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


Similar Posts:


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

Professional :: Tricky Animation Function - Copy Paste One Of The Segments Into A Separate Layer

Oct 3, 2010

its a door make up of 8 segments, im trying to animate it by making it open and close equaly,each door segment. but my segment is distorting because im doing each one segment bt segmet.is there a way to achieve this in flash?

a):should i copy paste one of the segments into a seperate layer using that one animation i got for all 8 parts?

View 6 Replies

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 :: 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

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 :: 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 3.0 :: Some Tooltip Kind Of Function In Flash?

Mar 23, 2010

when i worked with flex, i had the lovely function called tooltip wich made some text appear on a mouseover.Now i was wondering, is there some tooltip kind of function for as3 in flash? Or do i need to make a textfield that hovers slightly above the mouse and gets visible on a rollover?

View 1 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

ActionScript 3.0 :: Optimize The Code And Make Some Kind Of Switch Case Inside The Function?

Aug 29, 2009

i have many buttons(they are actually movieclips) and for each i made separate listener function.. is it posible to optimize that code and make some kind of switch case inside the function. I don't know how to find out who called the function... is there way to find out. I don't want pass the additional argument with events because it wouldn't be optimization at all.I put only two buttons to reduce code:

Code:
button1.addEventListener(MouseEvent.CLICK, idi);
button2.addEventListener(MouseEvent.CLICK, idi2);
function idi(event:MouseEvent):void {[code]....

View 3 Replies

ActionScript 2.0 :: Tricky Multidimensional Array?

Nov 10, 2004

I can't seem to get my combobox to work right. Let me paint the scenerio.I have my multidimensional array:

Code:
nissan = [ ["altima","1984","2005"], ["maxima","1976","2005"] ];

Then I have my two comboboxes:

Code:
model_cb and
year
heres my AS:[code]....

when I do this my "year_cb" displays >> nissan[0][1] or nissan[1][1] depending on if you choose altima or maxima.So I've gotten it to do that much but now I need it to display the corresponding year for the part in the array i.e. plug in "1984" (nissan[0][1]) and populate the combobox through 2005 (nissan[0][2]).when I use this code:

Code:
for(i=nissan[0][1]; i<nissan[0][1]; i++){year.addItem(i);

My file is to big to include even after zipping.

View 14 Replies

ActionScript 2.0 :: Tricky Navigation - Replace The Chosen Button?

May 23, 2002

i got 5 buttons in a row. on mouseover i want to replace the chosen button with 3 or 4 buttons (they should smoothly, vertically come up and all other buttons should come closer, depending on the longest of the new buttons). on rollout i want to go back to the first button.

so, i put the first row of buttons on frame 1 (the actions stop). on mouseover it keeps going to frame 2 and smoothly the buttons come up. on 5 there s a stop action. on rollout it keeps going to frame 8, where its back to normal again. on a second mouseover its supposed to go to frame 2. and theres the problem, sometimes it works, sometimes not.

View 1 Replies

ActionScript 3.0 :: Tricky Regex, Splitting At Singular Capital Leter?

Jan 23, 2012

I want to be able to split the following works in at the capital letters:
 
UserArea
User Area 
userArea
User Area 
UserAREA
User Area

[Code]...

View 3 Replies

ActionScript 2.0 :: Recursive XML To Multidimensional Array

Dec 27, 2010

ActionScript Code:
<root>
<node>

[Code].....

create Multidimensional Array from Recursive XML.

All I need create Array inside an Array dynamically from an unknown XML tree.

View 3 Replies

ActionScript 2.0 :: Any Way To Determine Recursive Loop End?

Jul 4, 2005

How do I determine the end of a recursive loop - when going through an xml document of unknown size?

View 7 Replies

ActionScript 2.0 :: Recursive Limits Workaround?

May 11, 2007

I am making a SUDOKU generator(ActionScript2.0), which would (for now) generate the full and correct sudoku table. To do that I need to use recursive functions for calculating all the possible values. The problem is that when I try to run my program I get this error :

Code:

256 levels of recursion were exceeded in one action list.

This is probably an infinite loop.

Further execution of actions has been disabled in this movie.Is it possible to somehow work around this limitation?

View 2 Replies

ActionScript 2.0 :: Recursive Functions And Loops?

Jan 16, 2009

I'm trying to create a minesweeper game as exercise, but I stumbled upon a problem.I've cleaned the code for you so only the relevant code is here:

Code:
function expand(cell) {
getbounds(bounds,cell.row,cell.col);

[code].....

View 1 Replies

ActionScript 2.0 :: Recursive Array On Levitated.net?

Nov 4, 2004

I've been studying the experiments on Levitated a lot. I've been looking over this one that deals with recursive functions. Here is the link:The actually get most of it. There is one part with an array though that pushes something and I don't understand it. Here's the code:

Code:
function addFillRequest(x0, y0, x1, y1, d) {
// que up a request to fill a region

[code].....

View 5 Replies

ActionScript 3.0 :: Make A Recursive Button Event?

Mar 14, 2011

I have a menu of 4 buttons and I'm trying to not be redundant and recursively use the same over, out, clicked function for each button by passing it's instance through the event handler.

I haven't had a whole lot of success finding the answer except locating a thread about creating custom classes....Which would be great, but I don't want to re-create my entire structure now. So I was wondering what the best approach might be.

Here's the code I've been working on.

[Code].....

View 4 Replies

Flex :: Recursive Iteration Through Every Component Instance?

Nov 17, 2009

I have various custom component instances in my flex app. I want to loop through them recursively and get their instance Ids. The recursive part is very important to me. I have tried doing this, but it didn't do recursive:

for each (var myItem:* in this.MasterContainer.childDescriptors)
{
trace(myItem.id);
}

View 3 Replies

Actionscript 3 :: Recursive Folder/Directory Copy With Air?

Sep 13, 2010

Is it possible to use pause/resume function to this??

source.copyTo( destination );

It would be great if you can send it at the earliest.

View 2 Replies

AS3 :: Flash - Recursive Object Scan Without Repeats?

Jun 12, 2011

While recursive scans are commonly use to scan through nested objects / data. It can go on an infinite loop, if some of the objects references one another. So what is the most effective way to scan all items, without crashing the computer, nor skipping a specified parameter?

Here is an example of a recursive scanner...

/**
* Triggers the scan function for each object given
**/
function recursiveScanner( object:* , scanFunction:Function ):void {

[Code].....

The objects will trigger scans for one another in an eternal loop.

I do believe in C/C++ : Each scanFunction call, will be added into a list consisting of scanned 'memory address', thus preventing a repeat. Is this even possible in AS3? Is there a more elegent way?

View 2 Replies

Actionscript 3 :: Recursive Flex View Component?

Sep 15, 2011

I have a Flex component that is a view of a data Object that recursively has a reference to itself.

For example if you had an Employee class that references a boss field of type Person, I'd like to nest the same view for that Boss. This shouldn't be an infinite recursive relationship (e.g. I'd only be viewing the boss field of each object).

I've tried creating an MXML component that references itself but when I run it locks up (seems like it gets into a recursive loop).

Is there anything you can do like includeInLayout conditions that will make sure it doesn't even instantiate that component.

View 3 Replies







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