Jump to content
Search Community

accessing sibling swf

alflasy test
Moderator Tag

Recommended Posts

Hi,

I am not sure if this question is specific to loaderMax but I am sure loaderMax will have better way to handle it so posting it here.

 

I have loaded two external swf. like this

 

<config>
<swfloader  name="module" url="module/module.swf" estimatedBytes="66000" load="true"  x="0" y="0" />
<swfloader  name="control" url="skin/controller.swf" estimatedBytes="78000" load="true"  x="0" y="0" />

</config>

 

Now the swf are loaded in parent and I want to dispatch event from controller to module SWF.

I tried different ways but can't efficiently target the swfs on its parent as it doesn't have any instance name.

 

something like

trace(controllerTimeline.parent.module)
or
trace(controllerTimeline.parent.getLoader('module'))
or
trace(controllerTimeline.parent.loaderMax.getContent('module'))
or
trace(controllerTimeline.parent.configLoader.getContent('module'))

 

All those throw error.

 

Thanks

Link to comment
Share on other sites

As long as you import LoaderMax in your controller.swf you can use LoaderMax to target module.swf

 

I made a basic example where module.swf is a simple looping animation and controller.swf has a single stop button. Both swfs are loaded into a parent swf.

 

This is the pertinent code in controller.swf:

 

 

import com.greensock.loading.*;

stop_btn.addEventListener(MouseEvent.CLICK, stopClick);

function stopClick(e:MouseEvent):void{
   trace("click");
   trace(LoaderMax.getLoader("module.swf")); // SWFLoader 'module' (module.swf)
   trace(LoaderMax.getLoader("module")) // SWFLoader 'module' (module.swf)
   trace(LoaderMax.getLoader("module").rawContent); // [object MovieClip
   var moduleSWF = LoaderMax.getLoader("module").rawContent;
   moduleSWF.stop();
}

 

Attached is a zip of module.fla, controller.fla and module_controller_demo.fla all saved as Flash CS5.

module_controller_CS5.zip

Link to comment
Share on other sites

  • 2 weeks later...

First of all thanks again for all your help.

 

Down the path of accessing siblings I have two new roadblocks and I am sure LoaderMax can easily handle that.

All the above example shows to trace the sibling SWFs but now I want to get XML from sibling SWFs

 

Like how can I get controller xml from module.swf.

and then I also want to switch the indexes of of siblings. I am guessing that can be simple setChildIndex() from parent.

Link to comment
Share on other sites

I'm not sure what you mean by controller xml. Is controller.swf loading its own xml?

 

Or are you talking about xml that is nested inside your SWFLoader node?

 

If the latter, as long as module.fla is importing the greensock loading classes (as shown in controller.swf code above), you can use LoaderMax.getContent() or LoaderMax.getLoader() to find any loader or its content that has been loaded.

 

As discussed in another thread, you can find the rawXML of your controller SWFLoader.

 

Again, I don't know exactly what you need to do but you know how to:

 

1: target 1 child swf from another child swf

2: find the rawXML of an ImageLoader or SWFLoader

 

Just try to glue those 2 concepts together within your project setup.

Link to comment
Share on other sites

Sorry for confusion. I tried diffrerent method that we discussed in other thread but didn't worked. Let me explain again.

 

I have parent SWF and that is loading two swf child. Now I want to get the raw xml of one child to another.

 

trace(LoaderMax.getLoader("module").rawContent);// [object movieclip]

trace(LoaderMax.getLoader("module").rawXML);// undefined

trace(LoaderMax.getContent("module").rawXML);// undefined

trace(LoaderMax.getLoader("module"),vars.rawXML);// undefined

 

 

So the above code get me the sibling SWF but when I try to get the xml of sibling it failed. May be I can set xml in variable in one child and then get it. Not sure but will try.

 

Thanks

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...