# \[MX\] Multiple setIntervals!

**URL:** <https://forum.kirupa.com/t/mx-multiple-setintervals/23688>\
**Category:** flash\
**Created:** [June 21, 2003, 2:25am UTC](https://forum.kirupa.com/t/mx-multiple-setintervals/23688 "2003-06-21T02:25:47Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Felipe\_Bastos](https://avatars.discourse-cdn.com/v4/letter/f/f05b48/32.png) [@Felipe\_Bastos](https://forum.kirupa.com/u/Felipe_Bastos)\
**Post date:** [June 21, 2003, 2:25am UTC](https://forum.kirupa.com/t/mx-multiple-setintervals/23688/1 "2003-06-21T02:25:47Z")

</div>

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:

```auto
// 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  
🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 21, 2003, 3:14am UTC](https://forum.kirupa.com/t/mx-multiple-setintervals/23688/2 "2003-06-21T03:14:20Z")

</div>

And…?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 21, 2003, 3:53am UTC](https://forum.kirupa.com/t/mx-multiple-setintervals/23688/3 "2003-06-21T03:53:23Z")

</div>

Sorry…  
hehe, and the setInterval (rotateimg) is called only the first time.  
☹

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 21, 2003, 4:11am UTC](https://forum.kirupa.com/t/mx-multiple-setintervals/23688/4 "2003-06-21T04:11:31Z")

</div>

I copied and pasted your code, it worked fine for me.

Let me double check…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 21, 2003, 4:13am UTC](https://forum.kirupa.com/t/mx-multiple-setintervals/23688/5 "2003-06-21T04:13:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 21, 2003, 7:06am UTC](https://forum.kirupa.com/t/mx-multiple-setintervals/23688/6 "2003-06-21T07:06:03Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 21, 2003, 7:15am UTC](https://forum.kirupa.com/t/mx-multiple-setintervals/23688/7 "2003-06-21T07:15:52Z")

</div>

set the MC’s registration point to the center

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 21, 2003, 7:17am UTC](https://forum.kirupa.com/t/mx-multiple-setintervals/23688/8 "2003-06-21T07:17:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 21, 2003, 7:18am UTC](https://forum.kirupa.com/t/mx-multiple-setintervals/23688/9 "2003-06-21T07:18:43Z")

</div>

But the it is an empty movieclip that loads the jpg. How do I set its regiatration point to zero?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 21, 2003, 3:41pm UTC](https://forum.kirupa.com/t/mx-multiple-setintervals/23688/10 "2003-06-21T15:41:13Z")

</div>

[http://www.kirupaforum.com/forums/showthread.php?s=&threadid=26238](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=26238)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 21, 2003, 4:55pm UTC](https://forum.kirupa.com/t/mx-multiple-setintervals/23688/11 "2003-06-21T16:55:57Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 21, 2003, 4:57pm UTC](https://forum.kirupa.com/t/mx-multiple-setintervals/23688/12 "2003-06-21T16:57:29Z")

</div>

Sorry…  
get it…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 21, 2003, 5:14pm UTC](https://forum.kirupa.com/t/mx-multiple-setintervals/23688/13 "2003-06-21T17:14:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 21, 2003, 7:50pm UTC](https://forum.kirupa.com/t/mx-multiple-setintervals/23688/14 "2003-06-21T19:50:20Z")

</div>

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.
