ActionScript 3.0 :: Two Functions Running At Same Time With Single Button Press

Jan 23, 2012

I have a problem with two functions. This is the story: the user has to press the space button on keyboard when he sees something on screen, then the "rightClick" function is called. If he presses the button when there is something else on screen that is a wrong answer (function "wrongClick" is called). The problem is that when the user presses the space button both function run at the same time.

This is the call of the wrongtClick function on frame 5
stage.addEventListener(KeyboardEvent.KEY_DOWN, wrongPress);
This is the call of the rightClick function on frame 10
stage.addEventListener(KeyboardEvent.KEY_DOWN, rightPress);

Both function are very simple:
function rightPress(event:KeyboardEvent):void {
scorenum += 1;
trace ("Right:",scorenum);
} function wrongPress(event:KeyboardEvent):void {
wrongnum += 1;
trace ("Wrong:", wrongnum);
//and plays a sound too
}

View 3 Replies


Similar Posts:


ActionScript 2.0 :: Stop A Function From Running By The Press Of A Button?

Aug 7, 2003

I want to be able to stop a function from running by the press of a button. Is there such an inbuilt function? Like "stop function(myFunction);" or something..?

View 5 Replies

ActionScript 2.0 :: Press Button Within A Certain Amount Of Time?

Jun 20, 2005

If you press a button within a certain amount of time, you are taken to lets say frame 2, if the time expires, you are taken to frame 3.I have used up all of my "i'm still a newbie at flash", so I'm just gonna tell you the truth and say that I haven't done any AS (or flash for that matter) in quite some time, so I guess I have to get busy and learning actionscript.

View 2 Replies

ActionScript 2.0 :: Play Two Songs At The Same Time If I Press The Button Twice?

Mar 5, 2002

I have it like this;

on (release) {
alexSound = new Sound(this);
alexSound.attachSound("coolsound");[code].....

But i dont want it to play two songs at the same time if i press the button twice.

View 1 Replies

ActionScript 3.0 :: Press The Button The Seccond Time The MC Doesnt Turn Visible?

Sep 15, 2011

how can i make MC visible for 20 seconds when a button is pressed i tryd to do this and this is what happend
when i first press the button it works perfectly but when i press the button the seccond time the MC doesnt turn visible can someon give me a sample how to do this?

View 3 Replies

ActionScript 2.0 :: When Press A Button Mc Starts A Countdown But Every Other Press Doesn’t Reset It?

Jan 13, 2009

How can i make it so a when you press a button it starts a countdown but every other press dosent reset it?

View 14 Replies

ActionScript 2.0 :: Single Background Animation Running Through All Scenes?

Feb 21, 2007

I currently have 6 scenes in my current movie. It's going to be an online portfolio and each page is a section of the portfolio. However, I have an animated background (400 frames long) that I want to be played throughout the entire site. Of course, when I try and do this the animation resets every time the scene changes. The best I could do so far is to have it running on every page this way but like i said, it resets every time the scene changes. Is it possible to set this background to run smoothly through the portfolio without resetting?

View 2 Replies

ActionScript 2.0 :: MX04 : Make A Dual Key Press Perform A Single Action?

Feb 1, 2010

im trying to make a game that requires you to have the spacebar and the right arrow key pressed to make the character move. However i just cant seem to link the 2 key presses together. when the keys are pressed individually it works and when theyre pressed together it works but i want the character to be inactive until both are down at the same time :/

i've tried everything that i can think of (which is kinda limited) i thought id cracked it with a 'while' statement but when i tested it flash would throw a fit and close heres the code that flash doesnt like, it looks (to me) like it should work but it clearly doesnt :P

PHP Code:

onClipEvent (load) {
_x = 0;
_y = 0;
}

[code]....

View 2 Replies

ActionScript 3.0 :: Deleting/Stopping Functions From Running?

Feb 11, 2009

In AS3, how do you delete or stop a function from running? For example in Frame 3, I have a function called createAnimation(); running, and when the user goes back to Frame 1, I want createAnimation(); to stop running, what is the best way of stopping or deleting the function?

View 4 Replies

ActionScript 2.0 :: MX > How To Make Functions Stop Running

Jul 14, 2003

how to move from one frame to another (once clips complete their actions). I had previously posted some questions regarding this matter, but I think the post got too long and confusing (at least to myself).SO I'm starting over from scratch and want to go step by step so I can understand. I have a line clip on stage that I move down the screen and center and expand it at the same time to fit the width of the stage. Now I have this code for that:

[AS]
goDownAndCenter=function()
{

[code].....

View 5 Replies

ActionScript 2.0 :: Calling Two Functions With A Single Command

Nov 17, 2008

a simple issue I guess: in my game I've 2 functions called in callback with Drag&Drop of a coin icon; usually I call just one of the two functions, but when I stand in another part of the game I need to call the other function, using the same coin icon (it's about two different payments, in a shop and in a museum).

[Code]...

View 4 Replies

IDE :: Call Multiple OnRelease Functions In A Single Function?

May 31, 2008

Is it possible to assign several onRelease Functions for multiple movieClips on a single function?

Here is my scenario... I have 10 movieClips on stage... i have a function on script which needs to be called every time any of the movieclips are clicked.. do i have to write a separate movieclip.onRelease function for each and every movieclip.

View 4 Replies

IDE :: Press Two Key At A Time?

May 20, 2009

How can I use two key at a time :

I wrote this code for single key ....

Code:
stage.addEventListener(KeyboardEvent.KEY_DOWN, moving);
function moving(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.RIGHT)

[Code].....

View 3 Replies

ActionScript 2.0 :: OnEnterFrame Inside A Class - Functions CharactercamX And CharactercamY Are Not Running Every Frame

Apr 15, 2009

I've been trying to run some functions in my class every frame and have come up with this code:

[Code]....

I get no errors, but the functions charactercamX and charactercamY are not running every frame.

View 3 Replies

ActionScript 2.0 :: Functions And Sub-functions - Button Doesn't Work OnRelease?

Jun 17, 2004

I have one function that puts text in a text field and makes a button goto a url onRelease.The code is like this:

Code:
item.onRelease = function() {
myButton.onRelease = function() {
getURL("http://google.com", "_blank");
}
talk = this.txt;
}
the only problem is that the button doesn't work onRelease. i think that it is because there are too many functions there, but at the same time,

View 5 Replies

ActionScript 3.0 :: Running 2 For Loops At The Same Time?

Sep 2, 2010

I have the following 'for' loop runningit animates squares so they fall down the page and land in rows.Once a row has landed I need to fade up an image on some of the squares. But I can't seem to run anything till the entire for loop is ended... any suggestions? I think I really need to run another routine at the same time, but how do you run 2 'for' loops at the same time?

ActionScript Code:
var testArray:Array=new Array("34","103","172","242","311","380","449","518","587","656","725","794","863");

[code].....

View 2 Replies

IDE :: Press As Past On The Mouse Before Time Runsout?

Apr 3, 2010

i made a small game. the player needs to press as past as he can on the mouse before time runsout.

well, i want to send the score of the player by post (php)

i have read alot of guids but i didn't mannaged to do thise, so i came here.

[Code]...

View 1 Replies

ActionScript 2.0 :: Calculate Time Animation Was Running?

Aug 18, 2009

I'd like to find the best way to calculate the actual time for the animation to be played. In my scenario, I have a button to start animation and button to stop it. Animation is set to run 3 second. I'd like to know how long the animation did ran after I press the stop button.

View 2 Replies

ActionScript 2.0 :: Calculate The Time Animation Was Running?

Aug 18, 2009

I'd like to find the best way to calculate the actual time for the animation to be played. In my scenario, I have a button to start animation and button to stop it. Animation is set to run 3 second. I'd like to know how long the animation did ran after I press the stop button.

View 2 Replies

IDE :: Total Running Time In Audio Skin

Aug 10, 2009

I'm using an mp3player skin, but the running time won't work (bottom of code)--it stays at "0:00" when you hit play. Everything else is working fine.[code]

View 1 Replies

ActionScript 2.0 :: Launch A Movieclip Each Time When Press A Face?

Oct 7, 2005

I have a problem with the rotating cube tutorial (link below):

[URL]

I'm trying to give an action to each face of the cube. I would like to make it a menu with 6 buttons (one per face)I want to launch a movieclip each time i press a face.

View 14 Replies

ActionScript 3.0 :: Stop Its Code From Running For A Given Time And Then To Resume?

Jan 5, 2010

Tell me is there a possibility to completely stop actionscript 3 code from running for a given time and then to resume?

View 1 Replies

ActionScript 3.0 :: Stop Code From Running For A Given Time And Then To Resume?

Jan 5, 2010

Tell me is there a possibility to completely stop actionscript 3 code from running for a given time and then to resume?

View 8 Replies

ActionScript 3.0 :: Set Variable Time For A Single Timer?

Jan 7, 2010

how to set variable time for a single timer, like I first setup this timer:

private function timer():void{
var randomTimer:Timer=new Timer(time,0);
randomTimer.addEventListener("timer", somefunction);

[Code].....

So how can I influence the time inside the timer? Do I create a global timer, remove the listener and recall the timer function? Would this work since the timer has already been declared, I a re-declare a timer?

View 1 Replies

ActionScript 3.0 :: Using Dictionary Over Object Every Single Time?

Jun 24, 2010

Any good argument as to why I shouldn't use a Dictionary over an Object every single time? I can't think of any case an Object can do the job a Dictionary can't, and it doesn't seem as the Dictionary creates that much more overhead.

View 8 Replies

Flex :: Different Country Time Into Single Page Using Flash

Apr 22, 2009

i am beginner dont know how do display all country time into a single page using action script 3 in flex . do u know any example time code refer me . i will try that code .

View 2 Replies

ActionScript 2.0 :: Display The Current Time Into A Dynamic Text Box - Seconds Not Running

Nov 10, 2009

I want to display the current time into a dynamic text box. The time comes correct but the seconds is not running... I want live seconds. what modification should i do to my following code?

[Code]....

View 3 Replies

ActionScript 1/2 :: Create A Single Large Bitmap Data At Run Time?

Feb 8, 2010

Requirement: Create single very large bitmap data which contain some 30 PNG images loaded and for each image it should have some text.  Images and text are loaded dynamically (AS2 code. Images are stored in a remote server). The bitmap data display should show 8 images at a time and corresponding text. We can see rest content by scrolling (kinetic scroll is implemented). How can I go for it?Some questions:Is there any limit for size of bitmap data ( As per link there is restriction on the height of the bitmap we can create in AS2 (max value is 2880 which is not enough for some 30 element list If we create individual bitmap data for 30 individual PNG files, we find some jerks in scroll. How can we have smooth scrolling?

View 5 Replies

Ios :: Test Flash CS5 Published SWF's Or Ipa's Without Having To Load Them Onto The IPhone Every Single Time?

Sep 12, 2011

is there a simulator or a way for Adobe Device Central to read CS5 created iOS published SWF's or ipa's for testing purposes?At the moment, I make a change in Flash CS5, publish the SWF and IPA, delete the old version from my phone, drop the new IPA in, re sync and test. This is not good for the workflow. What are the options for testing and developing?

EDIT:I am on a Windows machine (Windows 7).

View 2 Replies

String :: Adding A Single Letter At A Time To A Text Field?

Dec 26, 2011

Given the following example SWF: Sample Notice how with the words "enthusiast" at the end of the first line and "write" at the end of the second line, that they start to type out on the first line but after a few letters they are bumped.

I understand this is the correct behavior, but is there a way for "enthusiast" to begin being typed on the second line, and "write" on the third line instead of being bumped during the typing?

Currently I am thinking of doing a search ahead mechanism, so it finds the next word in whole, then makes that the active word to print, temporarily print it, see if it increases the numlines, and if it does insert a line break and continue writing. But it seems fiddly.

[Code]...

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved