Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-24-2009, 06:51 PM   #1
turb
Senior Member
 
Join Date: Aug 2003
Posts: 136
Default Instance name of loaded external swf

Hi,

I'm new to AS3 and have successfully loaded an external swf. When load is complete, I add the loader target content to a movieclip but I've got problem accessign it after.

ActionScript Code:
// siteLoaderComplete function siteLoaderComplete(e:Event) { // Set site holder site.x = -500 + 50; site.y = -600 + 100; site.addChild(e.target.content); }

The only problem is that it that right now, it add a child with a instance name of 'instance5' in site. But how can I change 'instance5' for another term like 'myContent'??

I need to be able to access content from the loaded swf.

Thank
turb is offline   Reply With Quote
Old 06-24-2009, 08:26 PM   #2
Slowburn
[Invent:Design:Create]
 
Join Date: Sep 2002
Location: Toronto, ON
Posts: 2,068
Default

When you load an external SWF using the Loader Class, the document class is invoked and is added to the external SWF's stage automatically. because of this, you cannot give the loaded SWF a name. however, the Loader Class can be named and added to the timeline, ad you gain accesss to the external SWF by way of loader.content.

To make you life easier, you could declare a variable that holds a reference to the content of the loader.

ActionScript Code:
var _reference:MovieClip = null; var loader:Loader = new Loader(); loader.name = "externalMovie"; loader.contentLoaderInfo.addEventListener( Event.COMPLETE, handleLoad, false, 0, true ); loader.load( new URLRequest( "ExternalMovie.swf" ) ); function handleLoad( event:Event ):void {      event.target.removeEventListener( Event.COMPLETE, handleLoad, false );      // keep reference to the content      _reference = event.target.content as MovieClip;     // add loader to the display list so we can see the external SWF.      addChild( event.target.loader ); } //now to manipulate the content... _reference.visible = true; _reference.x = 299.99; // or var theLoader:Loader = getChildByName( "externalMovie" ) as Loader; theLoader.content.visible = false; // etc...
__________________
o Please do a search before you post
o Please use the [ as][ /as] tag for your code (so we can read it clearly)
Slowburn is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
loaded external SWF buttons in scrollpane do not work! bigfitz ActionScript 2.0 14 10-13-2008 08:25 PM
Pausing root timeline in external loaded SWF alancan ActionScript 2.0 3 01-24-2007 12:18 PM
Stopping at a certain frame on external loaded swf alexe ActionScript 2.0 1 07-14-2005 04:10 AM
setProperty for loaded external swf JeremyToaster ActionScript 1.0 (and below) 1 10-15-2003 06:11 AM
Timeline Control in loaded external swf Sonor ActionScript 1.0 (and below) 5 08-28-2003 03:48 AM


All times are GMT. The time now is 11:35 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.