Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Desktop, Mobile and non-browser Environments > Projectors and CDs

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-09-2012, 03:06 PM   #11
ASWC
Super Moderator
 
ASWC's Avatar
 
Join Date: Dec 2007
Location: Greenville, SC
Posts: 6,528
Default

Quote:
Originally Posted by failure666 View Post
Yeah i'm starting to think good about air, but i don't want to switch in existing project..
What's to switch? Obviously what you are doing right now has no incompatibility with AIR. You could just change the Flash setting to AIR and compile and get exactly the same result except that now you can write code to truly access any files in folders.
Maybe you have no experience with AIR and you think it's gonna be too complicated or you'll need to rewrite a bunch of code but that won't be the case. Just make the switch, compile, and see that everything is exactly the same just with more possibilities.
__________________
aswebcreations
Super Duper!
ASWC is offline   Reply With Quote
Old 05-09-2012, 05:40 PM   #12
failure666
Senior Member
 
failure666's Avatar
 
Join Date: Nov 2011
Location: Bermuda triangle
Posts: 216
Default

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

Last edited by failure666; 05-10-2012 at 08:43 AM.
failure666 is offline   Reply With Quote
Old 05-10-2012, 10:33 AM   #13
failure666
Senior Member
 
failure666's Avatar
 
Join Date: Nov 2011
Location: Bermuda triangle
Posts: 216
Default

Also a big problem, that if name is picture01 or picture10 (anything that got "0") it fails to load...Why? Any suggestions?
failure666 is offline   Reply With Quote
Old 05-10-2012, 03:17 PM   #14
abeall
Senior Member
 
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,796
Send a message via AIM to abeall
Default

"picture10" should work as is. "picture01" would not work because the number makes the url "picture1" not "picture01" -- you would need to add leading zeros.

This function will add leading zeros to a number:

ActionScript Code:
function addLeadingZeros(num:int, minDigits:uint = 2):String {     var str:String = num.toString();     while(str.length < minDigits){         str = "0" + str;     }     return str; }
__________________
Aaron Beall | Flash portfolio | Fireworks extensions | Twitter
abeall is offline   Reply With Quote
Old 05-10-2012, 04:49 PM   #15
failure666
Senior Member
 
failure666's Avatar
 
Join Date: Nov 2011
Location: Bermuda triangle
Posts: 216
Default

abeall
Quote:
should work as is. "picture01"
done!
I was an idiot, haven't noticed that i put picture10 with .jpeg, not .jpg...

So, reasonable question is:
Is there a way to make function that would define if extension is .jpg .jpeg or .png?
something like that:
var pattern:String = "gallery/picture###.####";

but i guess this is either impossible, either very complicated, coz amount of characters could be 3 or 4 and there are letters, not numbers...

This is not very important, but this question is important:
Quote:
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...
failure666 is offline   Reply With Quote
Old 05-11-2012, 07:46 PM   #16
failure666
Senior Member
 
failure666's Avatar
 
Join Date: Nov 2011
Location: Bermuda triangle
Posts: 216
Default

Ok, i figured out the best suitable if statement
ActionScript Code:
// function that adds URL inside an array function onNextGalleryComplete(e:Event):void {     // add current URL inside an array     imagesURL.push(currentURL);     if (currentNum == 1){         // after first URL written inside an array - load it         loadImage();     }     // load next URL     loadNext(); }

It works!

But i found another heavy problem....When i test my movie in flash and emultate slow network speed, it write trace like this:
Code:
trace("stopped at", gallery/picture12.jpg);
trace("stopped at", gallery/picture13.jpg);
But i got actually 11 pictures, and it writes 12 inside an array...
Any way of getting past this kind of slow-speed errors?
failure666 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:22 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.