ActionScript 1/2 :: Call The Function Gets Repeated As Long As The Key Is Pressed And Only Require It To Run Once
May 13, 2009
I am creating a driving game using the following method to drive the car forward: if (Key.isDown(Key.UP)) {speed += 1;} I also want to call a function when the key is pressed athough if I add a function call the function gets repeated as long as the key is pressed and I only require it to run once?
In the following code I am trying to call the function pressMc when movieclip myMC_mc is pressed and the apply the drag action to it. However the drag action is being applied to the whole of level0 and therefore all of the moviclips.I am not sure why. Am using the this key word as I would expect this to be identified as myMC_mc when the myMC_mc.onPress is evoked.I want to write this as a function because I want to apply this drag action to lots of different movieclips
function pressMc (){ delete this.oldX; delete this.oldY;[code]....
Let's say I have a Custom Event Class, and it has several Event types stored in static Constant:
[Code]...
Is there an easy way to validate that the type passed to the Constructor is one of the Static Constants of the Class, without having to check it against each value?
Any simple way of measuring how long a button has been pressed for - had a look at gettimer but this seems to be an odd way of doing things - basically I want to say onclick start timing - offclick end timing var time = time button was pressed!
I'm an interior architect at a small architecture firm and I have been tasked with updating the firms website. I have no prior experience with flash, but have been able to learn enough to update all expcept for the portfolio section. For some reason, when I add three additional frames to the portfolio gallery timeline, it repeats the previous three frames before playing the new three. This happens only when I publish the file, when I run the timeline and view it on the stage everything appears fine.
Right now, I have a gallery with many different thumbnails each individual movie clip symbols and not button symbols and each movie clip has a rollover and rollout function assigned to them which are all basically the same for each thumbnail.
Following is an example from a small section of the gallery thumbnails.
The above shows two groups of thumbnails grouped into individual movie clips (web01, web02, web03) each movie clip containing 3 thumbnails (btn04, sub04_1, sub04_2). I had done it this way for grouping and ease of animation.
I was wondering if it was possible to create just one function which executes the rollover and rollout functions so the script window would not be filled with so much repeated script.
I have a function which makes a call to the server to load some financial data. This data is then displayed in a grid. In order to keep displaying the latest data I keep making this server call (every 30 secs). I'm using a Timer object to do this. The problem I have is that I have to wait 30 secs when the application starts for financial data to be displayed, what I'd like to happen is that the load data call is made, then start the update timer. Is there a way to set this up or shall I use to data load calls, one to get the initial data, then one to get the updates, which is made every 30 secs?
I am trying to compare the performance of several different algorithms. So created several functions each of them implementing different approach of solving the same task.What was thinking to do is to create 2 Date objects before and after the function runs, and to compare them afterwords.
I'am making a advanced mp3 player arund this tutorial: [URL] and i want the users of the player to see how long they have listen or how long time back of the song. i have the AS i what to use but i cant connect them. becuase the tutorial i used does not make a sound objekt (MUSIC)
How I should format a long integer into string format with commas? I don't know if there's a built-in func for this, but I haven't found it. raw int: 2000000 parsed string: 2,000,000
I'm trying to play a 10 minute long video (h264/mp4) which is 39MB in size, after I call stream.play(fileURL) it doesn't start playback until its loaded around 12-16MB of the file (many many seconds later), I finally get onMetaData at this point too. Why doesn't it begin playback right away, or at least w/in a couple seconds? What can cause this bloated lead in time?
I get the alert but I can't get the lightbox window to display. When my as code makes the ExternalInterface call I get what looks like a page refresh and a blank browser window.
I have an enterFrame action that I use on a graphic:
[Code]....
Because I want to use the above code more than a few times, I tried to make it a function.
[Code]....
But for some reason the function call does not work when I call it via an action on a graphic where initially the code worked when it was explicitly written and not called as a function.
I need to get a javascript var in my Flash application. I like to be able to just set a variable in the javascript (client constraints) rather than define a function.
Can this be done? I am trying to use the ExternalInterface.call()
have a node that has an asfunction embedded - won't work. if I change the a href to a web page- it works fine. If I try to call a custom function it doesn't call it at all.
What I have is a series of buttons created via attachmovie based on XML nodes. I want to make sure all buttons are all clicked. What I have below is the onRelease of the button and I need to put my checkDone function in there because of the XML onLoad function. What I am struggling with is how to check if each has been clicked. Typically I would just do like but1==true but that does not seem to work.
_root["but"+b].onRelease = function() { function checkDone(whichbut) { done = true;
I have a function with the name "result". It's two textfields where you can input some data. I have an addEventListener with a mouse Click to that function. So when I click on my button It starts the function. But I want to call the same function when you press the enter key. So the result will be the same no matter if you click on the button or just press the enter key. This is what I have tried but It doesn't work. I guess I should write my function name "result" somewhere.
this.stage.addEventListener(KeyboardEvent.KEY_DOWN, enterfunc); function enterfunc(event : KeyboardEvent) : void{ if (event.keyCode == Keyboard.ENTER){ submit(); }}
I have a character where if I press left/right/up/down he plays the associated animation, however, if I hold left, and then tap another key (whilst still holding the left key) the animation stops, even though the left key is still being pressed.
how to create this kind of fullscreen function when button is pressed http:[url].... . i dont know what kind of method used in this site.., if it uses javascript or just actionscript.
I have one function that runs when a certain button is pressed. However, I want this function to also run when enter is pressed. I know that I can make a function to do this alone, but is there any way that I can make the function that I already have made (that is set to run when the button is pressed) to run also when enter is pressed?
I have a very basic question. I have a custom class called caurina. I've imported the class and it works great. What i did is use that as a function called slide().
What I would like to do is make that function play when a button is pressed. I can't seem to find out how to do this anywhere. I am using as3.
Summary: When btn is pressed go play function slide()