Jump to content

Search In
  • More options...
Find results that contain...
Find results in...

how to use xml-loaded variables in loaded swf?

Recommended Posts

This one has got me stuck for quite some time now:


I'm using an XML-file to load up my LoaderMax queue, which is working just fine. What I would like to do is send the value of the extra variable ('category' in the XML below) in the XML file on to the loaded swf. This is my XML-file:

<?xml version="1.0" encoding="iso-8859-1"?>
<SWFLoader url="bump_worldclock.swf" load="true" noCache="true"  />
<SWFLoader url="cont_nu.swf" load="true" noCache="true" category="binnenland" />

Loading the 'cont_nu.swf' file onto the stage is no problem at all. Referencing to the value of the added variable works just fine. Sending the value of 'category' to that SWF (or fetching the value from within the SWF) does not work unfortunately. This is my code up to this point:

var mc:Object = currentLoader.content;
var cat:String = currentLoader.vars.category;

I suspect there to be an easy solution to my problem. But not easy enough to solve with a Google search.


Any help would be greatly appreciated! Many thanks in advance!





Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.


I would suggest having the parent swf figure out the category and tell the child swf what to do.



<SWFLoader url="pass-data-child.swf"  load="true"  x="0" y="0" category="automobiles" />


ActionScript in parent swf:

import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.*;
import flash.display.Sprite;
import flash.display.MovieClip;


var queue:XMLLoader = new XMLLoader("xml/data.xml",{name:"xmlDoc", 


function imageCompleteHandler(event:LoaderEvent):void
var loaded:ContentDisplay = event.target.content as ContentDisplay;
//populate a text field in the child swf with the property category name
loaded.rawContent.category_txt.text = event.target.vars.category

child swf: contains no code, only a blank textfield called category_txt



see demo attached 


Link to comment
Share on other sites

WOW! This is what I call some great advice! Thanks a million for the example. Turns out it was the 'rawContent' bit that solved it for me. Thanks again!

Link to comment
Share on other sites

Great. You're welcome.

Glad to hear it worked.

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.