ActionScript 3.0 :: Triggering A Tween To Happen During A For Loop?
Aug 12, 2010
If I put an if else statement in a for loop it will stop the loop till the if else statement has completed. I'm trying to run something else during my for loop. How do I do that??Here's my for loop:
ActionScript Code:
for (var i:int = 0; i < testArray.length; i++) {
chickletMc = new chicklet();
How to stop the next tween action to start until the previous tween completes playing in as3.0?and also i want to stop the tween to happen on the same object twice.Basically i have a container (movie-clip) in which there are n number of movie-clips (arranged as bricks). When i click on the container the target (brick) will disappear (made scaleX and alpha to 'o'). also i am tracking how many bricks are closed.But the problem is if i do a fast double click the tween seems to happen twice. and the count also seems to increase for the same brick.
I have a site that is fairly complex, but was using a massive amount of CPU power, even when sitting idle on a page with no animations. I went through everything with a fine toothed comb, and couldn't find the culprit.So I just started removing layers one by one, until I found the one causing the problem.
Turns out it was a layer with an animated mask. I have a large black recatangle, that I converted to a mask, and then used a shape tween on it. Once that was triggered. The CPU usage went up 65-75%. Even when the movie was stopped on a frame that that mask didn't exist on. Once it was triggered, the rest of the time you are on the site the CPU usage is through the roof. I can do to fix that. Is there some other way I should build an animated mask?
when I create a new Tween/Graphic symbol it turns into an old tween I already used (Ex: Two tweens, when trying to use the second one it reverts back to the first one). Both of them are on the same layer called "Text", also it seems to be fixed when I put the second tween on a new layer. But if I do this I will have at least a good 50 layers of text :S.
Second problem is I want my background music to loop throughout the whole video, my project has multiple scenes and I am baffled as to how to make the music play throughout.
EDIT: my project has to be 45 seconds and the music loop I'm using is about 17 seconds.
The actionscript code works fine, except for the tween, which is applied on all the sample rectangles at once. I want to fade in the rectangles (or any other dynamically created movieclips in loops) one at a time.
I have a loop in the flash file. it gives me a number of X & Y as the to & from coordinates and places a movieclip on the stage. I then have the tween class moving each clip as it is placed. the example is below:
I have created 4 movieclips and named (instance) them box1, box2, box3, box4 and shuffled them with the following code: var vector_name:Array = new Array("box1", "box2", "box3", "box4"); function shuffle(a,b):Number { var num : Number = Math.round(Math.random()*2)-1; return num; } var shuffled_vector:Array = vector_name.sort(shuffle); trace(shuffled_vector);
How can I tween the instances using fl.transitions.Tween with a loop. I tried the following but did not work.. btnPlay.addEventListener(MouseEvent.CLICK, startMotion); function startMotion(me:MouseEvent):void { btnPlay.visible = false; for(var j:int = 0; j < 4; j++) { var twSlide:Tween; [Code] ......
I have been trying to assign tween function in an array through a loop in as3.I have 20 mc on stage, the instance names are obj1, obj2 and so on.I want to assign a tween function to each of them, the function looks like this :
Actionscript Code: function startTween(e:TweenEvent = null):void {xTween = new Tween(obj1, "x", None.easeNone, obj1.x, Math.random()*20, 0.2, true);
The following Actionscript loads an XML file. Using the XML file, it loads an image - fades in the image - pans the image - and then fades out. I have then attempted to make a loop which loads the next image from the XML file and perform the same series of tweens. It would then load the next image, infinite loop. It appears that instead of loading each image one at a time, it is overlapping the mask with all images in the XML file. I then only see the last image in the XML file being tweened on the stage/mask. I do not believe that I can use a Timer to time the loading of each image. This is because the width of each image will be different so the duration of the pan from one loaded image to the next will be different. I believe that I need to use onMotionFinish in some manner after the image Fades Out in order to move to load the next image - but I can't seem to identify how to integrate that within the loop. Most likely my loop is not written correctly. [code]...
I have 10 mc's on my page which I want to load from alpha = 0 to 100, one at a time, but in a random order each time the page is loaded. I have code which uses an array to loop the mc's and I can then load the array into a tween using as2, but I don't know how to randomly create an array, then load these answers into a tween and play them one after another until the loop is complete.
I have 10 mc's on my page which I want to load from alpha = 0 to 100, one at a time, but in a random order each time the page is loaded. I have code which uses an array to loop the mc's and I can then load the array into a tween using as2, but I don't know how to randomly create an array, then load these answers into a tween and play them one after another until the loop is complete.
Basically I would like to tween a retangular 2D image on the stage, but also make it look like it is wrapping round on itself.A visual example of the effect I mean is here: [URL]Imagine the above is a rectangular shape being tweened from Right to Left, but when it reaches the left it wraps round as in the picture.Is this possible with Flash CS4 & AS3 or does it require some special add-on?
I am trying to make a movie clip fade in after several movie clips are pressed. It does not matter what order they are clicked in-Just as all of them are pressed. Does anyone know what this is called so i can find a solution?
I currently have a large picture on screen which I intend to show 1/3 at a time. Each time you click a button the picture tweens up 1/3. Basically what I want to happen is, on the 4th click, once the picture has been seen in its entirety I want it to vanish. The only piece of code I need is, how to make a new event happen on the 4th click.
Say you have a document class, and a customMenu class. If they import some of the same classes, would it be less overhead if everything was in the document class? Thus imports only happen one time?
I'm trying to make this script work in which two things should happen onRlease of a movie clip. In the script below, the "transition" plays but frame 18 doesn't..even though the path is right. I even tried frame label even that doesn't work. The script is on the clip itself.
I have some AS3 code that does two things. Only I want the 2 things to happen 10 seconds apart. The lines of code look like:
var myTween:Tween = new Tween(yellow, "x", Bounce.easeOut, startValue, finishValue, duration, true); var myTweenBlue:Tween = new Tween(blue, "x", Bounce.easeOut, startValue, finishValue, duration, true);
Right now, they happen at the same time, but I would like them to happen a few seconds apart. I have seen where I can pause the timeline, but in this case, the timeline is already stopped. these actions are triggered by clicking on a button. So Im not sure how to make it so the two actions happen a few seconds apart.
I'm making an Elder Scrolls type game and I want my enemies to hurt me after a certain time.So pretend like 5 seconds after they come on the stage they would take 5 hp off me.Then when one of the enemies die it stops until another enemy comes on the stage then it counts how long its been on the stage.This is what I have so far:
Actionscript Code: var tmr1:Timer=new Timer(2800); var tmr2:Timer=new Timer(5000);
I have a picture that is 500x500. My stage is 500x500. I have a tool bar that is on the bottom of the screen. It is in front of the picture. My onRollOver command is set so that on roll over the picture changes. Even if I am hovering over the toolbar the image still changes. I can not for the life of me figure out how to not have the onRollOver happen when the cursor is over the toolbar. Picture = pic_mc and toolbar = tb_mc I can not figure this out and I know how simple this is, but I am just at a lose. SIDENOTE: The tool bar is not a rectangle it is an irregular shape so I can't just say X,y area I figured I could use the toolbar shape to be the "block" from the image activating the onRollOver.
how to get something to happen according to the mouse's proximity to an object? like say i have a square & i want that square to get bigger the closer the mouse gets to it... how would one do that?
i am creating a flash website, i have a preloader at the start of the site. My problem is that when i view it as it would be seen on a browser the preloader doesn't appear straight away. i have an image with the preloader (site logo) and is 182kb file size and am guessing that this picture needs to load first for the next action to happen. if htis is so, other then reducing the file size is there anyway to make the preloader appear straight away.
URL...The preloader on this site seems to run through a complete animation before moving forward in the movie.I am curious if there is something to how preloaders like this work. Does each animation happen after a certain precent is loaded (in this example, when the squares turn green) or are they just animations that have nothing to do with the actual preloading?
I've been trying to use random to make something happen a certain percentage of the time. For example, for making the scientist go to frame 91 half the time and 181 the other half, I was using this code: