AS3 :: Flash - Use An Timer To Execute And Loop Movie Clips Of Different Length?
May 13, 2011
How would I go about using a timer to initiate multiple movie clips at once, and then loop them if they are all different lengths so that they restart in sync once more?
For example, say at t=0, 3 movie clips are started. Movie clip 1 is 3 seconds long. Movie clip 2 is 6 seconds long. Movie clip 3 is 10 seconds long. Movie clip 1 would end before movie clip 2 and 3, but I don't want it to restart until the others are both finished.
Furthermore, is it possible to set a countdown so that the the movie clips are initiated not after a duration, but after a specific time? For example, instead of having a timer countdown from 10 seconds and then playing, it instead countdowns until say 12:00 PM and then plays the movie clip.
View 2 Replies
Similar Posts:
Jan 23, 2010
I have an mp3 playing. What I would like is to have a movieclip that is located in the library appear, complete it's animation then get removed. The movie clip must complete this proccess 4 times, randomly during the length of the song but never at the same time and not in the last 5 seconds of the song. BTW I can't do this manually by just firing it off a random amount of times because this code will be used with lots of different mp3's, so I need to use the dynamic data I get by retrieving the song length.
I have the code working to retrieve the length of the song, and I have a variable that stores the length minus 5 seconds from the end, so I bascially have the length of time I wish to work with. My problem is making the movie clips appear 4 times randomly throughout that length of time. The code is below (what I have so far), the movieclip is stored in the library as circle_mc.
The timer I'm using at the beginning of the code (to retrieve the length of the song) is set to run after 2 seconds this is because there is a delay in the music starting and if it did it instantly the number retrieved obviously would be 0, so I delay it by 2 secs till I know the song is playing. At the moment I'm just trying to get it to fire twice, at the moment it fires once or not at all
[Code]....
View 1 Replies
Apr 24, 2009
I am trying to loop through an array of 5 movie clips using a timer. Below is the script that plays the first movie clip, then plays the next clip over and over.
var timer:Timer = new Timer(2000);
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.start();
[Code].....
View 3 Replies
Jun 5, 2009
I'm creating a game where certain movie clips execute a motion tween when a button is clicked, and stay still when not clicked. I know that this sequence would probably use coding such as if...button pressed execute movie clip/else...
But I'm not sure how to code it. Also is it better to have the motion tweens as a nested animation in each movie clip, or should I just create the tweens on the main stage. And if I make them nexted animations how do you say in a function to play the nested animation?
View 2 Replies
Nov 29, 2011
I have a ActionScript 3.0 project and I have a timer that is running on 1000 millisecond intervals. I would like to delay this timer for 1500 milliseconds perform an action and start the timer again after the delay. I thought I could do this easily, but I'm having trouble, would it be better to stop the timer and perform the action and then listen for the action to be completed to start the timer again?
View 1 Replies
Nov 13, 2009
I have five movie clips in my library. I want to load each to the stage with a fade in and fade out. I thought I could just call them into an array, but I can't find how to reference them. I have other clips in the library too so I can't just grab them all.
View 2 Replies
Dec 7, 2010
This is sort of a multi-layered question- I have a movie clip that I sectioned off in quadrants:The red dot is the player, the stage is the size of one square. My goal is to, when the player moves to either of the 4 edges, the next section of the quadrant comes up (meaning if the player moves to the right edge, the section that borders the right edge will slide on screen, and the old section will slide off screen).I was wondering if there was a way to hitTest if an object is touching any part of the edges? Is the hitTestPoint method something I should look into? What I have so far is an object off screen (black rectangle), that when the player touches the quadrants slide like I want them to (at least I'm trying to make that work).Here is my code. I know some of it's wrong and/or I'm missing something.
if(leftKeyIsDown && player_mc.x > -15)
//-15 is half the size of the temporary player_mc
{
[code]......
View 18 Replies
Apr 4, 2007
Flash 8 duplicating movie clips and setting 3 nodes from XML. I am trying to read in an xml with 3 parameters; 2 links and one text field for a caption. What am I doing wrong this time?
[Code]...
I am trying to have "bMC" load into and repeater for however many XML props there are. within "bMC" are two MC's that on click would open window or grab file and One Text field which would load in caption. For some reason the "bMC" isnt even loading at all. Attached is the .Fla
View 2 Replies
Mar 23, 2011
I'm re-creating a cctv style project, and I am trying to play flv's at different times using the timerEvent, as the flv's are embedded within one keyframe i need to use as3..
View 2 Replies
Feb 9, 2005
I have a movie clip that I want to play every 30-45 seconds. Basically it will start, run through the movie clip and stop and wait 30-45 seconds before it starts again.how to write a script to do this. The name of the movie clip is: lights_mc
View 7 Replies
Jun 20, 2010
Is it possible to put the following into a loop?
ActionScript Code:
var box1:Box = new Box();
var box2:Box = new Box();
[code].....
View 1 Replies
Feb 5, 2009
I've got a MovieClip with a linkage name of trackInfo. I'm trying to get XML information in a for loop to create and populate instances of the MovieClip for the length of the XML file.Here's what I have so far:
Code:
var myXML:XML;
var myURL:URLRequest = new URLRequest("tracks.xml");
[code].....
View 14 Replies
Apr 28, 2009
I have a function in which all items of an array are processed. in part one of the code I have a certain function called immedietly for ever item, but after that, a function is made within this function, to be added to a timer. the function will be executed 500 milliseconds later. this works fine most of the time, but sometimes the function with 500 mill delay doesn't get executed at all, while the first part does.
Can the cause of this problem maybe be, that there is a limit to the amount of Timers, or nested functions?
This is the function:
PHP Code:
if (ballsWillBeMatchedOut.length >0)
{
//part one:
for (i = 0,num = ballsWillBeMatchedOut.length;i<num;i++)
[Code].....
View 2 Replies
Nov 15, 2009
since my Timer runs every 5 seconds I have to initially execute the function normally. This creates a problem though since if the user has the mouse over the stage, it stops the timer.It cannot do this because it takes 5 seconds before the Timer first runs the function
View 2 Replies
Sep 4, 2009
All I am trying to do is display a movieclip (just a small rectangle) and have it repeat along the x-axis, adding one to it's instance name each time. It seems to work according to the trace statements but it only displays the last movieclip.
Here is the code:
var transition:mcTransition = new mcTransition();
for(var i:int = 1; i < 10; i++){ trace(i); addChild(transition); transition.x = i * 10; transition.name = "transition_mc" + i; trace(transition.name); trace(transition.x);}
View 2 Replies
Dec 9, 2009
I know this is probably really simple but it is frustrating me. All I am trying to do is display a movieclip (just a small rectangle) and have it repeat along the x-axis, adding one to it's instance name each time. It seems to work according to the trace statements but it only displays the last movieclip.
Here is the code:
var transition:mcTransition = new mcTransition();
for(var i:int = 1; i < 10; i++){ trace(i); addChild(transition); transition.x = i * 10; transition.name = "transition_mc" + i; trace(transition.name); trace(transition.x);}
View 1 Replies
Mar 20, 2011
I'm trying to use a loop to add some movie clips to the stage, but I want to give each one a different name so I can refer to them in another function, but I don't know how that is done. I'm trying to learn how to do this so I can create an Isometric game. Here's my code....
[Code]...
View 3 Replies
Sep 10, 2010
So basically, this is how I'm adding one movie clip to the stage. var balloon_mc1 = new balloon(); this.addChild(balloon_mc1); How do I do this for 100 of these movie clips, without typing var balloon_mc1 = new balloon(); this.addChild(balloon_mc1);
var balloon_mc2 = new balloon(); this.addChild(balloon_mc2);
var balloon_mc3 = new balloon(); this.addChild(balloon_mc3);
View 3 Replies
Jul 16, 2003
I want to have 4 to n movie clips on my stage and to be be able perform monotonousperations on all of them in a for loop like so.
for(i=0;i<numClips;i++)
{
if(this.hitTest("clip"+i))
[code]......
View 3 Replies
Feb 24, 2004
I'm trying to make a portfolio page where each of my thumbnails loads with the 'fading grid' effect. I've made all the thumbnails movie clips with the appropriate script, and they all work fine. I've also set them to be exported for actionscript, each with a number as their name, i.e. "1" "2" and so on.
I was then planning on using the following bit of code to load these movies into my portfolio clip, to save me having to do it at author-time.
[Code]....
But for some reason, instead of loading two movies, each one 10 to the right of the previous movie, it just loads them on top of each other. Is it something to do with the stage not updating?
View 3 Replies
Nov 13, 2009
I'm pretty sure this is probably a really stupid question. I have about four separate movieclips in my main time line. Each movieclip has its own animation and its own stop function. When I preview it it works fine.However when I try and add actionscript to my buttons everything else starts to loop. What am I doing wrong and how can I get around this?
I just tried putting the buttons in a separate movieclip and doing the actionscript in that instead of the main timeline but it still didn't work.
View 4 Replies
Mar 21, 2009
im trying to run a loop and assign all my new movie clipswith different names. i have tried .name and ._name they dont seemto be working..
for (var i = 1; i<=5; i++) {
imageName = new ImageMovie();
this.addChild(imageName);
[code].....
View 1 Replies
Sep 10, 2010
So basically, this is how I'm adding one movie clip to the stage.
[Code]....
View 4 Replies
Oct 5, 2010
k say i wanted to create a bunch of movieclips in a for loop but wanted to name them something different each time, how would i dynamically name them?
View 1 Replies
Feb 4, 2011
I have an array with many values pushed into it (happen to be names of objects). I am using a for loop to check all of the objects (by index number) for collisions, etc. Periodically, depending on a condition, I want to remove the currently checked object's name from the array list. I noticed that there is a problem if I immediately splice the checked name from the list. Namely, the list gets shorter, which is what I want, but not until I'm done checking all objects. Is it a good idea to solve the issue by incrementing i-- after the splice? I do this so that the object that used to be next in the list doesn't get skipped.It seems to work very well but I want to know if this is a lame/problematic solution and if there are any better ways of dealing with it
for (i=0;i<myarray.length;i++){
var ob=myarray[i]
//any old condition
[code].....
View 7 Replies
May 6, 2010
Why WebCam snapshots doesn't execute by timer?
ActionScript Code:
capture_mc.buttonMode = true;
capture_mc.addEventListener(MouseEvent.CLICK,captureImage);
[Code].....
this part of code works well without errors but when I click button I have a picture bu timer It doesn't.
View 1 Replies
Nov 3, 2010
All i really want to do is be able to affect multiple movieclips at once with event listeners and greensock tweens.
The first snag I hit was that I couldn't create references to movie clips using the old [] Associative array referencing method. Maybe I still can with AS3, but I couldn't get it to work...
So I found another technique using getChildByName that returns a reference to a movie clips and allows me to store that reference in a variable.
However, the movie clip I'm trying to affect with an event listener resides inside of another movie clips, so to build the address (aka, root.mc1.m2.mc3) to the mc I want to get to is proving to be difficult. (I'm very new to AS3...)
I thought the trace(target1_mc.target2_mc.name); at the bottom of the following code would output the name of target2_mc but it doesn't.[code]...
View 2 Replies
Dec 9, 2005
I've been staring at the screen too long and I'm sure the answer is simple but this has been bugging me for a bit now. I've created a grid with over 200 movie clips dynamically using a for loop. I was wondering if there was a way to assign rollovers and such to each new clip using the same loop.
I've been poking around with it a bit but can't seem to get it working and sure don't want to write over 200 rollover functions so any help would be great.
View 7 Replies
Nov 3, 2010
All i really want to do is be able to affect multiple movieclips at once with event listeners and greensock tweens.The first snag I hit was that I couldn't create references to movie clips using the old [] Associative array referencing method. Maybe I still can with AS3, but I couldn't get it to work..So I found another technique using getChildByName that returns a reference to a movie clips and allows me to store that reference in a variable.However, the movie clip I'm trying to affect with an event listener resides inside of another movie clips, so to build the address (aka, root.mc1.m2.mc3) to the mc I want to get to is proving to be difficult. (I'm very new to AS3...)I thought the trace(target1_mc.target2_mc.name); at the bottom of the following code would output the name of target2_mc but it doesn't...[code]
View 2 Replies
Sep 1, 2010
I have a simple array of movie clips ("box1" "box6") that I have created on the stage. I then have a simple onRollOver function that is iterated for each of these movie clips, as shown below. As it is now it's working fine, but I can forsee two potential problems for when I use larger arrays and apply this technique to my real working files.
If I were to have many more movie clips, the first line of code would be much longer as it lists each movie clip instance name. Is there a way to use, for example, a for loop to include all these movie clips in the array without having to type out all their names? As you can see here, I have used a simple numerically-incremented naming process. I think the problem may be that I am using movie clips with instance names assigned on the stage and not created through ActionScript.The function as I have created it makes all the movie clips gotoAndStop(1) and then the one that has been rolled over goes to frame 2. Is there a way of making all the movie clips in the array except the one that has been rolled over gotoAndStop(1), ie. is it possible to exclude the rolled-over movie clip from the first part of the function? Here it works just fine as it is, but I'm thinking that maybe when I start using more complex functions with tweens etc it may cause problems. Or not?
[Code]...
View 5 Replies