ActionScript 1/2 :: Repeating Functions While Key Pressed?
Jun 8, 2009
I'm just starting to learn to make my own functions and was trying to make a walk sequence. My original program used an elaborate series of counters and onEnterframe, but I want to take a different route (basically starting from scratch) because my walk sequences always turned the avatars into picasso paintings when two or more keys were pressed simultaneously. I'm more familiar now with set and clear timeout, but what do I do if I want a specific sequence to count up, then down, or rotate back and forth, like the pendulum of a clock? starting with a basic function like function walk(bodypart){bodypart._rotation += 45;}. if (keyUsed == 68){walk(square_mc);} what do I have to change so the square rotates back and forth +/- 45 degrees while depressed?
View 1 Replies
Similar Posts:
Nov 29, 2011
I have sound attached to the button, and it's played when the button is pressed. How to do that after pressing button, sound is played continuously? Without action script.
View 12 Replies
Feb 9, 2011
How can I keep repeating my functions below endlessly? I am Using the enterframe and timer class.I want my object to keep going across the stage over and over.Do I need a for loop?[code]...
View 2 Replies
Mar 15, 2009
if myVariable is a number variable and myFunction is a function, how do I use AS3 to repeat myFunction myVariable number of times?
View 2 Replies
Oct 21, 2009
I'm trying to repeat a function that basically will attachmovie on a "tileset", an image depending on the parameter. It's called AddID(i), and currently there's only 2 valid options, 0 and 1, images showing, X and O. There's a Button, and theres an array and a function that shows an image of the tile depending on its ID value loaded from the array.
My problem is: Everything works just great as if you repeat the function by clicking again, but... When repeating the function by code, all the tiles will have the Image of the last tile added.
[Code]...
View 4 Replies
Feb 21, 2006
what's the best way to combine these onrelease functions here so i dont have to repeat the same lines of code?
[Code]...
View 9 Replies
Feb 25, 2012
[Code].....
Even though I pressed only one button. The main menu button. PS: The faces are Colon and a P.
View 9 Replies
Nov 16, 2004
I have a function on root:
_root.fadeBox_mc.onEnterFrame = function (){
if (fade){
this.nextFrame();[code]....
This causes a mc to fade in and out on rollover/rollout. But what I wanna make is a box that fades in when pressed on the button and fade out when pressed for the second time. But if I say
on (press){
_root.fade = true;
}
the mc fades in, but I cant do another on (press) to fade out. Is this too confusing?
View 2 Replies
Dec 6, 2010
I am struggling a bit with keys on the keyboards controlling a movieclip to happen.Ive got a person moving when pressing right and left, and a movieclip with three frames: First frame is a movieclip with the person standing still, looking bored. The second frame is the person moving right, and the third frame is the person moving left.This is the code that Ive inserted into the persons actions on scene1:
if (Key.isDown(Key.RIGHT)) {_x += speed;this.gotoAndStop(2);_xscale = +scale;}
if (Key.isDown(Key.LEFT)) {_x -= speed;this.gotoAndStop(3);_xscale = -scale;}
this code works alright accept that when the keys are not pressed it doesnt stand still, the legs are still moving, so I tried to include this code aswell:
if (!Key.isDown(KEY.RIGHT)) [code]....this makes the person standing still when not pressed but not moving the legs when turning right and left.
View 3 Replies
Oct 6, 2011
I have a series of calculations i'm doing over a bunch of objects stored in a array. Each function is pretty CPU demanding but if you only run one function, it just works fine.
[Code]...
View 2 Replies
Jun 6, 2010
I've got a project thats getting a bit big, so Im taking the actionscript out into separate as files. I want all the basic functions to be in BasicFunctions.as and the make a library for more specific functions. I find that a lot of people use the import statement but I cant get that to work with a simple Hello World trace, yet the include statement works fine (see attached). I understand that import/include work differently, but which is the better method? If import, then is that heavier to work with. Any rate, what's the best way to organise code when it gets to the 1000+ lines?
[Code]....
View 9 Replies
Nov 4, 2009
I'm trying to find a way to have global functions in my as project, similar to how flash does with stuff like the util functions (describeType()...), where you can just call the function wherever you need it. For example:
[Code]...
So when I call Test(), it prints out "hello world" fine. My problem comes in that I can't change the name of the Test function, and I can't add any other functions without compiler errors. Is it possible to have a load of global functions in one file, or do I have to split them up into separate files like in the example? Also, I know that I can make a Global class and call static functions like Code: Global.doSomething() but I'd like to know if there's a way to do it as flash does it (describeType(), getDefinitionByName(), etc), or rather, how does flash do it?
View 9 Replies
Nov 25, 2010
Is it not possible to call other functions from generic mouse event functions?
Code:
_root.myButton.onPress = function(){
hide();
[code]......
View 6 Replies
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
Dec 2, 2004
in this example why the values of (12) and (21,39) are lost at the geo and geo1 functions
[code]...
View 11 Replies
Oct 25, 2011
Im adding lot of simple functions to prototypes of top level objects ( Object , Array , String ...) and have 2 questions :
Is possible to add functions to top level's classes in compile-time ?
If not , is there a way to allow this functions to compile ? I dont like to turn off strict mode
ex:
string.removeWhiteSpace();
string.sliceStr("." , "end");
textField.scrollBottom();
this return compile-time error , cause there is no such function , i have to write it in braces :
string["removeWhiteSpace"]();
string["sliceStr"]("." , "end");
textField["scrollBottom"]();
and i like to aviod it )
View 2 Replies
Mar 16, 2003
Is it not possible to call other functions from generic mouse event functions? Surely it is !!??ie....
Code:
_root.myButton.onPress = function(){
hide();
[code]........
View 11 Replies
May 12, 2010
By the way I'm still really new to Flash and AS3.I'm writing this quiz that gets questions and answers from an xml file in the same directory and displays the question in a TextArea, the available answers in a list, and additional text in another text area.Most of it was working the way I wanted and I noticed the apostrophes weren't coming through the XML so I thought I'd try escaping it with a not thinking. I did a publish preview and saw that my list loop became infinite populating my answer list. I took the out and still had the same problem. I backed out as far as I could in the AS3 and couldn't find anything that would cause it to continually loop like that. I traced a statement at the beginning of the script and realized it was actually looping the whole app not just an event or function. I'll reply back with the code.
View 1 Replies
Jun 3, 2009
i made two buttons, first called buttonA and the second buttonB.each button will run a movieclip when it's clicked now, the first time when i try it it works wonderfull, then when i keep clicking it, the scrips repeats causing the moviclips to pause or run again, the more i click the more it repeats ,
View 2 Replies
Sep 14, 2010
Is something wrong in this syntax? I'm getting only the first record and it keeps on repeating. When the php file is being tested in the borwser, it shows its data correctly in this format. AA,,BB,,CC,,DD,,
senderLoad.sendAndLoad("http://www.web.com/bb.php",receiveLoad,"POST");
txt2.html=true;
receiveLoad.onData = function(src) {
[code].....
View 18 Replies
Sep 25, 2010
I have a website with a mc inside a mc. The nested clip keeps repeating , I want the nested clip to run 1 time. I have stop actions on each clip, it delays, but won't stop repeating.
View 6 Replies
Oct 20, 2003
if there is a piece of code that will count from 0 through 9 and then just keep repeating over and over?
if there is would there be a way of controlling the spped of the count - so it could go really fast or quite slow??
i tried
[AS]onClipEvent (load) {
myValue = 0;
}
[Code].....
View 5 Replies
Jan 14, 2011
Functions embedded inside other functions? In all my years of ActionScript programming, I've never seen this (this is part of legacy code written by someone else which I am adapting):
[Code]....
View 6 Replies
Mar 19, 2010
Its a complicated senario for me. I have a sound management singleton with an asset like dictionary storing all referances to my urls and assets and the guff inside it-
I have a function called addItem(id:String, url:String):Object
I would love to do something similar as soundManager.addItem(id:String, url:String).play() or soundManager.addItem(id:String, url:String).stop() of which it'll both add my item to my dictionary, and begin playing the sound
[Code]...
View 2 Replies
Dec 27, 2009
Let's I have a class Square that has a several functions. I want to call it from a class Grid, which is a group of Squares.So in the class file for Grid, how would I do this:
Code:
public function doSquareFunction(thisFunction:Function):void{
square1.thisFunction();
[code]......
View 8 Replies
Nov 9, 2005
I have a function with 4 necessary arguments (aka parameters) in order to perform the actions. I would like to have the ability to pass the same function to itself as an argument (sort of like a recursive function) along with its arguments. Basically I want to "base" to engage an onMotionFinished event handler if there is another function passed as an argument. Something like...
[Code].....
Would there be a way to use listeners to do this or the AsBroadcaster?
View 6 Replies
Dec 3, 2009
I have a simple mp3 player, with PLAY PAUSE PREVIOUS and NEXT buttons. the problem i have is if you click the play button more than once, the mp3 clip will start to play itself as many times as you clicked. this sounds really bad..u could have the clip playing over itself 5 times.
Code:
if(play button is clicked ONCE){
(deactivate play button until next song);
}
in other words, only one PLAY-button-CLICK allowed per song...
View 7 Replies
Mar 10, 2010
I am dynamically playing a video.flv file on the stage when a button is clicked. It plays fine but continuously repeats itself. I want it to play once and the disappear.
View 2 Replies
Apr 25, 2009
So, I downloaded a simple sound loop from Flash Kit.
I am building a Flash webiste and want the sound to loop once the movie loads. I have added a stop and play button to the movie in case the viewer doesn't want the sound on. I understand sound can be annoying.
I add the following code to the FRAME 1 of the movie. Everything works fine but when the loop finishes, it just stops. How do I get it to continue looping? Also, as I navigate to other sections of the movie.. I want it to continue playing and not restart when I go back to say "Home". Home starts at frame 1 as well.[code]...
View 9 Replies
Jun 16, 2010
On the stage of a flash app I have several movieclips that keep repeating. Now I need a movieclip that doesn't repeat. It should play once, and then keep its last state on stage. I can't find out how to stop this movieclip from repeating.
View 3 Replies