PDA

View Full Version : [MX] Multiple setIntervals!



Felipe Bastos
June 20th, 2003, 10:25 PM
I want to combine various setIntervals.
The main Interval (10 sec) calls the function that loads the images.
What I want is to call another Interval (2.5sec) that calls a function that rotate the images (+90 degrees).
Here is the code:

// comando para fullscreen
fscommand("fullscreen", "true");
fscommand("allowscale", "false");

// funcao que attacha mc_loadimg e carrega img
function loadimg () {
var f1 = random(165) + 1;
//f2 = random(48) + 1;
loadMovie(f1 + ".jpg", "_root.conjunto.foto1");
loadMovie(f1 + ".jpg", "_root.conjunto.foto2");
loadMovie(f1 + ".jpg", "_root.conjunto.foto3");
loadMovie(f1 + ".jpg", "_root.conjunto.foto4");
trace ("img# = " + f1);
}

function rotateimg () {
_root.conjunto.foto1._rotation = 90;
_root.conjunto.foto1._x = _x + 300;
_root.conjunto.foto2._rotation = 90;
_root.conjunto.foto2._x = _x + 310;
_root.conjunto.foto3._rotation = -90;
_root.conjunto.foto3._x = _x + 300;
_root.conjunto.foto4._rotation = -90;
_root.conjunto.foto4._x = _x + 310;
trace ("function rotateimg OK");
}

//run the function initially
loadimg();
//use setInterval to run it every 5 seconds after that

setInterval(loadimg, 5000);
setInterval(rotateimg, 2500);

The crazy math that I did is because I reflected the movieclips, so I have to set their _x position after rotating the mcs.

Thanks
:)

lostinbeta
June 20th, 2003, 11:14 PM
And...?

Felipe Bastos
June 20th, 2003, 11:53 PM
Sorry......
hehe, and the setInterval (rotateimg) is called only the first time.
:(

lostinbeta
June 21st, 2003, 12:11 AM
I copied and pasted your code, it worked fine for me.

Let me double check...

lostinbeta
June 21st, 2003, 12:13 AM
Yep, worked fine, here was my output..


img# = 6
function rotateimg OK
img# = 69
function rotateimg OK
function rotateimg OK
img# = 94
function rotateimg OK
function rotateimg OK
img# = 145
function rotateimg OK

Felipe Bastos
June 21st, 2003, 03:06 AM
The function rotateimg is called. This is ok, but the images do not rotate.
just in the first call. Is there a way to rotate a movieclip according to its center? I want them to rotate but stays in the same position!

jonnooe
June 21st, 2003, 03:15 AM
set the MC's registration point to the center

Felipe Bastos
June 21st, 2003, 03:17 AM
If this is not too much..... create 3 imgs, named 1.jpg untill 3.jpg, 300x300px and put them in the same .swf file`s folder. They should rotate at first call, but when a new image is loaded, it does not rotate anymore.
Thanks

Felipe Bastos
June 21st, 2003, 03:18 AM
But the it is an empty movieclip that loads the jpg. How do I set its regiatration point to zero?

lostinbeta
June 21st, 2003, 11:41 AM
http://www.kirupaforum.com/forums/showthread.php?s=&threadid=26238

Felipe Bastos
June 21st, 2003, 12:55 PM
I have a lot of doubts on this thread.
First of all, here is my .fla.
I have on the stage (610x610px) four movieclips that resides the same loaded image.
But I modified them a little bit.
+ mc1(0,0) - no modification
+ mc2(610,0) - one flip horizontal
+ mc3(610,610) - one flip horizontal and one flip vertical
+ mc4(0,610) - one flip vertical
!!! The registration point of the mc is the upper left!!!
Thats why I had to fix their position on the stage after setting the flips.
And also on the function rotateimg I had to do this.
So I think I will have to set their center position after the image is loaded, correct? What I have to do? Just put the code after the loadMovie commands?

Thanks :thumb:

Felipe Bastos
June 21st, 2003, 12:57 PM
Sorry...
get it...

Felipe Bastos
June 21st, 2003, 01:14 PM
I was looking at the code and realized that this is worst than I thought.
If I set the x_scale and y_scale to -100, the image will appeear in a different position. I really need to set their center position to the center of the image, so I could rotate and flip whenever I need. Is this possible using only actionscript?

lostinbeta
June 21st, 2003, 03:50 PM
I get an unexpected file type error when opening your file. If you are on a mac you need to .zip it.

And the link I posted in my last post showed you exactly how to center your loaded content. Sure that used a dynamically loaded .jpg, but the same method goes for any dynamically loaded content.