[flexcoders] Flash CS3 Components - Custom Properties Methods

2007-10-02 Thread byte.sensei
I've been experimenting with Flex SWC Components developed in Flash 
CS3 (using Flex Component Kit for Flash CS3).

I've successfully created some custom properties/methods on these 
that I can use in Flex.  Here's a quick example of a UIMovieClip 
class extension:

package {
import mx.flash.UIMovieClip;
public dynamic class forestDragon extends UIMovieClip {
public var current_state : String = ;
public var my_name : String = ;
public var my_color : String = ;

public function forestDragon():void {
}

public function fly_begin():void {
gotoAndPlay(1);
}

public function fly_end():void {
gotoAndStop(1);
}
}
}


So, in Flex I can then get/set the current_state variable and call 
the fly_begin() and fly_end() methods as needed to start/stop the 
component animations.

All of this works great, but I'm now faced with a new challenge.  For 
example, I want to be able to set my_color and/or my_name via Flex 
and then have it change the color of the Flash object or change the 
text underneath the animation to whatever my_name is set to, etc.

However, I can't figure out how I can reference these properties or 
use them to control aspects of the Flash movie clip.  I first tried 
creating a dynamic text instance on the Flash movie clip but whenever 
I publish the SWC it's throwing an error.  I can add dynamic text 
elements to the Flash movie clip, but if I give it an instance name 
it won't compile/export.

Obviously, the real strength of Flex Components developed in Flash 
CS3 comes when you can take advantage of custom properties/methods to 
change aspects of the Flash movie clip dynamically via Flex.  Am I 
approaching this the right way, and if so (or not) can anyone provide 
some direction/insight on how to accomplish this?

Thanks!




RE: [flexcoders] Flash CS3 Components - Custom Properties Methods

2007-10-02 Thread Mike Krotscheck
Use Getter/Setters, like this.

 

package {
import mx.flash.UIMovieClip;
public dynamic class forestDragon extends UIMovieClip { 
private var _my_name : String = ;
private var _my_color : String = ;

private var _my_textfield:TextField;
public var current_state : String = ;



public function set my_name(value:String):void

{

_my_name = value;

_my_textField.text = _my_name;

}

public function get my_name():String

{

return _my_name;

}

 

public function set my_color (value:String):void

{

_my_color = value;

_my_textField.setStyle(color, _my_color);

}

public function get my_color ():String

{

return _my_color;

}

 


public function forestDragon():void {
}

public function fly_begin():void {
gotoAndPlay(1);
}

public function fly_end():void {
gotoAndStop(1);
}
}
}

 

Michael Krotscheck

Senior Developer

 
RESOURCE INTERACTIVE

http://www.resource.com/ www.resource.com http://www.resource.com 

[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 



This email and any of its attachments may contain Resource Interactive
proprietary information, which is privileged, confidential and may be
subject to copyright or other intellectual property rights belonging to
Resource Interactive. This email is intended solely for the use of the
individual or entity to which it is addressed. If you are not the
intended recipient of this email, you are hereby notified that any
dissemination, distribution, copying or action taken in relation to the
contents of and attachments to this email is strictly prohibited and may
be unlawful. If you have received this email in error, please notify the
sender immediately and permanently delete the original and any copy of
this email and any printout.




From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of byte.sensei
Sent: Tuesday, October 02, 2007 9:09 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Flash CS3 Components - Custom Properties  Methods

 

I've been experimenting with Flex SWC Components developed in Flash 
CS3 (using Flex Component Kit for Flash CS3).

I've successfully created some custom properties/methods on these 
that I can use in Flex. Here's a quick example of a UIMovieClip 
class extension:

package {
import mx.flash.UIMovieClip;
public dynamic class forestDragon extends UIMovieClip {
public var current_state : String = ;
public var my_name : String = ;
public var my_color : String = ;

public function forestDragon():void {
}

public function fly_begin():void {
gotoAndPlay(1);
}

public function fly_end():void {
gotoAndStop(1);
}
}
}

So, in Flex I can then get/set the current_state variable and call 
the fly_begin() and fly_end() methods as needed to start/stop the 
component animations.

All of this works great, but I'm now faced with a new challenge. For 
example, I want to be able to set my_color and/or my_name via Flex 
and then have it change the color of the Flash object or change the 
text underneath the animation to whatever my_name is set to, etc.

However, I can't figure out how I can reference these properties or 
use them to control aspects of the Flash movie clip. I first tried 
creating a dynamic text instance on the Flash movie clip but whenever 
I publish the SWC it's throwing an error. I can add dynamic text 
elements to the Flash movie clip, but if I give it an instance name 
it won't compile/export.

Obviously, the real strength of Flex Components developed in Flash 
CS3 comes when you can take advantage of custom properties/methods to 
change aspects of the Flash movie clip dynamically via Flex. Am I 
approaching this the right way, and if so (or not) can anyone provide 
some direction/insight on how to accomplish this?

Thanks!