Re: [flexcoders] Use an Image as an icon

2006-12-13 Thread Lachlan Cotter

Hi Even,

I may be wrong, but I'm pretty sure the case is this:

Meta-data and embedded assets are interpreted at compile time.

Program variables are assigned at runtime.

It doesn't really make sense therefore to assign a compile time  
constant the value of a runtime variable. I.e. var image won't ==  
'image.jpg' until your program is running. I'm not sure I really see  
the point of what you're trying to accomplish here.


If you want to change the button's icon while the program is running,  
you might have to say something like:


[Embed('about.jpg')]
public var img:Class;

public function changeIcon ():void
{
btn.setStyle('icon', img);
}

Cheers,
Lach



On 07/12/2006, at 8:31 AM, ejb4424 wrote:


Hello. Can anybody tell me either how to use an image as an icon, or
convert an image to a class for use as an icon (in components, the
icon is of type Class)? Or better yet is it possible for
me to dynamically embed an image via a variable?

Sure the usual embed assertion works:
[Embed('image.jpg')]
[Bindable] var img:Class;
...
mx:Button label=button icon={img} /

But what I want to do is embed the image via a variable such as:
var image:String = image.jpg;
[Embed(image)]
var img:Class;

What I'm trying to do is a bit more complex, but help with this simple
example should get me going. Any help would be appreciated. Thanks.

Evan




[flexcoders] Use an Image as an icon

2006-12-06 Thread ejb4424
Hello.  Can anybody tell me either how to use an image as an icon, or
convert an image to a class for use as an icon (in components, the
icon is of type Class)?  Or better yet is it possible for
me to dynamically embed an image via a variable?

Sure the usual embed assertion works:
[Embed('image.jpg')]
[Bindable] var img:Class;
...
mx:Button label=button icon={img} /

But what I want to do is embed the image via a variable such as:
var image:String = image.jpg;
[Embed(image)]
var img:Class;

What I'm trying to do is a bit more complex, but help with this simple
example should get me going.  Any help would be appreciated.  Thanks.

Evan