0
votes

I have an image component in flex (mxml file), like below

<mx:image id="imageID"/>

I have a separate actionscript class and I am trying to set the source of the image from the init() in the actionscript class.

I am trying to access it like,

    [Embed(source="hello_world.png")]
        [Bindable]
        public var hello_world:Class;

        init()
    {
.................

        imageID.source = new hello_world();
....................
    }

But the image doesnt get displayed.

So my question is, how do we access the image component declared in the mxml page in the actionscript class.

2
...and? You forgot to ask a question here.Brian
I apologize for overlooking. Thanks for pointing it out @BrianShenoy Tinny
Ah, now I see the problem.Brian

2 Answers

0
votes

Judging by the answers on AS3 Embed images class and then get these images into another class?, you just need to cast your hello_world class as a Bitmap:

init()
{
.................

    imageID.source = new hello_world() as Bitmap;
....................
}
0
votes

try this

imageID.source = hello_world;