Jump to content
Search Community

Call Parent Doc Class Public Function from Child

Multi-Task test
Moderator Tag

Recommended Posts

Trying to unload a child SWF by calling the parent document class function from the child document class...

 

Loading as such from Main Document class: (SWF loads and plays fine)

if(currAsset is SWFLoader){
	container_mc.addChild(currAsset.rawContent);
	currAsset.rawContent.gotoAndPlay(1);
	
}

Also, within Main Document Class:

public function swfFinished():void {
	var currAsset = media.getChildAt(mediaTracker-1);
	currAsset.content.visible = false;
	currAsset.rawContent.gotoAndStop(1);
	container_mc.removeChildAt(0);
	currAsset=null;
	//set up and play the next swf
	managePlayBack();
}

Then -

From the Child SWFs Main Document Class:

This function is fired once the SWF is done (last frame of SWF calls this), this fires but doesnt trigger parent function of swfFinished().  

private function done():void {
	var curParent:MovieClip = this.parent.parent.root as MovieClip;
   	curParent.swfFinished();
}

Any ideas?

 

Link to comment
Share on other sites

From the child swf, this.parent says its referencing the stage.  

 

so this.parent.parent should be the container_mc?  

 

adding another parent (this.parent.parent.parent) should be the stage of the parent application?

 

but what about the document class of that parent?  :/

 

I should add that these sub SWFs are being loaded into an AIR app.  SWFs are pulled from Server...  Am I even able to access the public functions within the AIR app from the loaded SWFs?

Link to comment
Share on other sites

Thanks Carl for helping out...

 

So I added a simple text field on stage to try to determine what is being referenced and for displaying errors.

 

Environment:

AIR app runs on desktop and loads in externally hosted SWF files.  This all works great since I have a crossdomain policy in place.

 

However; after your suggestions.  I am getting a #2047 error.  Any ideas?  Is it not possible to call public functions of an AIR app from externally hosted SWFS?

private function showSomething():void {
	try {
		this.dText.text = "parent  " + MovieClip(this.parent.parent.parent.parent);
	} catch(e:Error) {
		this.dText.text = e.errorID+"\nError Message : "+e.message;
	}
			
}
		
private function done():void {
	this.dText.text = "done";
	var curParent:MovieClip = this.parent.parent.parent.parent as MovieClip;
   	curParent.swfFinished();
}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...