|
-
Components and dynamic content in flash??
I have a specific requirement for a UI component that I am working on. I would like to make the component so that a designer can update a graphics in live preview mode whilst keeping the associated class the same.
For example...
Lets take a button component which has an icon in the background and label. By setting an inspectable, I am able to set the label easily, but is it possible to point the icon to an image in say, the library or remotely etc? and have the image show as the background inside flash?
Many thanks for looking
RipX
[EDIT]
Ahhh...I'm not able to load extenal files into the client so the graphic would have to be a library asset? Possible?
Last edited by RipX; 10-22-2009 at 07:29 PM.
-
Senior Member
This works. First define the new parameter.
[Inspectable(name = "image",type = String)]
public function set image (im:String):void
{
_image = im;
}
public function get image ():String
{
return _image;
}
Then in the component script you write this:
if (image != null)
{
var _Class:Object = getDefinitionByName(image) as Class;
myBitmap = new _Class(width,height);
var bMap:Bitmap = new Bitmap(myBitmap);
addChild (bMap);
}
Somewhere you define myBitmap and cast as BitmapData.
In the library you have a default image, here "dfaul". Click on the image in the library and go to properties and export for actionscript. Give a class name. I usually use the name of the image but without the extension. You have to do that with all the images in the library.
Last edited by cancerinform; 10-23-2009 at 05:36 AM.
- The right of the People to create Flash movies shall not be infringed. -
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|