ActionScript 3.0 :: Adding Timer To Recursive Function?

Nov 16, 2010

I made an app (Towers of Hanoi) and i added a "demo" button that solves the problem based on a recursive function. The button is supposed to make a move one step at the time, i mean one step at every few seconds so you can actually see how the algorithm works. The problem is i haven't really used the timer event before and i have no idea how to implement it in this particular scenario.

Code:
function hanoiPlay(n:int,a:Stack,c:Stack,b:Stack):void
{

[code]......

View 7 Replies


Similar Posts:


Actionscript :: Recursive Function And Returned Value?

Nov 5, 2010

I think I have the recursion working properly, but I'm not able to get the originally requested item's property set to the right value.The goal here is to find the topmost parent (or "ancestor," depth = 0) of the nested item (a taxonomy based on Dictionary "parent" attributes), and assign that originally requested nested item's "ancestor" property accordingly.For instance, in

Apples
- Red
- - Empire
- - - Fresh

"Fresh"'s ancestor should be set to "Apples." While I'm attempting this on an "on-demand" and individual basis, I'm open to a solution that tags all children that are related to the same ancestor in one fell swoop or for statement, since that would probably be more efficient.

REQUEST

for (var mc:Object in taxonomy) {
var term = taxonomy[mc];[code]....

As you can see, while the recursion does find the root, the originally requested item still gets the default value.

View 2 Replies

ActionScript 2.0 :: Recursive Function XML Tree

May 3, 2004

im having a problem reading a xml tree in Flash MX...[code]and this Actionscript to just to view the tree.[code]meaning that when it calls itself again, that it will stop searching the next items on the same level from where it was called.how do i not let it stop searching and complete the tree.

View 4 Replies

ActionScript 3.0 :: [flex As3]function Non Recursive Call. How?

Feb 3, 2009

So, 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.
What's the cleanest way to do that?

View 16 Replies

ActionScript 3.0 :: Recursive Function To Search Through XML Tree

Aug 27, 2009

I want to vreate a recursive function that will search through my xml tree and display all the leaves(node values); this is the function that I wrote:

function searchXML (theItem) {
trace("theItem.*.length() "+theItem.length());
trace("theItem.* "+theItem);
trace("--------------------------------------");
if (theItem.*.length() > 0) {
searchXML(theItem.*);
[Code] .....

View 1 Replies

ActionScript 3.0 :: [flex As3] Function Non Recursive Call?

Sep 2, 2009

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.

View 1 Replies

ActionScript 1/2 :: Recursive Function Crawling Through Movieclips?

May 19, 2010

I have this function to find occurences of misstyped varaible names (with wrong lower / upper case). I have a movieclip called "debug" where I define and call this funciton ("getCase(_level0)"). But It never finds my testttt variable - If I put the test varaible in _level0 the variable is found. 
 
var targetsCase_ary:Object =  new Object();
var targetsLower_ary:Object =  new Object();        testttt = 1    testttT = 1        function getCase(clip:MovieClip, recu:Number){        if (recu==undefined) recu = 1;        var n:String;        for (n in clip){            var sPath:String = clip._target + "." + n;            var sPathLower:String = sPath.toLowerCase ();                        //trace(sPathLower + " " +

[code]....

View 3 Replies

ActionScript 3 :: Slowing Down Loop In Recursive Function

May 2, 2010

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);
}}

View 3 Replies

ActionScript 3.0 :: Recursive Function Returning Null Value

Feb 7, 2011

I've been trying to implement a QuadTree to store a two-dimensional array representing a terrain. I generate the array first, then I use the below function to generate a QuadTree for the array.

[Code]....

View 5 Replies

ActionScript 2.0 :: Loading An Xml And Looping Through It Using A Recursive Function?

Jul 22, 2004

FLASH MX 2004

I am loading an xml and looping through it using a recursive function. The problem is that it only reads through the first tree and then quits..?

[Code]....

View 3 Replies

ActionScript 2.0 :: Creating A Kind Of Tricky Recursive Function?

Apr 4, 2005

Because it's a little hard to explain what I need.. I'll make an example.So.. I have the figure below. I mean.. that's what I'm trying to achieve. For that figure I have data stored in the folowing way._root.marc is an Array.All the paths that leave a square ... like From M0 if you choose 1 you'll get M1,From M0 through 5 you'll get to M3.. and so on.this is stored like_root.marc[0].p - the paths. If _root.marc[x].p.length is 0.. that means that Mx is the last one.. and has no paths assigned, like shown in the figure. My very big problem is that I need to position that MC's.. M3,M4.. all of them, according to the paths above them.

So, to position M2, i need to take a look at M1, and if it has any paths, more than one path, I need to move it further down. But this is not the end of it. If M1 has more paths that lead to other MC-s.. i need to take in considerations their paths too . This drove me mad for the last couple of days, and my time is slowly running out for my diploma What I've tryed till now was to build a function let's say... getNextY(m) that should return a number. A "ponder"?..like...to use it in a line like M2._y = (currIndex + getNextY(1))*dy;// here it should return 5 for instanceM3._y = (currIndex + getNextY(2))*dy;// here getNextY should return 1

View 11 Replies

ActionScript 2.0 :: Recursive Function - Reading A Xml Tree In Flash MX?

May 3, 2004

im having a problem reading a xml tree in Flash MX...i got this tree,

data.xml
PHP Code:
<menu>
<menuitem label="menu1">[code]....

meaning that when it calls itself again, that it will stop searching the next items on the same level from where it was called...how do i not let it stop searching and complete the tree..

View 4 Replies

ActionScript 2.0 :: Creating A Kind Of Tricky Recursive Function

Apr 4, 2005

I'm in a big big mess, trying to figure out how to do this for the last couple of days. I finaly came to the conclusion that I need a recursive function for what I'm trying to do. Because it's a little hard to explain what I need.. I'll make an example. So.. I have the figure below. I mean.. that's what I'm trying to achieve. For that figure I have data stored in the folowing way. _root.marc is an Array. All the paths that leave a square ... like From M0 if you choose 1 you'll get M1, From M0 through 5 you'll get to M3.. and so on. this is stored like _root.marc[0].p - the paths. If _root.marc[x].p.length is 0.. that means that Mx is the last one.. and has no paths assigned, like shown in the figure.

My very big problem is that I need to position that MC's.. M3,M4.. all of them, according to the paths above them. So, to position M2, i need to take a look at M1, and if it has any paths, more than one path, I need to move it further down. But this is not the end of it. If M1 has more paths that lead to other MC-s.. i need to take in considerations their paths too . This drove me mad for the last couple of days, and my time is slowly running out for my diploma What I've tryed till now was to build a function let's say... getNextY(m) that should return a number. A "ponder"?.. like...to use it in a line like
M2._y = (currIndex + getNextY(1))*dy;// here it should return 5 for instance M3._y = (currIndex + getNextY(2))*dy;// here getNextY should return 1 Why 5 or one? because it needs to take into account only if the paths are greater than 1.

View 10 Replies

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?

View 2 Replies

Adding A Seekbar Bar Timer?

May 6, 2009

I would like to add a timer that keeps track of total time and also current time that runs next to my seek bar component for my flash movie. How can I do this? For example: 1:11 | 2:04 ... the 1:11 displays the current time of the movie and the 2:04 would represent the total time of the video.

View 20 Replies

IDE :: AS 2 Adding Time To Timer

Jan 26, 2010

I am creating a flash game with a timer and as you answer questions I would like the time to increase or decrease but I can't seem to figure out how to do so.

View 1 Replies

ActionScript 2.0 :: Adding A Timer To Game

Oct 8, 2006

I've been trying to make my own flash game based on the kirupa tutorial: url...My scripting is very similar to the scripting in the tutorial, but I obviously adapted it to my own design. Now Iïż½m trying to add a time limit, which when the time reaches 0 it jumps to the time up screen. I have spent two whole days searching on google, trying loads of suggestions, trying to figure this out myself.[code]This scripting works on a test page (i.e. away from the actual game) but when I try to add it to my game it deletes the main movieclip (in this case a tank) which is used to play the game.

View 3 Replies

ActionScript 3.0 :: Turning A MouseClick Function Into A TIMER Function?

Oct 30, 2009

I had a function that occured on mouseclick called go_out. I want this function to occur when the timer fires after 5 seconds. After the 5 secons I receive this error:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.utils::Timer@3fe4561 to flash.display.MovieClip.
at home_flash_fla::MainTimeline/go_out()
at flash.utils::Timer/flash.utils:Timer::_timerDispatch()

[code]....

View 1 Replies

Flash - Adding Time To Timer / Counter

Nov 28, 2011

I've looked all over the web and everyone can teach you how to make a timer for your game or a countdown, but I can't seem to find out how to add time to an already counting timer. So here is my counter class:

package {
import flash.display.MovieClip;
import flash.display.Stage;
import flash.text.TextField;
import flash.events.Event;
import flash.utils.Timer;
[Code] .....

That works without any issues or problems and just keeps counting upwards at a speed of 100ms, what I want to know is how to add say 30 seconds if something happens in my game, say you kill an enemy for example.

View 2 Replies

ActionScript 3.0 :: Position Of Images Changes When Adding Timer?

Oct 16, 2009

I finally added a timer into my XML AS3 gallery, but when the timer starts the images dislocate..

What is the problem here? I manually set the width and height in the XML with difficulty... (Because I couldn't find a way to automatically set the image to the horizontal and vertical center..)

But why does the position changes when the timer starts to play (every 10 secs)?

This is wat it looks like when the timer hasn't started yet (or when I browse through the images with the arrow buttons):

[Code]...

View 5 Replies

ActionScript 3.0 :: Timer Adding And Removing Children

Aug 24, 2011

I am creating a game and want to reward the player at the end of a level by playing an animation. I have created a timer to add the animation to the stage but cannot figure out how to remove the animation once the timer has completed counting. I am sure you wise scripters out there know the secrete to this mystery.

[Code]....

View 2 Replies

ActionScript 2.0 :: Adding Time To A Countdown/timer?

Mar 20, 2007

I'm making a game and it has a 20sec timer in it and I want to make a button/powerup thing that adds 5 seconds to the timer when you press it.I'm currently using: -

Code:
timerBTN.onPress = function(){
_root.countdown += 5;

[code].....

View 6 Replies

ActionScript 3.0 :: Adding Penalty Feature To Timer?

Apr 5, 2012

The game contains a timer which displays on screen and counts up displaying hours, minutes and seconds.

When the hint button is pressed the game adds 1 to the penalty counter.

Code:
penalty++;

What I want to happen is for 20 seconds to be added the time shown at the end of the game for every time the hint button is pressed.

Below is the timer code:

Code:
function TimerHandler(e:TimerEvent):void{
var Seconds:String = String(uint(MyTimer.currentCount%60));
var Minutes:String = String(uint((MyTimer.currentCount/60)%60))
var Hours:String = String(uint((MyTimer.currentCount/60)/60));

[Code]....

View 4 Replies

Flash :: Adding Parts Of A Snake On Through Timer Events?

Mar 30, 2011

having problems adding parts of a snake on through timer events

package {
import flash.display.Sprite;
import flash.events.KeyboardEvent;[code]....

View 1 Replies

ActionScript 2.0 :: Adding A Timer To Sequentially Load In Buttons?

Oct 14, 2009

This is TJenner2's code I got from this thread:

ActionScript Code:
var myBtnArray:Array = ["Apple", "Orange", "Blue", "Lion"];
var myFrameArray:Array = [2,3,4,5]

[code].......

View 7 Replies

ActionScript 3.0 :: Timer Animation - Adding And Removing Children

Aug 24, 2011

I am working on a game and want to reward the player with an animation at the end of a level. I have created a time and added the animation to the stage but I cannot figure out how to remove the animation once the timer has completed.
Code: Select all/* Simple Timer
Displays a countdown timer in the Output panel until 30 seconds elapse. This code is a good place to start for creating timers for your own purposes.

Instructions:
1. To change the number of seconds in the timer, change the value 30 in the first line below to the number of seconds you want.
var celebration:Celebration;
var fl_TimerInstance:Timer = new Timer(1000,30);
fl_TimerInstance.addEventListener(TimerEvent.TIMER, fl_TimerHandler);
fl_TimerInstance.removeEventListener(TimerEvent.TIMER, removeTimer);
fl_TimerInstance.start();
[Code] .....

View 1 Replies

ActionScript 3.0 :: Adding Timer To MovieClip Loop In Triangle

Jan 25, 2010

I set up a loop where a movie clip moves in a triangle over and over. It works, but I want it to pause for 5 seconds at each location, so I added a Timer (my first attempt). Now, it will go through the triangle once, pausing correctly, but then the main movie clip (target_mc) stops in the original position and never moves again.

Code:
import fl.transitions.*;
import fl.transitions.easing.*;
var xMove0:Tween;
var yMove0:Tween;
var xMove1:Tween;
[Code] .....

View 5 Replies

ActionScript 3.0 :: Flash - Adding Time To A Game Timer?

Mar 21, 2011

've created a simple flash game for moving a car round the flame to collect fuel cans and avoid traffic cones. The game has a 10sec timer running but i want to make it that if u hit a fuel can it adds 5secs to the timer and if u hit a cone it removes 2secs.This is my code so far

var fuelpoints = 0;
var conepoints = 0;
startButton.visible = true;

[code]....

View 1 Replies

ActionScript 3.0 :: Rotator Timer - Adding Buttons For User To Control Item

Aug 24, 2009

I have a news rotator that is populated from an RSS feed. The rotator has a timer that cycles through the news items, displaying a link and image and title for each item. I have the put in three buttons for the user to control the item that is displaying. A pause, forward and backward button.

My issue is that I'm not sure how to implement the button without messing up my timer that is already running. I was able to do the Pause button, which was simply to stop the timer. The forward and backward buttons are a bit more tricky. This is what I have so far. Note that I have much of the code duplicated because I needed to initialize the objects for the first timer index. After the first item, the code runs from the timerHandler() function.

PHP Code:
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
[Code] .....

View 2 Replies

ActionScript 2.0 :: For(); How To Add A Timer Function

Aug 22, 2006

I have a for() statement performing a loop that attaches a movieclip each time it's executed. The variable "maximumBloodBurst" defines how many times the loop cycles (the amount of movieclips to produce).Here's the script:

Code:
createBloodCells = function () {
var g:Number;

[code].....

View 12 Replies







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