Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Finite Loops



how can I make a movie make a certain # of loops (20) in the scene then contue till the end..



FlashKit > Flash Help > Flash General Help
Posted on: 02-11-2004, 06:23 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Finite Menu...help
I have been trying to use a finite menu for sometime. Member (Scotty) had poster an .fla of what I was looking for. The only problem I am having is the movieclip contents go back to it's starting point once the mouse is rolled out of the mask area. Is there anyway to have the MC come to a stand still once the mose has left the area.

Thanks

Making A Finite Loop
I know this is prolly Flash 101, but how does one go about creating a finite loop with a movie clip?

We have created a movie clip that we would like to loop 3 times & then stop. The down & dirty way we did this is to just copy & paste the same animation within the clip 3 x, but I know there's prolly an easy way to script it instead.

My thought was to attach a variable that would tell the clip to play [variable]times, but that maybe a bit overkill.

Thoughts?

Thanks,
Robs

FINITE PHOTO SHOW LIKE THIS?
I wanna create one like this... using _xmouse and _ymouse.
like: http://www.luacrescente.com.br/

did anyone do this, or like this?
need this help!

Generating Finite Random Colors
I've got some words floating around a screen using action scripting. Each word needs to be 1 of 4 specific colors: OxIE506E, Ox5F690F, 0xB93714, and Ox9B0F37. But I want each word's color to be randomly generated from those four possibilities. I know this is simple, but I can't quite work it out.

Here's an advanced version of the problem, less crucial. If there are say, 4 different words, is there a way to randomly choose from those 4 colors but not have the same color picked twice?

Looping A Scene A Finite Number Of Times
I use this code in frame 10:

for (i=0,i<5,i++){
goToAndPlay (9-i)
}

I'd expect to se the frames: 10 (the code start to run, i=0)
9 10
8 9 10
7 8 9 10
6 7 8 9 10
5 6 7 8 9 10

but that I see is the last line repeated till the infinite.
I checked possible contradictions of others objet actionscripts and this not occur.
Besides of my head, something is wrong, but what?.

Make This Script Only Run For Finite Number Of Frames?
Hello I am a total noob,

I saw this example script and got it to work, and I want to use it for only certain frames, but the effect it produces shows in every frame of my show. How can I make it only produce the effect in the frames I want? Thanks in advanced!

i = "1";
alpha = "0.8";
maxlight = "20";
while (Number(i)<=Number(maxlight)) {
duplicateMovieClip ("ray0", "ray" add i, 800-i);
setProperty ("/ray" add i, _xscale, getProperty("/ray" add (i-1), _xscale)+i*alpha);
setProperty ("/ray" add i, _yscale, getProperty("/ray" add (i-1), _yscale)+i*alpha);
setProperty ("/ray" add i, _alpha, 10-i*(0.5/50));
i = Number(i)+1;
}
setProperty ("ray0", _visible, "0");
stop ();

[MX04] SetInterval Function Running Finite Number Of Times...
Hi,

I was wondering if someone could look over this(see code below). It basically stops responding and offers to stop running the script.

What I'm trying to do is run a function a finite number of times with an interval between each time it runs.

There may be a better way of doing it otherwise but any suggestions would be brill, Ta.

Neily


PHP Code:



onClipEvent (mouseUp) {
    var Counter=0;
    
    do {
        setInterval(TraceTest,1000);
    } while (Counter<=10);

    setInterval(TraceTest,1000);
    
    function TraceTest(){
        trace("Function Called" + Counter);
        Counter++;
    }
}

Looping Loops Of Loops
First of all, a BIG hello to the Flash kit Community...

this is my first post to this board, wont be my last :P

now to business... i have a small problem. What i need to create is an accelerating counter... eg.


Code:
at frame | the counter says| special counter
1 0 25
25 1 24
49 2 23
72 3 22
94 4 21

so as the movie iterates through the special counter drops by 1 until the counter is looping at 25fps. the counter(ascending)controls a movieclip which contains images of numbers(these refer to seconds). when that counter gets to 10 it resets and pushes the "tens of seconds counter" up by one......now what i want to do id

i hope i havent lost anyone....

now when the "seconds" start iterating at 25fps i want the "tens of seconds" to begin accelerating .... and so on through minutes, tens of minutes and finally hours.

so far it is shaping up as an evil series of nested ifs.... there has to be a better way.... any ideas?
tricky bits arise also as "tens of minutes" and "tens of seconds" loops from 1 to 6 ....

"hours" shouldnt need to iterate for too long anyways...


if anyone has some ideas i would very much like to hear them :P

I'm Having Problems With "if " Loops Inside "for" Loops. Help?
I am trying to execute an "if" statement inside a "for" loop. There are no formating errors in the script, but when I test the movie, it hangs for a minute or so, then a message comes up saying that my code might be to complex. Could somebody maybe shed some light on this?

Do While Loops
I must be retarded....

I want a loop something till count = 19. but my script keeps scrashing me or returns only when count = 19.


do {
count = count + 1;
trace (count);
} while (count eq 19);


i want this result in my trace...
1
2
3
4
5
6
7
8
9
.
.
.
19

######FOR Loops#####
hi guys, a little problem with my for loop

when i want to set up a counter limited to lets say 30 iterations using the FOR loop, Flash counts all the way to 30 without executing the code inside the FOR loop.


Code:
on (press) {
for (c=1;c<target;c++){
duplicateMovieClip (crap, "crap"+c, c);
_root["crap"+c]._x = c*50;
c = c+1;
target=30;
}
}
any one know what i'm talking about? please help!

Loops?
Going to the basics. How do you make a loop. Could you please post the script that shows an example.

I would like to Loop a script to add a variable everytime making it +1 everytime Then starting over after say 100.
Thanks in advance.
Andy

Two Loops At Once?
i have seen 2 loops or what looks like 2 loops happening at once and out of sequence. After the first loop has ended the second loop continues while the first loop restarts. I dont understand how that is possible? If it is possible or an explaination can be given, please reply how.

Thanx

Mp3 Loops
im trying to download a loop as an mp3, and whenever the download screen comes up, the loops is played in real player instead of saved on my hard drive. is there a way to make the loop save to my drive from real player? or how can i disable real player from automatically launching?

thanks
dazvoltron

ps is the flash player easier to use and smaller than mp3's? if so could someone tell me where i could find a tutorial for flashplayers? thanks alot

Loops?
I'm trying to get a movie clip to dulpilcate 20 times. It will only duplicate twice. Heres my code tell me what im doing wrong

on (press) {
for (j = 0; j < 20; j++) {
duplicateMovieClip("bug","bug",1);
bug._x = random(100);
bug._y = random(20);
}
}

Thanks

Davy

Loops
Here is a small script I wrote that is working fine for me, but I'm not sure why it works the way that it does. My movie is playing at 24 fps and I am using this frame with an MC on the main timeline as a simple timer to sit on the frame until the loop is satisfied...then moving on to the _root frame label "rest". My thougth was that the loop would be incrementing "i" 24 times per/sec, which isn't the case at all. The numers I have now (1000*75) is about 2.5 seconds. Why is this????


onClipEvent (enterFrame) {
for (i=0; i<(1000*75); i+=1) {
}
if (i>=(1000*75)) {
_root.gotoAndStop ("rest");
}
}

Loops
hello all,
is it possible to set up a loop to for example do this

tellTarget (_level1) {
gotoAndPlay ("menu1");
}

for 1 to 10 ? (ie level2,menu2)

Thanks for any help
Al

Loops...
Not sure if this belongs in the Newbs forum, but since it does involve FLASH 5 actionscript....anyway.

I never used any actionscript in FLASH 4 except for basic preloaders and the geturl, and i have only a VERY basic knowledge of C++, (which this looks alot like), so im stuck on this stupid thing alot of you probably think is easy as hell:

How do i tell my movie when to stop a loop. I figured out how to get a loop going (and was i proud? You bet) by saying

if (_currentframe = 9) {
gotoAndPlay (1);
}


Now what im trying to do is get it to STOP looping so i can play the rest of my movie. I was hoping maybe there was a way to do so when a certain amount of seconds, or maybe rotations of the loop, have elapsed but damned if i know how.

Also, for those of you who know C++, is there a way to simply declare and use a variable? Like if i want to declare a variable called numLoops, and increment it by 1 every time currentframe = 9, then using it later in an if statement like if(numLoops = X) [code for stopping loop].
Probably can, but again, no ideas how.

Thx for any help

-Fate

Loops
cant belive this slipped my mind
how do you make a sound loop?

Mp3 Loops
hello friends,

hope you are having a splendid day, afternoon, evening, night where ever you are right now. here my questions. I working with a bunch of loops that are randomly playing, all of that works fine, the problem is just that when I replay the sound onSoundComplete a little splitsecond there is silence, so it ain't really looping. Is it recommended to use the sound object at all when wanting to play background music?

If not, cause I have been working on this one as well, I created seperate swfs with my loops in them, same concept they randomly picked then playd. But then my neat fade in fade out function I wrote is no good, cause it seems the get and setVolume are again reserved for the sound object.

So basically two questions, and answer to one of them will make me happy enough.

1. Anyway to avoid skipping when using the sound object for looping backgroundmusic

or

2. Can I set the volume of a loaded movie the same way I can with a loaded Sound?

Loops?
How can i define how many loops for a symbol to travel along a path?

I tried to make a flash with 2 object -
1) a planet (circle)
2) a planet Ring (a hollow circle)

how do i make it that the the planet is in the center of the planet ring? Because when i tried it with the planet layer on top of the planet ring layer the planet covers the ring layer and the ring appears to be behind it.

eh about the planet question. It is like bringing the planet back of the ring at certain part of the loop so that the ring will look like it is looping around the planet

Loops ?
does anyone know any easy to understand tutorials on loops (for loop, while, do while loop and all the rest of that) for some reason i can not grasp it, its really annoying me.
thanks
najib

Loops
I have a movie clip containing 4 frames. I would like the frames to loop a limited number of times before stopping. How can I do this using actionscript ?

Loops
I am trying to get a loop to work but every time it runs through the loop and then the code giving me only one duplicate of the movie post99. here is the code:

for (i=2;i<100;i++)
{duplicateMovieClip("post1", "post"+i, 1);
setProperty("post"+i, _x, i+50);
setProperty("post"+i, _y, i+50);
setProperty("post"+i, _visible, "true");}

any help would be appreciated. Thanks

Loops
hey guys...i have a problem with looping movie clips. i have this one movie clip inside another one, so that when you click a button, it plays the "inside" (i guess you could call it child) movie clip...but the problem is this: you click the button and it plays the movie fine...but it plays it over and over and over again....it loops it. is there a way to turn loops off in movie clips?? thanks for all your help in advance!!

While Loops
Can someone help and give a tut opn while loops? When used, etc...

Where Are The Loops
i need some loops and i can't find them help me plz

Loops
Hey all-

I am working on a book by Macromedia on Actionscripting and I am stuck on loops. Is there a website that explains them a bit better and gives examples one would use for real life situations?

I am talkin about stuff like:

var i=-1
while(++i < something){
name = "item" + i;
this[name].removeMovieClip();
}
}

Loops
hey guys....loops loops loops....why aren't they synchronized!!!!!???
always empty space between the same loop.....plaese help

Help With Loops
ok i'm very confused about how loops work... so could someone break apart what these lines of script are doing and translate it into english so i can understand and recreate it.

for (var i=1, i<=2; ++1) {
*some stuff*
}

also what is "this" in actionscript

hwap462@hotmail.com

Loops
Hi!

I have made a short presentation in flash and need help. i want it to play through till it reaches frame 106 and then play on continuous loop from frame 100 to 106. how do i do this? is there an actions code i type, if so what?

thanks alot,

andy

For Loops...
I'm trying to get 2 loops to concatenate in parallel and can't do it!
to make it clearer here is my code:

conc = new Array(50, 10, -10, -50, -90);

for (j=7; j<40; j=j+7) {
for(h=0; h<5; h++){
_root["balls"+j]._x = conc[h];
....

i'm guessing that since the h loop is nested in the j loop, during every looping session for 1 element or the j loop all the elements in the h loop are activated.
i need them to loop in parallel so for each 1j there is an 1h at every looping session instead of for each 1j there are 5h.

i tried so many ways, i'm giving up soon. i'm sure it's right under my nose. but i already see double....

anybody???
thnx

For Loops?
I'm trying to build a mult-user environment, using a password system for sign in. I want to put a for loop on the sign in button, so that it will check all the usernames and passwords without me having to manually input them into my .swf. So, I'm wondering, how would I do this?

Loops
Hi All,

Could someone please tell me if there is a way to loop back to a previous line in AS?

I know about loops "while" "for" and "for_in", but they don't seem to fit the bill for what I want.

Failing this is there some way to say something must not be equal to something else, such as "value 1 must not equal "bob" ?

Thanks.

Do ... While Loops
Hey, how do you make it so that a Do...While Loop runs the loop every 1 second? LIke it will run once, then run again 1 second later, then again 1 second later...etc.

While Loops
I would like to use conditional statements to move a button in the main timeline up, over and back down. I need to be able to watch while it moves.

Based on the condition, it is also possible that I may need the button to move down, over and back up. This is also the reason that I can't just create a movie clip without AS.

While Loops?
OK...am just trying this SIMPLE bit of code form a book I have:
FLASH MX ActionScript for Designers. (great book mind you)


but for some reason..I can see no reason why this wont work:



I have a movie clip (just a tween of an arrow "easing" up..thats it)
with this code ON the clip:


Code:
onClipEvent (load) {
this._alpha = Math.random()*100;
this._x = Math.random()*550;
this._y = Math.random()*400;
}

On the root time line I have the frame action of:

Code:
k=0
i=Math.random()*20;
while (k<i) {
duplicateMovieClip("arrow_clip", "arrow_clip"+k, k)
}


All I keep getting is code in the script..etc..etc..errors ...and it never works.

Im just trying to play with the duplicate MovieClip a certain amount of times....on the stage..with some random placement and alpha......



Also..can I put an unload "this" on the last frame n the tween? So the movie will always keep 20 clips on the stage at a time..but NEW ones (so alpha and location change all the time)

This seems simple to do..what am I overlooking?

thanks

-whispers-

For Loops Using I
Hi Guys,

I have 20 buttons that I want to define actions for. Instead of defining 20 separate call back functions, I wanted to do this in a FOR loop since all of the buttons share the same action. My buttons are named "btn1_mc" through "btn20_mc". So, I created this for loop:

------BEGIN

for (i=1; i<20; i++) {
buttons_mc.btn[i+_mc].onRollOver = function() {
myColor = new Color(this);
myColor.setRGB(0xFFFF00);
_root.name_txt.text = this.btn+[i+_txt].text;
};
buttons_mc.btn[i+_mc].onRollOut = function() {
myColor.setRGB(0xFFFFFF);
_root.name_txt.text = "";
};
}


------END

But this doesn't work. I traced "i" and it is incremeting properly, but for some reason my buttons aren't responding...any idea what I'm doing wrong?? Do i need to store the button names in an array first?

Thanks,

Josiah

Loops
what is correct syntax
_root["firework"+i+"banger]="yes";
for
firework1banger="yes"

the syntax above is wrong
Thanks

Loops
When you find a loop you like there's a button that says 'add to my fk' and I clicked it and it took me to my "favorites house" page but it didnt add the loop. What do I do?

Loops :S
Ok, so i have a function that moves an MC across the stage upon a button press. I would like the button to tell a different MC to play its last 10 frames, and THEN call the function that moves the first MC across the stage.

I can get the button to do this simultaneously, but this is undesirable. How can i make it so that the function is called AFTER the second MC has finished its last 10 frames?

Ive tried various loops but to no avail, as my coding skills are somewhat limited.

Thanks in advance

Do While Loops
Hey, I am trying to have a movie clip shoot where the mouse position is when they click a button, heres my script, I havent done any action script in a long time so I can't really see whats wrong.

code: on (release) {
shootx = _xmouse;
shooty = _ymouse;
CowboyMC.play();
duplicateMovieClip(bullet,bullet01,1);
bullet01._x = CowboyMC._x;
bullet01._y = CowboyMC._y;
do {
bullet01._x = bullet01._x - 5;
bullet01._y = bullet01._y + shooty * 0.2;
} while(bullet01._x < shootx && bullet01._y < shooty)
}

Loops
Ok, I've already searched the forums in trying to figure out how to do loops. I also looked on the internet. Everywhere it says a simple animation should loop unless there's a stop. Well, I've been trying that and am really getting frustrated. All I have is a circle in frame 1 on the left of the screen, with a keyframe. Then on like frame 30 the circle is on the right. The motion tween has it the circle move across the screen but IT WON'T LOOP. I didn't specify any ActionScript and I can't find any on any of the frames. I have also tried putting a GotoAndPlay(1) at the last frame but nothing will work. It just goes through the motion tween once and that's it-- done. I've even read the 'tutorial' offered on this site, which doesn't seem to work (or I'm incompetent) in that it says to make the circle a movie clip and then change it back right away, which didn't really accomplish anything. Please help! Thanks in advance.

Loops
i've created something very simple:
a 10x10 rectangle box moving across the screen from left to right - in 10 frames using a tween.
however i want this to keep on happening throughout the site.
i know i should use some kind of loop - what sort of actionscript would i need - repeat loop?
or is there a tool in flash to do it for you?
(To save me from copying and pasting the frames ad infinitum...)
Thanks

Loops Within Loops...
Hello all... simple question...

Can I have an if loop within an if loop?

So

if (x==y){
if (a==b){
do this
}else{
do this
}
}else if (x==z){
do something else
}

Basically I have a series of if statements checking what a user types, I want to then check if a movie is loaded on level 1, if it is, unload it, if its not, write out a message saying there is no movie on that level.

Ta

Loops
i was trying to make a countdown loop.

It counts down and when it gets to a certain number it moves to the next frame. How do i do this with the actions only on the one frame?

For Loops
Alright, I'm somewhat new to AS and have been learning everything i know from these tutorials, so please bear with me when i ask my idiotic question

can someone please break down for loops for me? what they're doing, how to use them, etc? I searched the flash help pages and tried searching the tutorials here (the search engine here considers "for" to be a useless word and doesn't include it in its searches) but i couldn't find anything better than "for (init; condition; next){}".

Thanks,
Convinced He Needs Something Besides If-Thens

[HELP] Loops - Other Then For Loops
Hello everyone,

I just have a quick question. Is it possible to use a loop OTHER then the for loop?

This is what I want to accomplish. I have a dynamic text box, and a button. When you hold down the button the dynamic text box increases by 1 (number starting at 1940)

I want it to keep going until you release the button and thought to do so with a loop

If someone could please tell me how to go about doing this, it would be greatly appreciated

Thanks

For Loops
Can I make a for loop wait for an animation, such as the rolling of dice?

Copyright © 2005-08 www.BigResource.com, All rights reserved