ActionScript 3.0:以编程方式加载图像 [英] ActionScript 3.0: load an image programmatically
本文介绍了ActionScript 3.0:以编程方式加载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用ActionScript 3.0开发Blackberry Playbock应用。我对此非常陌生。
I'm developing an Blackberry Playbock app with ActionScript 3.0. I'm very very new with this.
我具有以下项目结构(我使用的是Adobe Flash Builder Burrito):
I have the following project structure (I'm using Adobe Flash Builder "Burrito"):
项目
|
src
|
资产
|
图像
project | src | assets | images
在图像文件夹上,我有几个要以编程方式加载的PNG图片。
On image folder I have several PNGs images that I want to load programmatically.
然后
我必须使用哪个GUI组件来显示图像?
What GUI component I must use to show an image?
推荐答案
此示例加载一个图像并使用按钮对其进行更改:
This example loads one image and uses buttons to change it:
// create a Loader object to hold things that you will load
var myLoader:Loader = new Loader();
// position the Loader
myLoader.x = 250;
myLoader.y = 0;
// put something into the Loader
myLoader.load(new URLRequest("tree.jpg"));
// make the Loader visible
addChild(myLoader);
// button listeners
top_btn.addEventListener(MouseEvent.CLICK, loadPhoto);
last_btn.addEventListener(MouseEvent.CLICK, unloadAny);
// button functions
function loadPhoto(e:MouseEvent):void {
myLoader.load(new URLRequest("sailboat.jpg"));
addChild(myLoader);
}
// this function empties the Loader object
function unloadAny(e:MouseEvent):void {
removeChild(myLoader);
}
这篇关于ActionScript 3.0:以编程方式加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文