本文介绍了ActionScript 3.0中:编程加载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我开发一个黑莓Playbock应用程序使用ActionScript 3.0。我非常非常新的与此有关。
I'm developing an Blackberry Playbock app with ActionScript 3.0. I'm very very new with this.
我有以下项目结构(我使用的Adobe Flash Builder的卷饼):
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中:编程加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!