ActionScript 2.0 :: Place A For Loop In A Recursive Function With The Function Call Within The Loop
Nov 4, 2005
If you place a for loop in a recursive function with the function call within the loop... will the loop finnish or does it stop working untill the last recursion?
I have a difficult problem with a recursive function. Essentially I need to 'slow down' a for loop within a function that repeatedly calls itself (the function); Is this possible, or do I need to somehow extract the recursive nature of the function?
function callRecursiveFuncAgain(ob:Object):void{ //do recursive stuff; for (var i:int = 0; i < 4; i++) { _nextObj=foo callRecursiveFuncAgain(_nextObj); }}
This function creates a word inside of a movieclip. The words that it makes are specified in a text document in an array, and I don't know how many there will be. Then I have a do while loop that creates movie clips for these words to go into:
I have a thumbnail gallery and i want each thumbnail to appear 1 by 1 rather than appear all at once.At the moment i have a for loop that creates each of the thumbnails.
I create standard AS3 flex project. In constructor goes only start();
rest of functions are basically this: private start():void { f1();} private function f1():void { f2();} private function f2():void { f1();}
And it's standard recursion. SWF either breaks or loops as many times as I tell it. One f calls the other, which calls first... I do not want that. I want f1 to do some stuff, calls f1 and closes itself. Than f2 works, calls f1 and closes. And so on. Like having 2 sets of code that loops through.
I am trying to figure out how to call an onComplete function without leaving the code loop (because the vars are no longer recognized with the hand-off). I thought this might work:
I have a variable in a loop that i want to access in a function outside of the loop. However the variable gets deleted when the loop is closed so no longer exists when i call in the function.here is the code; i'm trying to access the variable picHeight from within the scroll function
I have a function that is called from clicking a button
PHP Code:
con.scrollerDetails_mc.content_mc.info_mc.spin.addEventListener(MouseEvent.CLICK, spinIt); var isTurning:Boolean = false; function spinIt(e:Event):void
I am making a character walk. This code will make him wobble to the right and when thats done it will trigger him to wobble to the left and then call the function again to continue the loop.I can get the loop to work fine by calling the function but how do I STOP the function? Also I want to call it later on. Is there a way to start and stop a function?
I have a while loop that I need to shuffle the order of my array. This was initially an AS2 code and am trying to convert this over but have come across with an error I don't understand so hoping someone may know what it means. My while loop code is:
Code: var randomArray = shuffle(orderArray); function shuffle(toShuffle) { // shuffles an array
I looked through the documentation on looping, but I don't understand it. I'm trying to make this function loop, until the user stops it:
function playMusic(evt:MouseEvent):void{ channel.stop(); //to prevent users from starting files multiple times over top of each other - is there a better way to do this? channel = myMusic.play(songPosition); myTimer.start();}
If I want to break out of a function rather than a loop, it's suggested that I use the return; statement. But that doesn't work in the following code, I just want the trace statement to run once...
I am designing and coding a navigation menu at the moment, and so far I have got the button instances to duplicate for each of the menu items, and set widths, positioning values and RollOver/RollOut functions. However, I would ideally like to include the onRelease button functions in the for loop too - as they are all the same apart from the variable "i". Here is the code snippet:
ActionScript Code: for (i=1;i<(_root.noofmenuitems+1);i++){ duplicateMovieClip("mc", "mc"+i, i);
[code]...
Now my problem is that by the time the onRelease function is called, the for loop has been completed and the value of i returned is the last i value from the loop (_root.noofmenuitems+1). The this["mc"+i] part obviously works, because the trace function is called when I click any of the menu items.The problem is that I have 6 menu items, and when I click any of them, the trace function returns "test 7" - not the corresponding i values for each button.
this is a standalone AIR app which runs off of usb media to help people organize their personal information. there is an XML file in a separate folder which stores the name of a file that the user uploads to usb media (into yet another folder), in this case, the person's living will. getting the path to that file as it differs from mac to pc has been a challenge and i feel the only way around this is to give a conditional for the operating system (second function below).
My immediate goal below is to get the name of the file (VALUE) over to the openThisFile function so that "fileName" can be given a value appropriately in the second function code for mac. I can't figure out how to do this...Alternately, is there a way to manipulate "currentTarget.data.toString()"? I was thinking that could also help me... it has the full path to the file, which unfortunately does not work on Macs... for some reason it just can't locate the file (unless I'm missing something).
Quote:
public function handleLoadData(event:Event):void { try { propertyFilePath = path;
I have a script that contains: an array of movieclips -> MaxBallArr another array of movieclips -> MaxBallLrg an array of textfields -> MaxToolTipArr a library movie clip -> max_box
I'm trying to gather them some how in an addEventListener which worked fine in that way:
ok how and where do i put the setInterval script if i want to execute the "animateThumbsToLeft" function for 6 times and inbetween each time have a delay of say half a second..
i need a function that would remove all children of a specified container, except specified exceptions, something like removeall(cont, {cont.mc1, cont.mc2});that removes all children of cont, except the two mcs. if possible i need the number of exceptions to be not too limited.i almost made it, but then, when i needed to add the children back, i got stuck.the function needs to remember (array?) everything it has removed, including the state in which all of it was (alpha, scale, childinxed, etc);even that almost succeeded, but when i used one specific array that i declared outside of the function, if i used it to remove children of somebody else, i couldnt make the array remember both cases to add them later. make an array of arrays?anyway, i am very very much stuck, and would would be very happy to get out.if something like this exists on the web, would love a link. if not, i think such a function (especially integrated with an eventmanager class to make a super as3 nanny) would be a great gift to the as3 people.
have images play automatically when you don't click on PREV or NEXT buttons in a gallery for a certain amount of time.
I've used the TIMER function, but found that, when I click on PREV or NEXT, the timer would be activated again on that picture, which messes up the entire browsing experience.
I'm creating a sort of psuedo DBMS in flash and I'm having trouble populating my tablesI'm creating input textboxes for each of the input values.My problem is this. The textboxes are being created in a for loop like this..
How would one go about creating a function inside a for loop that does not have a button action attached to it while still having access to the current index number.
This code was found on senocular:
Code: var curr_button; for (var i=1; i<=3; i++){ curr_button = this["button"+i]; curr_button.num = i;
[Code]....
This is all great however i would like the functions to just be regular old functions, not button actions (onPress), is this possible?
Am Creating a game in as2 an object come from left to right Randomly how do i stop the object i written script in single frame but it runs in all frame of the game
_root.onEnterFrame = function() { passed++; if (passed>speed) {