USERNAME:
PASSWORD:
Save Info!
Logging in…
This topic is 1 page long.
[ Profile | Posts | Contact ]
Posted at: 7/26/09 10:22 AM
Sign-Up: 05/15/08
Posts: 488
so I have this code. it is supposed to store the references to them in an array.
for (a=1; a<=3; a++) { var moun:mountain=new mountain(); moun.x=mouncur; moun.y=253.7; moun.name="moun"+a; addChild(moun); mounarray[(a-1)]=stage.getChildByName("moun"+a); trace(mounarray[a])//undefined }
only, it come out undefined. Help!!
Kylelyk: Forwards and Backwards, Over and Out.
Posted at: 7/26/09 10:34 AM
Sign-Up: 08/10/05
Posts: 6,031
At 7/26/09 10:22 AM, kylelyk wrote: mounarray[(a-1)]=stage.getChildByName("m oun"+a); trace(mounarray[a])//undefined only, it come out undefined. Help!!
... You're setting a-1 yet tracing a. Anyway, why bother with all that?
for (a = 0; a <= 3; a++) { mounarray[a] = new mountain(); mounarray[a].x = mouncur; mounarray[a].y = 253.7; addChild(mounarray[a]); trace(mounarray[a]); }
Portfolio(Under construction): UnknownFury.com | Msn: giant_ak_47@msn.com | Contact: me@unknownfury.com Follow me on twitter!
Posted at: 7/26/09 10:44 AM
with that code, can I change the "depth" of the array and will it change all the mc's depths inside it? or do I need to make a seperate container mc to do this?
Posted at: 7/26/09 10:54 AM
An array doesn't have a 'depth', if you're talking about what I think you are. To change the depth of all of them just put them in a holder MC. So change addChild(mounarray[a]); to myHolder.addChild(mounarray[a]);
Posted at: 7/26/09 05:36 PM
Sign-Up: 04/16/04
Posts: 5,542
Right, cba to explain what you're doing wrong, too tired; so i'll show you:
yours:
for (a=1; a<=3; a++) { var moun:mountain=new mountain(); moun.x=mouncur; moun.y=253.7; moun.name="moun"+a; addChild(moun); mounarray[(a-1)]=stage.getChildByName("m oun"+a); trace(mounarray[a])//undefined }
mine:
var mounarray:Array = new Array(3); for(var a:uint = 0; a<3; a++) { var moun:mountain = mounarray[a] = new mountain(); moun.x = mouncur; moun.y = 253.7; addChild(moun); }
My social worker says im special!
All times are Eastern Standard Time (GMT -5) | Current Time: 11:42 PM
<< Back