And another error on my part in doLoadImage replace i with movieCount

Alain Rousseau wrote:
Hi Paul,

actually what you should do with setInterval is something like setInterval(functionReference, interval); or to keep the scope of the interval : setInterval(this, "functionReference", interval);

secondly, if you want to load the image at a set interval, then your approach is wrong. You should call setInterval to attach a new movie and increment the count inside that interval. There is no delay in a for loop, at least none noticeable enough in this case. What is happening in your code is that all 5 pictures will appear at the same time after 1 second. Don't know if that's what you aim for.

in the case you want the pictures to appear at a 1 second interval, your code would become :

// if you're in a class do the following
private var myIntrvl:Number;
private var movieCount:Number;

// if not :
var myIntrvl:Number = 0;
var movieCount:Number = 0;

function loadImages() {
this.clearInterval(myIntrvl); // it's best practice to clear your interval before setting it, you never know where it has been set before
   myIntrvl = setInterval(this, "doLoadImage", 1000);
}

function doLoadImage() {
   movieCount++;
this.attachMovie("image"+i, "image"+i, 41); // allways refer to the movieClip you are attaching, in your case it's "this" image = this["image"+i]; // eval is deprecated in Flahs 8, so this is a better syntax
   // rest of your resizing code afterwards
}
  Hope this helps !


Alain

Paul V. wrote:
Let me explain the problem I am having and then I will send you some code. I want to load up images in a slide show with set interval, with the images being called image1 image2 image 3 etc. I want to be coding a dynamic slide show so that if I change the images I can just replace the mc images.

here is the code I am working on, I am a little new to setInterval (completely new to that function actually) - I do understand the basic syntax, setInterval( function (){ //entire function here;},1000);

But I don't know how to run a for loop inside it and pass a variable to it. (I am a newbie).

function loadImages(){ //Ihave this here so I can run an external for loop. for(i=1;i<6;i++){ setInterval(function(){ //set interval and begins anonymous function i.e function() -no name attachMovie("image"+i,"image"+i,41); //trying to attach the images, image1 - image5 image = eval("image"+i); //instance assigned to variable 'image'
      image._x = ((Stage.width / 2)-(image._width/2));   //positioning
image._y = (yFactor); //positioning oldwidth = image._width; //saving dimensions for resizing formula oldheight = image._height; //saving dimensions for resizing formula image._height = yheight; //image height set to variable image._width = ((oldwidth*yheight)/oldheight); //image width set to proportions of original },1000); //interval to 1 sec. 1000 milliseconds } //end for loop } //end container function
I am trying to set the images up for a second and then have them switch.
Help me out if you you know a solution. Or even if you see some obvious errors. Like I said I am new with the set interval. by the way if you like that little resizing technique, you can use it. Thank you.

Looking forward to a response on this one.

Paul Vdst
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com



_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com



_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to