ActionScript 3.0 :: Repeating Functions X Number Of Times
Mar 15, 2009if myVariable is a number variable and myFunction is a function, how do I use AS3 to repeat myFunction myVariable number of times?
View 2 Repliesif myVariable is a number variable and myFunction is a function, how do I use AS3 to repeat myFunction myVariable number of times?
View 2 RepliesI'm trying to create a shuffle button for my mp3 player. I don't want it to repeat any song in the xml playlist until all the songs are played. Is there to display a random number on the click of a button, without repeating any number in the array until all the numbers in the array are used?
View 9 RepliesI have a movieclip called myButton,inside of myButton i have a textfield called buttonLabel. I have 16 instances of myButton placed on the stage with instancenames myButton1,myButton2, etc.I want the textfield inside of each button to display the same number as the one in their instance name. ie myButton1.buttonLabel.text = "1".instead of repeating that line of code 16 times, is there a way i can use a loop? something like
for (var i:int = 1; i < 17; i++)
{
myButton(i).buttonLabel.text = i
}
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 RepliesHow 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 RepliesI'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]...
what's the best way to combine these onrelease functions here so i dont have to repeat the same lines of code?
[Code]...
I am using a code to load images into random movieclips and this works ok but I am getting a lot of repeated numbers
totalPlaces=6
for (i = 1; i < totalPlaces; i++) {
rannum=random(27)+1
[code].....
How to create a code to generate non repeating random number?
View 3 Repliesi was just wondering how to create random numbers without ever repeating the same number twice or more
View 4 RepliesHow to create a code to generate non repeating random number?
View 3 Repliesi have a main .swf that automatically loads a second .swf on its last frame (via loadMovie.) it loads this second .swf to level 0 (replacing itself).
when the second .swf reaches it's own last frame it loads the main .swf into it, beginning the whole process again. here's the thing...
i only want this to happen 3 times. in other words, the third time that the second .swf is loaded into the main .swf. i want the whole thing to stop-freeze-on the last frame of the second .swf.
I created a button.....it will be clicked 2 times. When clicking on button 1st time, the ball 01 will appear. When clicking on button 2nd time, the ball 02 will appear.
Code:
var i:Number = 2;
_root.next.onPress = function()
{
[Code].....
I need to take a jpg and clone it 200 (can be any number) times. I want the files to all be saved in the same directory but with numbers. Essentially creating an image sequence of one image.
Photo001.jpg
...
Photo200.jpg
Is this possible? The file reference class seems like would ask me each time where to save the file, I clearly don't want that. Ideas?
I've got a presentation that continually reads an XML and displays content based on that. It works fine for 2-3 hours then just stops. No errors, just stops.
What I'm doing is adding and removing eventListeners throughout the process using two alternative loader objects.
For example:
PHP Code:
slideLoader1.contentLoaderInfo.addEventListener(Event.COMPLETE,loadJPG, false, 0, true );
I started using the "weak" listener based on what I've been reading about garbage collection, but actually this works better:
PHP Code:
slideLoader1.contentLoaderInfo.addEventListener(Event.COMPLETE,loadJPG);
The presentation runs much longer with the second listener type. In both cases I'm removing it this way:
PHP Code:
slideLoader1.contentLoaderInfo.removeEventListener(Event.COMPLETE,loadJPG);
Is there a problem constantly adding/removing eventListeners this way?
I'm talking about the div(X,Y) function in C which returns the number of times X is reduced by Y. if you're confused, I'm talking about this:
div(30,5) returns 6 (30 is reduced 6 times by 5)
div(34,7) returns 4 (you can reduce 30 by 7 four times, leaving 6 behind)
Is there such a function?
I am trying to repeat a function x number of times. How do I go about doing that?
Here is the function:
Code:
function dance(){
var animspeed = .4;
var back = 0;
var delay = (animspeed);
[Code]...
I have 1 button that when pressed 1 time should play "movieclip 1" and when hit for the second time should play "mc 2" on so on untill "mc9"(each movieclip plays continously when once activated)
so I need the button to register how many times it has been activated to play the right movie at the right time
I know I saw a script once that would work sometime, just cant find at anymore
I want to loop a movie clip a different number of times depending on conditions in an if else statement i tried using a counter like this
Code:
playTwo = function(){
if (_global.counter < 2) {
theMC.play();
[Code].....
I'm new at actionscript, so I'm making simple button games, but I have 2 questions: Question 1: Displaying number of times the button is clicked I searched the forum, and what I found was.
[Code]...
for example, if I clicked the button 100 times, a text "ABC" would appear, and if the button is clicked 200 times, a text "DEF" would appear in the same text field. I only have a rough idea on how to do this, so before I fail completely, can anyone just give me the code instead
How could I count the number of times that the values are found, i.e. yes=2, no=1 .. in AS3?
View 3 RepliesI was taking this tutorial, >>LINK<< I want to change it from,
Code:
on (click) {
Duplicate Movie clip to,
Code:
onClipEvent (Load) {
That way once it load's it will duplicate the circle MC a random number of times. This circle MC is inside of another MC so it wouldnt be _root i want it to goto, it would be t_mc that I want it to look for it in.
So in the t_mc MC I put this code,
Code:
onClipEvent (load) {
i = i + 1;
duplicateMovieClip (t_mc.circle, "circle" + i, i);
}
And on the circle, I put this code,
Code:
onClipEvent (load) {
scale = (random(100) + 50)
this._x = random(250);
this._y = random(150);
[Code] .....
How to count how many times the btn have been click. After counted the number of btn been click, according to the number, load the sound that match with the number of the btn been click.
At the first frame :[Code]
Sound = new Sound();
Sound.attachSound("firstSound01.wav","secondSound0 2.wav");
At the btn's action:[Code]
on (release) {
count++;
trace(count);
if (count == 1) {
_root.Sound.start();
[Code] .....
With using these code, the sound come out when I click the btn is firstSound01.wav,the second time i click the btn the sound come out still firstSound01.wav. How to make it come out secondSound02.wav when I click the btn after first sound finish.
how can i have one movieclip but make it multiply alot times with a max number like maybe 10??
View 1 Replieshow to count how many times the btn have been click. After counted the number of btn been click , according to the number , load the sound that match with the number of the btn been click. i upload the fla zip file to here.anyone who know how to do it,
[Code]...
b'cos of the file is too big i can't attach here,so i post the code here.With using these code, the sound come out when i click the btn is firstSound01.wav,the second time i click the btn the sound come out still firstSound01.wav.How to make it come out secondSound02.wav when i click the btn after first sound finish.
I need to make the whole ad repeat X number of times and then stop on the last frame (it always stops in the first frame for me) then I need to link the clickable button to go to a website when clicked. [URL]
View 4 RepliesCreate a 12x9 grid;Populate the cells with random numbers ranging from 1-9;Assign a symbol (custom graphic) to each cell depending upon which random number is generated in it;Limit the amount of times each number in the random range is used to 12.My question is simply this: how do I, using AS3, create a random number function that will only use each number in its range a maximum of 12 times (it is important to note that my grid consists of 108 cells using the numbers 1-9 exactly 12 times each)? So for example, if the random number function populates 12 cells with the number "4," it will then exclude that number from its remaining iterations.I am adhering to OOP standards so including script in actual timeline frames is not desirable.
View 5 RepliesI have a list component that lists certain items..
so, if i click on a certain item..i should get the index this way : var clickedIndex:int = listID.selectedIndex; but how can i count the number of times the variable clickedIndex has been selected? so, if a user keeps clicking on the index[0], i want to know how many
I want to count the number of times the mouse click, whenever it is clicked. I read about the mouse events in flash but I am unable to complete is Here is my trial
1) Created an oval with the oval tool and by using text tool I wrote START on it and made it a button by clicking CREATE A SYMBOL.
2) Whenever that oval button(Start) I need to count the number of times I clicked on it.
how to get a movie clip to loop a specific number of times in Flash? I know how to stop a movie clip from looping by using the this.stop (); command by placing the command in a separate Action Script layer, in a keyframe, inside of the movie clip's timeline. This allows the movie clip to play through once and then stop. But I need for the movie clip to loop more than once, maybe 2 or 3 times, and then go back to the main timeline.
Also, is it possible to place a pause (I'm guessing, maybe by using a timer of some type?) between the loops, so that the movie will pause a couple of seconds before it loops again and then stop? Please note I do not need the movie clip to stop when there's an event like a rollover or anything. I just need it to play a couple of times, pause between plays and then stop and go back to the main timeline.