Flex AS3: Assign a button's upSkin property with a remote file dynamically?
Posted
by aaron.lovelace
on Stack Overflow
See other posts from Stack Overflow
or by aaron.lovelace
Published on 2010-03-18T08:08:32Z
Indexed on
2010/03/18
8:11 UTC
Read the original article
Hit count: 506
actionscript-3
|flex
I am building a Flex application with ActionScript 3. Unfortunately I've hit a wall with this one...
I would like to be able to apply an upSkin to my dynamically generated button like this:
//this theSkin variable is dynamic in my app, but for this example it's a simple string
var theSkin:String = "http://www.mypicturedomain.com/images/myimage.gif";
var navBtn:Button = new Button();
navBtn.id = "thumb1";
navBtn.width = 60;
navBtn.height = 45;
//skin the button
navBtn.setStyle("upSkin", theSkin);
//add the button to my canvas
myCanvas.addChild(navBtn);
When I attempt this, I get this error:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Loader@3dac941 to Class.
How do I skin this button with my image dynamically? A couple of things to consider:
- The upSkin image must be remote. It can't be local.
- The button must be generated dynamically (it's in a for loop).
Any help/ideas would be much appreciated at this point!
© Stack Overflow or respective owner