简体   繁体   English

将外部图像加载为空符号as3

[英]load external image to empty symbol as3

I'm trying to load an image to a symbol. 我正在尝试将图像加载到符号。

I've looked at every answer but seems they got side tract with similar solution but no explanation on how to get the image to appear in the empty symbol. 我已经查看了所有答案,但似乎他们得到了类似解决方案的建议,但没有说明如何使图像显示在空符号中。

Here is my code I got here and works but image not assigned to symbol. 这是我到达这里可以正常工作的代码,但是图像未分配给符号。

var loader:Loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
    loader.load(new URLRequest("Red_X.png"));

function onComplete (event:Event):void
{
    addChild(Bitmap(LoaderInfo(event.target).content));
}

Thanks in advance. 提前致谢。

There's no need to wait for the Loader to finish and extract its content. 无需等待加载程序完成并提取其内容。 Simply add the Loader right away. 只需立即添加装载程序。

To add to a different container, you have to call the add method on that container. 要添加到其他容器,必须在该容器上调用add方法。

var loader:Loader = new Loader();
empty.addChild(loader);
loader.load(new URLRequest("Red_X.png"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM