【问题标题】:accessing an image component in flex from actionscript3从 actionscript3 访问 flex 中的图像组件
【发布时间】:2015-07-27 11:55:39
【问题描述】:

我在 flex(mxml 文件)中有一个图像组件,如下所示

<mx:image id="imageID"/>

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

我正在尝试访问它,

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

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

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

但是图片没有显示出来。

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

【问题讨论】:

  • ...和?你忘了在这里问问题。
  • 我为疏忽道歉。感谢您指出@Brian
  • 啊,现在我明白了。

标签: actionscript-3 apache-flex


【解决方案1】:

AS3 Embed images class and then get these images into another class? 上的答案来看,您只需要将您的hello_world 类转换为Bitmap

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

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

【讨论】:

    【解决方案2】:

    试试这个

    imageID.source = hello_world;

    【讨论】:

      猜你喜欢
      • 2019-08-30
      • 1970-01-01
      • 1970-01-01
      • 2014-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多