Why not use:
var myMovie_mc:MovieClip = attachMovie("itemDivider", newItemDividerName
,x);
Then you can set the properties by doing:
myMovie_mc._x = nextItemDivider ;
Giles
P.S. Best to stick to one subject name for each question on the list
because the list archive will then be able to tie the discussion
together when searching
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jon
Sent: 02 August 2006 13:45
To: [email protected]
Subject: [Flashcoders] New to the list - got a question
Hi All,
I'm new to the list, so appologies if I don't get the posting right on
this - but I have a question.
I'm trying to load in a set of XML data, manipulate it and then get it
to display on the stage. So far so good on the first two fronts - I can
get the data in and get everything I want out of it.
Now the amount of XML is dynamic, so I have pushed the needed data into
an array.
For example.
XML:
<xml>
<data>
<item></item>
</data>
<data>
<item></item>
</data>
</xml>
The amount of "data" elements is dynamic (and there is a lot of other
rubbish in the XML) so I've pushed all the "data" elements into an
array.
So far, so good, I can cycle through the array and access the XML
elements using Xpath.
The problem is - for each "data" element, I want to create a new
instance of a MovieClip on the stage (thats already created in the
library) and set varaibles inside it, and change it's X and Y positions.
No problems creating it - but I can't access the MovieClip! Because the
data is dymanic, I need to be able to create "x" amount of MovieClips.
So I'm using the following code to do this:
//For each Data Element in the Array (x = 0; x < numDataElementsInArray;
x++) {
var newItemDividerName:String = "itemDividerStageRecord" +x;
attachMovie("itemDivider", newItemDividerName ,x);
//Now this all works, a newMovieClip is created on the stage (for as
many elements as I have), 10 at the moment
}
Now the problem is - I then can't access the MovieClip dynamically.
Basically I want to be able to access it by the variable name i've just
assigned it.
For example - I now have (when it is published), 10 elements on level0,
named itemDividerStageRecord0-9.
So I want to set their cords. So what i've been doing is:
_root._level0.newItemDividerName._x = nextItemDivider; //nextItemDivider
is a Number which does increment
And thats not working at all - nothing is changing.
I've traced it down to the name I'm using to access it - if in the same
loop I put:
_root._level0.itemDividerStageRecord6._x = nextItemDivider;
That works for one MovieClip (obviously).
But I want to be able to access each MovieClip dynamically.
Is there any way to do this? I want to pass the instance name the
varaible when setting the cord, not use the absolute element name
"newitemDividerName".
Please let me know if this is confusing, I can explain better!
Cheers.
-Jon-
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com