ASWC
Yeah, i have try and it's nice to know...But i suppose my client will ask for web-site based on exactly same content...that's why i want to keep it strictly flash (universal), coz as i understand Flash player can't read some of AIR commands, like the one you suggested..
I just want to make something very universal, also for future projects, and it doesn't really matter how complex it will be
abeall
Hell...I still can't get it
This one should work fine as you said, but it loads only picture1 and trace of imagesURL array also shows only picture1...hmm
What i have missed?
ActionScript Code:
// create an array of URLs
var imagesURL:Array = [];
// start URL counter
var index:int;
// create new loader
var loaderImages:Loader = new Loader();
// create container
var images:MovieClip = new MovieClip();
var pattern:String = "gallery/picture###.jpg";
var currentURL:String;
var currentNum:int = 0;
currentNum++;
currentURL = pattern.replace("###", currentNum);
imagesURL.push(currentURL);
trace(imagesURL);
// command to load
loadImage();
// function that loads image
function loadImage():void {
// define image URL
var imagesURLreq:URLRequest = new URLRequest(imagesURL[index]);
// load image URL in loader
loaderImages.load(imagesURLreq);
// create listener so it would only execute loadNow function AFTER image is fully loaded
loaderImages.contentLoaderInfo.addEventListener(Event.COMPLETE, loadNow);
// set gallery loaded flag
galleryIsLoaded = true;
}
update 1:
Now i think i get it!
ActionScript Code:
var pattern:String = "gallery/picture###.jpg";
var currentURL:String;
var currentNum:int = 0;
loadNext();
function loadNext():void {
currentNum++;
currentURL = pattern.replace("###", currentNum);
var loader:Loader = new Loader();
loader.load(new URLRequest(currentURL));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onNextComplete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onNextError);
}
function onNextComplete(e:Event):void {
trace("loaded", currentURL);
imagesURL.push(currentURL);
loadNext();
}
function onNextError(e:IOErrorEvent):void {
trace("stopped at", currentURL);
trace(imagesURL);
}
Only thing left is to make some if statement, and i can't imagine how to do this...
I need to say somehow inside
onNextComplete function, that if imagesURL array already got it's first URL than i need to call
loadImage(); and this action must be executed only once...just to show first image, before other urls are pushed, coz it takes plenty of time to push all items...
update 2
Strange...but it take time only inside flash with ctrl + entere, in usual player it's fast..hmm