One of the quickest ways to clear up scope issues using setInterval is to
use the Delegate class...

http://www.actionscript.org/resources/articles/205/1/The-Delegate-Class/Page
1.html

Lukas

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Richard
Mueller
Sent: Tuesday, January 22, 2008 1:52 PM
To: [email protected]
Subject: [Flashcoders] Scope Issue?


I'm trying create a simple image slide show using the MovieClipLoader and 
setInterval, and I can't get a reference back to my dynamic MC logo
containers.

In my class I have :

private function createSlides(logoData:Object){

                 trace('//Creating Slides');
                 var ref = this;

                 totalLogos = logoData.length;

                 for(var i = 0; i < totalLogos; i++){
                         var tempLogo = 
target.createEmptyMovieClip('logo'+i, target.getNextHighestDepth());
                         tempLogo.website = logoData[i].attributes.website;
 
imageLoader.loadClip(logoData[i].attributes.image,tempLogo); 


                 }
                 logoInterval = 
setInterval(this,'slideshow',3000);
         }


'target' is a reference back to the main MC instance(container).  Images 
load just fine.

private function slideshow():Void {
                 trace(target);
                 trace(currLogoIdx);
                 trace('grrr = '+ target.logo[currLogoIdx]);
                 //var logoFadeIn:Tween = new 
Tween(target.logo[currLogoIdx], "_alpha", Strong.easeIn, 0, 100, 1, true);
                 if(currLogoIdx == (totalLogos - 1)){
                         currLogoIdx = 0;
                 } else {
                         currLogoIdx++;
                 }
         }

My trace on 'target' and 'currLogoIdx' return proper values, but the one on 
target.logo[currLogoIdx] returns undefined.
If I trace('grrr = '+ target.logo1);  or logo2, logo3 and so on, it returns 
the proper MC path.  Any ideas?

Richard




_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to