I'm developing an Blackberry Playbock app with ActionScript 3.0. I'm very very new with this.
I have the following project structure (I'm using Adobe Flash Builder "Burrito"):
project
|
src
|
assets
|
images
On image folder I have several PNGs images that I want to load programmatically.
How can I do that?
And
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);
}
if u want to show multiple image using for loop then follow this code:
var IMAGE_URL:String = new String("image/");
for(var i=1;i<=13;i++){
addChild(imageLoder(i,i*25));
}
private function imageLoder(ranvalue:int,cor:int):Loader{
var ldr:Loader = new Loader();
ldr.load(new URLRequest(IMAGE_URL+ranvalue+".jpg"));
var xcord=5;
var ycord=5;
ldr.x = cor;
ldr.y = ycord+20;
return ldr;
}