Jump to content
Search Community

Loading Specific Movie Clips From SWF Using XML

Buzzafett test
Moderator Tag

Recommended Posts

Hi,

 

Not exactly sure if I understand the question completely but perhaps this will help:

 

1) You can store the names of symbols you want to use in an xml file and LoaderMax can load that XML file. Once the xml is loaded you can then use those symbol names to in conjuction with SWFLoader's getClass() method to instantiate symbols from the loaded swfs library.

 

Below is some code that shows how to grab an item out of a loaded swf's library:

 

loadLibraryItem.fla AS3:

 

 

import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;

//load the swf that contains the symbols you want to use:
var librarySWF:SWFLoader = new SWFLoader("assetsLibrary.swf", {onComplete:completeHandler});

librarySWF.load();


function completeHandler(e:LoaderEvent):void {
//create a reference to the class (library item) in your external swf that you want to use
var librarySymbol:Class = librarySWF.getClass("RedCircle");
trace(librarySymbol);

//this will create an instance of your class
var myInstance:MovieClip = new librarySymbol();
addChild(myInstance);
myInstance.x = myInstance.y = 100;
}

 

assetsLibrary.swf has a symbol in the library with a class name of RedCircle.

 

I have a attached a zip of CS5 files that use the code above. Open loadLibraryItem.fla to see it in action. (use your own greensock files).

 

Hopefully this gets you close to what you need. If not, let us know.

 

-c

loadLibraryItem_CS5.zip

Link to comment
Share on other sites

Hi,

 

Sorry that my answer didn't suffice. I still don't know what you mean "via XML".

The LoaderMax don't have any single component that to handle what I think you mean.

I can only assume now that you need something much more elaborate.

 

At a bare minimum you need to:

  • create an xml file listing all the symbol names
  • use an XMLLoader to load the xml
  • when the xml is done loading parse out a list of symbol names
  • load the assets swf and wait for it to fully load
  • loop through the list of symbol names and instantiate they symbols from the loaded swf

That could all take a few dozen lines of code and still wouldn't cover everything.

Which part is giving you trouble?

Unfortunately we don't have any examples like that on hand. It would really help to be able to focus in on which parts of the GreenSock tools you need more help understanding to help you get through this project.

 

If you need some sort of XML quick-start guide, I strongly recommend:

http://www.republicofcode.com/tutorials/flash/as3xml/

Link to comment
Share on other sites

  • 4 weeks later...

Hi Buzzafett,

 

Yes, I understand because i'm after the same solution. I'm trying to call a movieClip from the Flash library using XML.

 

i.e. Instead of 'test.swf' loading, i'm wanting to call a movieClip from the same library as the .fla.

 

<?xml version="1.0" encoding="UTF-8"?>

<all>

<GROUP>

<IMAGE>test.swf</IMAGE>

<QUESTION>Example #1</QUESTION>

<OPTION1>Example</OPTION1>

<OPTION2>Example/OPTION2>

<OPTION3>Example</OPTION3>

</GROUP>

</all>

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