actionscript3 -从actionscript3访问flex中的图像组件



我有一个图像组件在flex (mxml文件),像下面

<mx:image id="imageID"/>

我有一个单独的actionscript类,我试图从init()在actionscript类设置图像的来源。

我正在尝试访问它,如

    [Embed(source="hello_world.png")]
        [Bindable]
        public var hello_world:Class;
        init()
    {
.................
        imageID.source = new hello_world();
....................
    }

但是图像没有显示。

所以我的问题是,我们如何访问actionscript类中mxml页面中声明的图像组件

根据AS3上的答案来判断嵌入图像类,然后将这些图像放入另一个类?,您只需要将hello_world类转换为Bitmap:

init()
{
.................
    imageID.source = new hello_world() as Bitmap;
....................
}

try this

imageID。

最新更新