Home Tutorials Forums Articles Blogs Movies Library Employment Press
Prev Previous Post   Next Post Next
Old 04-26-2007, 10:23 PM   #1
CPedrick
Senior Member
 
Join Date: Sep 2006
Posts: 124
Default array not staying defined outside onLoad

I have a little picture viewer that I built that loads pictures from an array.
When I define the array contents within Flash, it runs beautifully. When I try to build the array with the same contents from an external text file, however, it says it can't find the pictures.

Here's the array, built in Flash, that works just fine:
ActionScript Code:
var picNames: Array = ["hotel1.jpg",         "hotel3.jpg",         "smores.jpg",         "sunday1.jpg"];

Here's the code I'm using to bring in the same information in from an external text file:

ActionScript Code:
picsLVs = new LoadVars(); picsLVs.load("pics.txt"); picsLVs.onLoad = function(success:Boolean):Void {     if (success) {         var picNames: Array = new Array();        //create picture name array from loaded text file         picNames = this.pictures.split(",");                    } else {         trace("Error loading/parsing LoadVars.");     }  //end if } //end onLoad function

And here's the contents of pics.txt (the text file I'm loading):

Code:
pictures="hotel1.jpg","hotel3.jpg","smores.jpg","sunday1.jpg"
The text file appears to load properly. If I trace the contents of the array within the onLoad function, it correctly displays the array as the contents of the imported text file.

If I trace the contents of the array outside the onLoad function, however, it returns the length of the array as "0" and the elements as "undefined", so for some reason, the array does not stay defined outside of the onLoad.

Any ideas?

TIA,
Carolyn
CPedrick is offline   Reply With Quote
 


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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading Music from an Array tfoston ActionScript 2.0 2 07-19-2007 03:24 PM
Array into shared object? Bushfire ActionScript 2.0 2 06-26-2006 09:31 PM
ASP Array not picked up as an array?! karwalr ActionScript 2.0 9 06-22-2006 08:35 PM
Can I make an array of pointers to other arrays? pulse ActionScript 2.0 5 04-12-2006 03:28 PM
sorting multidimensional numeric array in MX calculus ActionScript 1.0 (and below) 2 06-27-2005 03:51 PM


All times are GMT. The time now is 02:01 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.