View Full Version : How to get _root Array data from inside a deep MC hierarchy
Spongebob
August 8th, 2002, 05:40 PM
I have some global Arrays defined and loaded with data at the _root level. Data is OK cause I checked it with the List Variables option.
I cannot address any of my arrays from within my MC hierarchy (not from MC2, MC1 or Component MC), BUT I can address variables defined at the root level correctly !!! Why??:
MC Hierarchy: ComponentMC-->MC1-->MC2-->Various MCs
I placed trace(_root.MyArray[0]); at MC2 level, then at MC1 level and finally at ComponentMC level but the sentence still reads "undefined".
Is there a way to actually get my Arrays data from _root ?
Do while true
"Thanks"
Loop :)
Spongebob
iceman
August 9th, 2002, 03:12 AM
If you defined global arrays then it should read _global.myArray[0] rather then _root, because arrays follow hierarchy. If its on the _root timeline make sure but if its global just use the _global property, thats probably whats causing you problems.
Hope this helps
Kyle:)
Spongebob
August 9th, 2002, 10:00 AM
It's not working yet :(
I've defined this at _root level:
_global.MyArray = new Array();
... and loaded it with data from a textfile.
If I check loaded data in the List Variables option it reads as follows:
Variable _global.MyArray = [object #33, class 'Array'] [
0:"Argentina",
1:"Uruguay",
2:"Brasil",
3:"Chile",
4:"Paraguay"
]
My MC hierarchy is this (where Component MC is at _root level):
ComponentMC-->MC1-->MC2-->Various MCs
Then, I want to address MyArray from MC2 so I write in the first frame at MC2 level :
trace(_global.myArray[0]);
According to MyArray data displayed before, _global.myArray[0] should display "Argentina"...
BUT it still displays "undefined".
Am I doing something wrong ?
Thanks in advance,
Spongebob
designdrumm
May 18th, 2007, 05:33 AM
Hello, I am new here, but I read your post and I had a suggestion avbout your text file.
Is this what is in your text file?
Variable _global.MyArray = [object #33, class 'Array'] [
0:"Argentina",
1:"Uruguay",
2:"Brasil",
3:"Chile",
4:"Paraguay"
]
If it is you may want to set your text file up to read a such:
&MyArray=0:Argentina, 1:Uruguay, 2:Brasil, 3:Chile, 4:Paraguay
or if your numbers are suposed to be variables then:
&MyArray=&0=Argentina, &1=Uruguay, &2=Brasil, &3=Chile, &4=Paraguay
I don't have your files so I cant test this myself. Try it out and let me know if it works for you.
:D
DD
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.