actionscript 3 - Dynamically calling array value by index number -
i'm having trouble calling values of array using index number dynamically. i'm trying name of movieclip dynamically each time loop calls. code:
public var allitemsunlockedtc:array = new array("itemwrench", "itemsc", "itemvoltmeter", "itemgloves", "itemstirespray"); for(var tcitems:int = 0; tcitems < allitemsunlockedtc.length; tcitems++) { trace("tcitems length: " + tcitems); trace("values: " + allitemsunlockedtc.valueof([tcitems])); /*getchildbyname(allitemsunlockedtc.valueof(tcitems) movieclip).x = par.toolcloset.kast_1.slottc1;//getchildbyname("slottc" + (tcitems + 1)).x + 400; getchildbyname(allitemsunlockedtc.valueof(tcitems) movieclip).y = par.toolcloset.kast_1.slottc1;//getchildbyname("slottc" + (tcitems + 1)).y + 245; getchildbyname(allitemsunlockedtc.valueof(tcitems) movieclip).gotoandstop(2); //getchildbyname(allitemsunlockedtc.valueof(tcitems)).name = ("slottc" + (tcitems + 1)); notinventoryparenttc.addchild(getchildbyname(allitemsunlockedtc.valueof(tcitems) movieclip));*/ }
instead of getting values 1 one in ascending order, values @ once every time loop calls.
how call value index using loop ?
thanks in advance,
milan
nevermind, solved it.
trace("values: " + allitemsunlockedtc[tcitems]);
stupid question xs
you want item @ specific index. in actionscript done this: yourarray[index]
. don't use valueof
.
so like:
trace("values: " + allitemsunlockedtc[tcitems]);
Comments
Post a Comment