Forum Topic: Initiating array prob

(59 views • 5 replies)

This topic is 1 page long.

<< < > >>
None

dogdgey5

Reply To Post Reply & Quote

Posted at: 10/18/08 09:06 AM

dogdgey5 EVIL LEVEL 07

Sign-Up: 03/08/08

Posts: 128

hello. I have a problem with initiating an array for another movieclip. For example, a movieclip with an instance name of MC, and a variable number of type of number named varia, can be initiated by:

_root.mc.varia = 5;

Given that varia exists on that MC.
How do I do this for an array? I tried this on the MC:
var arr:Array;

and this on another movieclip:
_root.mc.arr.push(5);

when I traced arr[0] on the first movieclip, it was undefined. What do I do?


None

WolfAkela

Reply To Post Reply & Quote

Posted at: 10/18/08 09:08 AM

WolfAkela LIGHT LEVEL 08

Sign-Up: 12/19/05

Posts: 2,327

var arr:Array = new Array();


None

dogdgey5

Reply To Post Reply & Quote

Posted at: 10/18/08 09:19 AM

dogdgey5 EVIL LEVEL 07

Sign-Up: 03/08/08

Posts: 128

ty but still doesnt work. here's what I have for the 'initiation' of the movieclip's array:

for (q=0; q<arr.length; q++) {
_parent[_root.bullN].arr.push(arr[q]);
}

ignore the _parent[_root.bullN] part. both movieclips have an array with a name of arr, so it might be confusing. But what I want is for the second movieclip's arr to recieve all of the first movieclip's arr variables.


None

WolfAkela

Reply To Post Reply & Quote

Posted at: 10/18/08 09:49 AM

WolfAkela LIGHT LEVEL 08

Sign-Up: 12/19/05

Posts: 2,327

But what I want is for the second movieclip's arr to recieve all of the first movieclip's arr variables.

It's as simple as array2 = array1, so it's just like:
_root.mc2.arr = _root.mc1.arr;


None

mayoarm11

Reply To Post Reply & Quote

Posted at: 10/18/08 10:27 AM

mayoarm11 NEUTRAL LEVEL 17

Sign-Up: 06/13/07

Posts: 1,013

At 10/18/08 09:49 AM, WolfAkela wrote:
But what I want is for the second movieclip's arr to recieve all of the first movieclip's arr variables.
It's as simple as array2 = array1, so it's just like:
_root.mc2.arr = _root.mc1.arr;

ok, but it still doesn't work. god this is annoying.

this is what I have for the 1st MC:
var arr:Array = new Array();
arr.push(ind);
trace(arr.length);

and for the second:
_parent[_root.bullN].arr = arr;

and that trace always traces 1, meaning only the push function worked, and the initiation of the arr didnt work.

Awesome turret game in the making, featuring 85 uniqe turrets: News post

BBS Signature

None

WolfAkela

Reply To Post Reply & Quote

Posted at: 10/18/08 11:18 AM

WolfAkela LIGHT LEVEL 08

Sign-Up: 12/19/05

Posts: 2,327

Huh... you did declare an initialize the second MC's arr with = new Array(), right?

From the code, if it traced "1", it means first MC's array is fine. Trace the array of the second MC and see if it's fine.


All times are Eastern Standard Time (GMT -5) | Current Time: 07:49 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!