ActionScript 2.0 :: Delaying Execution Of Multiple Functions
Apr 3, 2010I have 3 functions that I need to execute delayed by x seconds. For instance on my first frame I have:
[Code]...
I have 3 functions that I need to execute delayed by x seconds. For instance on my first frame I have:
[Code]...
I have a chicken walking on the screen. The legs are separate movieclips nested. After a while I had the chicken walking rightwards, with hittest(there must be a better way) at the end of the stage he turned to the left and then again to the right after hitting the left barrier. I also got his right leg going up and down for a smoother walk. I did this with Tweener. But then the problems started. I didn't get the left leg also to move up and down.
The chicken got more and more crazy. And now he starts walking backwarsds instead of to the right, as I intended to, after publishing. Who has a better idea of letting this chicken walk or a good hint for functions to be executed when I want? Tweener is good, but maybe not for this? The chicken doesn't have to respond to a mouse action (maybe later), this is the code, for which the walking to the left apparently seems to be executed first....
ActionScript Code:
function walking() {
Tweener.addTween (kip, {x:kip.x+60,
time:1,
transition:"easeInOutQuint",
onComplete:walkingright});
//onStart:walkingrightstart});
The collission with hittest is also not really smooth but I can't think of something else. I am at a stage where I can't develop 3D moving.
My AS 3 program has multiple buttons. Users can select one and then immediately select another and this causes 2 threads that collide. Once one button is executing, I want the other buttons to ignore clicks.
The problems are twofold: 1) the first time the 2nd button attempts to execute (by checking lock), when it returns (from checking lock) and attempts to pick up processing where it left off, it seems to forget where it was and does not utlimately complete its task(s); possibly variables have been altered, it is difficult to say. That is, AS 3 is unable to successfully pickup where it left off on the first button. the second problem is that AS 3 incorrectly returns to button 2 after the lock condition is cleared. It persists and will execute that button.
I have a loop and in it i am attaching a movie clip (basiccly its just a row with data). The movieclip has a alpha fade in it. Now I want to delay each attachmovie function so that the movies are attached one by one rather then trow them all on the screen at once. (plus it looks better with the alpha fade).
I tried the setInterval but it wont work (ex.:Interval is 1 sec, and if im going to attach 6 MC, flash wait 6 * 1 sec, then show them all)
And is it possible to attach a movieclip inside a othermovieclip thats not on the same frame (the other MC is on frame 10)?
I'm trying to create something that you could use in a game that shows you the points adding to your total score little by little (instead of it adding it all at once). I've managed to make a timer delay, but it will still only update once and I don't know what to do.
Code:
var pointBuffer:Number = 500;
var totalPoints:Number = 1000;
[code]....
I have multiple buttons with the following script applied which waits a second while a transition animation plays then loads a new image into the container... There seems to be a problem with having this code applied to multiple buttons unless I make the function and interval identifiers unique (i.e. transitiondelay1/waitFunction1,transitiondelay2/waitFunction2, etc.). I don't really want to have to do this to each button.[code]
View 1 RepliesI am building a Flash site with a boombox animation. I have the below code I am using. I am using just two frames. First frame, is where I put the code in the actions layer, boombox is still. In the second frame, I placed my movie clips on layers (woofers vibrating & tape deck spins). No code in second frame. So, if you hit the play, previous or forward button a song goes on and the animation start. If you press the pause button, animations stop with music. I have created 2 functions per button.
2 questions: 1 - Is this the best way to do it? If I press the buttons quickly, sometimes a song gets stuck and I can't stop, forward, etc. I was wondering if this was the code?
2 - I am tweening in my pages using AS3 - not timeline. I have a music and video page (each a movieclip). Is there a way that once I tween in the new movie clip (non-music of vid page) that the music or video can shut off?
[Code]...
I have used the loader script to load an external swf into current project. I have added a button to unload the external file when wanted, and was wondering if you could have multiple functions for that button, so that when you click it to unload it works as a 'home' button as well, and takes the user back to the mainpage again?Might be wise to mention that im kinda new to adobe flash and as3, and not sure if the way i have used to load the external swf was the easiest. Seems like a few have had some issues with this subject before me as well.
View 8 RepliesHow would I manage to enable a button to perform several operations? I want a button to do the following.
I want it to change colour etc, when it is hovered over, I also want it to activate anther flash file on the page via local connection on release. How do I allow the button to set up different actions? Do I need to make 2 separate invisible buttons? And have action script applied to both of them for the 2 commands? How for example would I be able to extend this so that I can have the button doing several things? Say:
1) On rollover it changes colour
2) On rollover it activates a flash mc on the page
3) On Click it changes colour
4) On release it takes the user to another page
how to make button do multiple things at the same time. i.e when button is pressed it animates object1 and object2 i have a buttons that opens a sliding door (code is:
on (release) {
control.gotoAndStop(2);
}
so it opens a door where sound control is and i want for the same button at the same time to open lets say another door somewhere in the same stage with a music tracks in ther
I'm trying to fiqure out a way to have multiple SetInterval functions. what I'm trying to do is have text highlight a sentence using the setinterval function than after the number of chars needed are highlighted I want to be able to clear the interval and then start with the next sentence through another setInterval.
The program I'm trying to write is somewhat of a text to speech. I have a audio clip and a static text box. the audio is supposed to sync with the highlight of the text. the only way i could fiqure to generate the sync with a highlight was through setSelection as a loop.
Code:
var i:Number = 0;
var my_snap:TextSnapshot = test.getTextSnapshot();
var count:Number = my_snap.getCount()
my_snap.setSelectColor(0xffff00);
[code]....
I have been searching the internet for help on how to delay code within a single function, but every solution I have found so far relies on creating event listeners for a timer and then running commands from the event handler functions.I am writing a 'console' type interface where the user types in a string which is, upon pressing enter, processed in one function and then sent to a final function to display the result.[code]I want to somehow insert a pause between each call of that last function, updateDisplay.
View 1 RepliesI have a situation that is driving me nutsthe site in question lives hereI have that 16 sec tweenLite intro fading up the title, then down, then all the elements of the stage fade in.which is fine and looks great.BUT the video that plays after the intro will sometimes play before intro is done which is not great.I have done the code all in the timeline as I am not class savvy is there any way that I can pause the video instance or have the playhead pause until the intro is over.
View 0 Repliesi was wondering if you can delay whats inside a text box... for example, when an action is made, the text box will show "action done". kinda like a status bar, now what i wud wanna do is for the x number of seconds i wud want to set it back to blank text box again...
View 7 RepliesI'm making an image gallery that has an MC as a background that resizes itself due to the size of the image. How can I use the loadMovie function when the button is pressed it will resize the background to the size THEN display the loaderMC that will load the image.How can I achieve this effect? I'm wanting to use the reusable MC (from Kirupa tutorials) or something that will load the image and show a status bar for the loading.
View 2 Repliesi have 5 moviecip in the stage and i am scaling them to 100% i would like to delay each one so let say first one animate when reach 50% the next movieclip start growing an so on ...
[CODE]....
i was wondering if you can delay whats inside a text box... for example, when an action is made, the text box will show "action done". kinda like a status bar, now what i wud wanna do is for the x number of seconds i wud want to set it back to blank text box again... is there any way to do that?
View 7 RepliesIs it not possible to call more than one function at a time?, this is my problem:-
btn.onRelease = function()
{
blah();
something();
jump();
}
When I run something like the one above, jump is executed but everything else is ignored, would really like to run all functions at the same time.
Most flash games and interactive animations that use keyboard events are made to respond in different ways to different keys.I am working on games for toddlers, who basically just bang on the keyboard indiscriminately. The trouble I'm having is setting up keyboard eventlisteners (key_up) that each perform different function.We're talking games like: when key pressed, ducky dances; when key pressed, doggy dances; when key is pressed, ducky and doggy go to sleep. I've attempted removing the listener before adding the next one:
stage.addEventListener(KeyboardEvent.KEY_UP, doSomething);
function doSomething(evt:KeyboardEvent):void
{make it do something;
[code]....
I really need a Timer that shoots multiple functions. The Timer Class just handles one function and therefore is not good enough for my project. The Timer should work something like this:
After 1 seconds fire functionOne
After 4 seconds fire functionTwo
...and so on...
Time is really crucial in my project (down to milliseconds) so I really can't use the Timer Class and fire "new" Timers all the time because Flash needs some milliseconds to process all the code and in the end it sums up to kind of a lot of time.
can you make a button have multiple functions? as in if i click a button one and imahe will pop up and then click that same button and another different image will pop up??
View 1 RepliesI'm using the below code to have a button that adds a MC to the stage. The problem is that I have over a dozen of these buttons and I'd rather not have to write out the event listener and function for every single button. Is there a way to use a single function for all the buttons and just change what MC is added based on which button is clicked? So if the user clicks on the draw5 button the function adds the deck5 MC to the stage?[code]
View 7 RepliesAs I've been working with AS I've developed a collection of utility functions. For example:
$ cat utils/curried.as
package utils {
public function curried(f:Function, ...boundArgs):Function {
[Code]....
And I've found that, some times, I want to keep more than one public function in each file... But ActionScript restricts me to one public definition per file, if that file defines its self as being part of a package.
So, without creating a class with static methods, how could I get more than one public function in a single .as file?
I was thinking can you call multiple functions at one time Like instead of
[Code]....
I have been trying to figure out this by myself for a while and needless to say, I have been completely unsuccessful. I have various a loop that creates multiple movie clips called: movie1, movie2, movie3, movie4... (you get the idea...) i want to assign roll over,roll out, press functions to all of theme.g. when you press on one movie, it highlights it.but I am trying to find a summarized way over writing each one out:
movie1.onRollOver=function(){
something happens
}
someonne once told me to use chartAt to do this, to reference different mcs, but I cant figure out how to do it.
Sorry if the subject doesn't make much sense but I basically want to perform several if the statement when on movie clip is clicked. an example of an onRelease trigger that activates two if then statement that change the frames of 2 movie clips.
View 11 RepliesI�m trying to use Listeners to capture the MouseUp event based on Helen Triolo�s sample at [URL]I reused her code and loaded the listener�s array (with MC names that will listen to the MU event) from a textfile.My problem is that I don�t have these MCs on the _root. They�re located deep in the MC hierarchy, this way: MCComponent-->MC1-->MC2-->MCs I want to address for listening (I have about 250 MCs in this level of depth which I want to to address for listening)So, when defining the MouseUp function for each MC to respond to, I couldn�t address the MCs. I tried in different ways without any result.
This is the code:
// set up responders for each listener
// listeners is the Array with MC names which I loaded from
// the textfile
for (var i in listeners) {
[code].....
Is there any way of making this work? Is there something missing in this code ? Note: I cannot put these MCs on the root because of other functionalities that they need to accomplish...By the way..., what about RollOver and RollOut ? Can they be captured too ? I�ve read about capturing MouseUp, Move and Down but not Rollovers...
For the past half-year I've been coding like this:
ActionScript Code:
_root.menu_mc.link1.onRollOver = function () {
_root.menu_mc.link1.text.htmlText = "<FONT COLOR='#000000'>" + "Cool" + "</FONT>";
_root.menu_mc.link1.text.thickness = 100;
[Code].....
I know and I've seen some more efficent code such as, making loops and assigning variables.
get started by making the above code more efficient? I've attached the source file.
In C++/Java you can do this to import a library of functions to your current file.
Code:
#include <someFuncitons.h>
Is there a similar command in Actionscript? I want to use some commonly used functions over multiple SWF files and don't want to copy and paste all of them into each file.
I have a rather general question regarding OOP. How do constructor functions execute with multiple class extensions? I'm making an orbital physics simulation, and every spatial body is of the class SpaceObject, which extends Sprite. Then, I have all earth-type planets be of the class Earth, which extends SpaceObject. There are certain parameters that I'd like to set for every single SpaceObject (like position and size) in the constructor function, and certain parameters (like density and mass) that I'd like to set in the constructor of class Earth.But from the main timeline, when I create an instance of class Earth, I can only enter the parameters of the Earth constructor, ie
Code:
var planet1:Earth = new Earth(density, mass)
Or I can create an instance of SpaceObject:
[code]......