As a Delphi developer moving over to FlashMX2004 I am having trouble with a fundamental process. Here is what I am trying to do:
load an xml from a specified URL. parse it within an onLoad function.
the xml contains a random number (up to 20) of sibling nodes. Parsing each node causes a new custom object (same class every time) to be created and relevant properties (text and numeric) to be set.
I then create a new movieclip and load it with an image loaded from a URL specified as a property in the xml.
SO FAR SO GOOD, MOVIECLIPS CREATED AND VISIBLE.
[*]I then set Mouse.addListener and onMouseDown, onRollOver and onRollOut events for each instance.
My problem is that although the events fire, they either use ONLY the last created instance or cause errors because the reference is ‘undefined’.
I understand that there is a known ‘feature’ in Actionscript which means that the functions use the current value of any variable used in the initialisation loop, rather than the value appropriate to the instance at the time of creation.
Can anyone point me to a quick example where multiple instances of an object (and child movieclip) are created in a loop and assigned mouse events?
Thanks in advance