-
Using a ForLoop to call an Associative array nested within a Indexed array
In the below code, "sector" is an indexed array.
fsector1, fsector2,fsector3 are Associative arrays.
The "gotoAndStop" command doesnt work properly.
The last trace command, "curTerr" returns the same value as "curSec",
leading me to assume i did not define "curTerr" properly.
Can anybody help with this?
Actionscript Code:
function loadmaptest() { sector = ["fsector1","fsector2","fsector3"]
fsector1 = new Array(); fsector1["terrain"] = "grass"; fsector2 = new Array(); fsector2["terrain"] = "forest";
fsector3 = new Array(); fsector3["terrain"] = "rocky";
for (i = 0; i < sector.length; i++) { trace("loading sector: " + sector[i] + ")"); curSec = sector[i] curTerr = sector[i]["terrain"] (curSec).gotoAndStop(curTerr); trace("loaded: sector(" + curSec + ") Terrain(" + curTerr + ")"); } }
I have also tried:
curTerr = curSec["terrain"]
curTerr = (curSec)["terrain"]
curTerr = [curSec]["terrain"]
Any help would be appreciated. Thanks.
-
Prid - Outing
Actionscript Code:
this[curSec].gotoAndStop(curTerr);
Tutorials to Read:
Explanation of Dynamic Object Access I wrote for someone else
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
-
Thanks, i didnt see that...
I will try this (and read the tutorial if not) and let you know if it works out.
-
thank you for the easy to understand tutorial.
The trace command returns proper values now, but
the gotoAndStop command appears to still not take any effect.
fsector1 , fsector2,fsector3 are all movieclips located at the root level.
"grass", "forest" , "rocky" are the frame labels within those movieclips.
i have replaced: curSec
with : this[curSec]
in both places. The trace command now returns proper values for each variable:
loading sector: fsector1)
loaded: sector(fsector1) Terrain(grass)
loading sector: fsector2)
loaded: sector(fsector2) Terrain(forest)
loading sector: fsector3)
loaded: sector(fsector3) Terrain(rocky)
but i dont know why the gotoAndStop command does nothing still
any help?
-
Actionscript Code:
function loadmaptest() { sector = ["fsector1", "fsector2", "fsector3"];
sector["fsector1"] = new Array(); sector["fsector1"]["terrain"] = "grass";
sector["fsector2"] = new Array(); sector["fsector2"]["terrain"] = "forest";
sector["fsector3"] = new Array(); sector["fsector3"]["terrain"] = "rocky";
for (i=0; i<sector.length; i++) { curSec = sector[i]; trace("loading sector: "+curSec+")"); curTerr = sector["fsector"+(i+1)]["terrain"]; this[curSec].gotoAndStop(curTerr); trace("loaded: sector("+curSec+") Terrain("+curTerr+")"); } trace(sector); }
loadmaptest();
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|