PDA

View Full Version : passing data from main timeline to function within mc


Scuba_Steve
08-17-2007, 06:14 PM
dunno why this is giving me such a hard time...

i've got code on the main timeline that defined the path to an xml file. i need to then load that xml into a textArea component that is inside a SWF file that i loaded into an empty MC on the MAIN timeline.

confused? good - me too.

no matter what i do, i can't seem to trigger the xmlObject.onLoad method though in the swf i loaded into the empty mc.

my empty MC is called "topic_holder_mc" and loaded into it is "overview.swf". within that swf is the textArea object and all the code required to load XML into that object. the xml object's onLoad function is called "loadTrainingTopic(xmlPath)";

would someone for the love of God please help me here. :) i can't seem to send a value (xmlPath) to that function or even trigger it for that fact. i know the paths are correct regarding what xml to fetch from where, as i've added a trace statement to the onLoad and can't even get it to output so i know i'm not even reaching the function.:p

Scuba_Steve
08-17-2007, 06:16 PM
i've tried about a zillion variations of:

topic_holder_mc.loadTrainingTopic("path/to/xml");

ooh... maybe topic_holder_mc.xmlObject.load("path/to/xml"); ??? giving it a shot...

**edit - no dice**

matbury
08-19-2007, 03:13 AM
What does this return?

xmlObject.onLoad = function():Void{
trace("xmlObject has loaded");
};
xmlObject.load("path/to/xml");

matbury
08-19-2007, 03:23 AM
Another possibility is that if you're loading an external SWF into your movie, it isn't loading completely and initialising when the XML has loaded and parsed. You'd have to trigger the xml.load() after the SWF has load and initialised.

Check out the MovieClipLoader class for loading your SWF and use the oListner.onLoadInit() method to trigger the xml.load() method:

var myMCL:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();

myListener.onLoadInit = function():Void{
myXML.load("path/to/xml");
};

myMCL.loadClip("mySWF.swf", topic_holder_mc);

myMCL.addListener(myListener);