[flexcoders] How do I add an swf/image in meta data in my setter

2008-06-26 Thread djhatrick
I was trying to follow the logic in the mx:Button class on how to add
an icon to a simple UIComponent i created with a setter that looks
like this:

view:SimpleFunComponent id=toolButton
icon=@Embed(source='/assets/tool_icon.swf')/

I don't really understand how to cast my classname (as i was trying to
extract some stuff out of button to help me out - but it's way
complicated). I cam getting errors - any way I dice this.  Would
somebody have a little time who has experience help me to road of
total happiness please.  Maybe I am close, but i am probably way off.

Thanks for your help, this is a little over my head working with
metadata trying to create a class on the fly.

Ptrick



public function set icon(tempIconName:String):void
{

var newIconClass:Class = Class(tempIconName);
var newIcon:IFlexDisplayObject;
newIcon = IFlexDisplayObject(new newIconClass());
addChild(DisplayObject(newIcon));
 


}




RE: [flexcoders] How do I add an swf/image in meta data in my setter

2008-06-26 Thread Alex Harui
Public function set icon(iconClass:Class):void

 

@Embed returns a class.

 

If you want to handle external content as well, look at SWFLoader.source

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of djhatrick
Sent: Wednesday, June 25, 2008 11:12 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] How do I add an swf/image in meta data in my
setter

 

I was trying to follow the logic in the mx:Button class on how to add
an icon to a simple UIComponent i created with a setter that looks
like this:

view:SimpleFunComponent id=toolButton
icon=@Embed(source='/assets/tool_icon.swf')/

I don't really understand how to cast my classname (as i was trying to
extract some stuff out of button to help me out - but it's way
complicated). I cam getting errors - any way I dice this. Would
somebody have a little time who has experience help me to road of
total happiness please. Maybe I am close, but i am probably way off.

Thanks for your help, this is a little over my head working with
metadata trying to create a class on the fly.

Ptrick

public function set icon(tempIconName:String):void
{

var newIconClass:Class = Class(tempIconName);
var newIcon:IFlexDisplayObject;
newIcon = IFlexDisplayObject(new newIconClass());
addChild(DisplayObject(newIcon));



}