PDA

View Full Version : Calling child movie methods from a parent movie [MX]



_hopesfall
June 16th, 2003, 05:25 AM
Hi...

I'm working on a Flash MX application which involves a Parent movie and a Child movie.

I've loaded the Child movie into the Parent movie using LoadMovie. The instance name of the Child movie is Child1.

In the Child movie I have a user-defined function called getChildXML (we don't need to get into more details about the function).

The point here is that I want to call the getChildXML function from the Parent movie. Is that possible? I've tried something like Child1.getChildXML(); but with no luck.

Please help!

Thanx.

senocular
June 16th, 2003, 05:55 AM
_parent

is used to reference a parent movieclip. In your movieclip Child1,

trace(this._parent);

would output the Parent clip. If your getChildXML is a straight function in that Child1 (and not an XML proto or something) then using this._parent will refence the Parent clip.

_hopesfall
June 16th, 2003, 06:03 AM
Thanx for the reply. But it doesn't solve my problem. I want to call getChildXML from the Parent clip and not vice-versa. Is it possible to access a child movie's methods from a parent movie?

senocular
June 16th, 2003, 06:46 AM
ooo I misread

Child1.getChildXML doesnt work? Are you sure the clip is fully loaded when you try to call it?

_hopesfall
June 16th, 2003, 07:32 AM
Okay, this is what I'm trying to do, the getChildXML function constructs and returns a string (which is some XML). I want to call this function from the Parent movie.

I wrote

strXML = child1.getChildXML();

when I try something like

trace (strXML);
or
trace(child1.getChildXML());

I get "undefined" in the output window.

I am writing this code in the first frame of the parent movie using this.onEnterFrame.