Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-15-2006, 07:04 PM   #1
shrinkwrapped
Registered User
 
Join Date: Sep 2002
Posts: 20
Default array from external text file loop problems

I have an external text file that loads into an array and splits at the commas that is working. The first item from the file is a link to a external .swf file which also loads wonderfully.
The loaded text file is this
PHP Code:
&labMap=testing.swf,working,off,broken 
The other items from the file target frame labels inside a movieclip from the loaded swf file.

If I manually tell the items where to go it works
PHP Code:
var itemlocation=this.labMap[1];
floorplan.desk1.gotoAndPlay(itemlocation); 

When I try to get the other items to do my bidding things aren't working so good. Either nothing happens or undefined errors. How do I use a loop to get the other items to trigger my movieclip without having to manually enter the information?

Here is the whole mess. help...


PHP Code:
var loadMap:LoadVars = new LoadVars();
loadMap.onLoad = function(success:Boolean):Void {
    if (
success) {
        
trace(this.labMap); // List all the names from the file
        
        //Split the loaded text file at the commas
        
this.labMap this.labMap.split(',');//split things at the comma            
            //load the room swf into the floorplan mc loacted on the stage
            
var floorplanitem=this.labMap[0];                                                
            
this.createEmptyMovieClip("floorplan"1);
            
            
//load the room status information into the appropriate spots when done loading        
            
var mclListener:Object = new Object();
            
mclListener.onLoadInit = function(target_mc:MovieClip) {
                
trace("movie loaded");
                
//movie loaded tell the movieclips inside the loaded swf where to go                
                    
var i:Number;                    
                    for (
0this.labMap.lengthi++) {
                            var 
desknumber ="desk"+i;        
                         
trace (desknumber);
                         var 
itemStatus=this.labMap[i];
                         
floorplan.desknumber.gotoAndPlay(itemStatus);
                        }                    
                
                }
            var 
image_mcl:MovieClipLoader = new MovieClipLoader();
            
image_mcl.addListener(mclListener);
            
image_mcl.loadClip(floorplanitemfloorplan);
            
                            
    } else {
        
trace("Error");
    }


}
//load the text file for the room contents
loadMap.load("loadVarsRooms.txt"); 
shrinkwrapped is offline   Reply With Quote
Old 07-15-2006, 08:29 PM   #2
webreake
Senior Member
 
Join Date: Oct 2003
Location: mexico
Posts: 214
Send a message via MSN to webreake Send a message via Skype™ to webreake
Default

hi
i dont know if i undestand the problem but i think you need to begin your "for" loop from one like this
Code:
 for (i = 1; i < this.labMap.length; i++) { 
                            var desknumber ="desk"+i;         
                         trace (desknumber); 
                         var itemStatus=this.labMap[i]; 
                         floorplan.desknumber.gotoAndPlay(itemStatus); 
                        }
Suerte!!
webreake is offline   Reply With Quote
Old 07-16-2006, 12:59 AM   #3
shrinkwrapped
Registered User
 
Join Date: Sep 2002
Posts: 20
Default

Thanks for your reply.
I am thinking its something with the mclListerner because when I trace this.labMap.length; inside my listener I get undefined. If I trace it the line before I get the correct array amount. I have to use the listener to wait for the swf to load or else it doesn't target the movieclip.
shrinkwrapped is offline   Reply With Quote
Old 07-17-2006, 08:58 PM   #4
webreake
Senior Member
 
Join Date: Oct 2003
Location: mexico
Posts: 214
Send a message via MSN to webreake Send a message via Skype™ to webreake
Default

check your scopes!
Im using linux right now so i cant check it
i think when you are inside of the mclListener block when you use "this" you are targeting mcListener but you want to target loadMap so instead of using this use loadMap.labMap.length
im not sure you should try it
webreake is offline   Reply With Quote
Old 07-17-2006, 10:59 PM   #5
shrinkwrapped
Registered User
 
Join Date: Sep 2002
Posts: 20
Default

I think I have it working now. I ended up creating a new array before my listener for the movieclip labels. Then I had to use eval inside my listener to get everything to be placed properly on the stage. Not sure if its coding savy but it seems to be working
PHP Code:
var i:Number;                        
for(
i=0;i<howmany;i++){ 
//assign desk number and place the mc status
var desknumber:Object = eval("floorplan.desk" i);
desknumber.gotoAndPlay(deskStatus[i]);

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Optimizing Flash Web Sites for Search Engines rockcoastmedia General Chat 19 03-29-2009 09:31 PM
calling a PDF file in Flash AudryLucy Projectors and CDs 20 12-30-2006 01:43 PM
External Text File Slideshow flashboulder ActionScript 2.0 2 03-14-2005 03:23 AM
load array from external text file Jins ActionScript 1.0 (and below) 6 07-07-2004 01:28 AM
using variables in external text file while running *.exe dartagnan324 Projectors and CDs 1 08-07-2003 04:14 AM


All times are GMT. The time now is 09:25 AM.

///
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.