Share Posted October 25, 2011 I swear I saw how to do this a while ago - but I have searched the forums to no avail, maybe someone can offer some help. Im using loadermax to read an XML file of SWFLoaders. If I use the setting of maxconnections of 1 things load sequentially and all is good. I store the loader names in an array (using array.push(event.target.name) in the child complete function and play them as needed later on However If I set it to max connections of 3 - some complete loading before others, and the array ends up out of order. An easy way around this is to just add an index to each loader. Right now one of the XML nodes look like this : What I would like to do is this : Then be able to read that index variable in the child complete function. (The work around Im using right now is to just parse the name at the _ and use the number as the index - but Id like to remove that constraint.) Thanks Rob Link to comment Share on other sites More sharing options...
Share Posted October 25, 2011 A few comments: 1) You can getChildren() on the XMLLoader anytime which returns an array of the child loaders that it discovered/parsed in the XML. Those will be in order (it doesn't care if load="true" or not). So the index would correspond to the placement in the array of course. If you've got stuff nested inside nodes, etc., that's fine too - you can just get that particular LoaderMax instance by name and then getChildren() on that LoaderMax. Like if your XML was: And let's say you wanted to get the children (in order) of queue2. You'd do: var queue2Children:Array = LoaderMax.getLoader("queue2").getChildren(); 2) Or, you can add extra data to your nodes in the XML and it will automatically get added to its "vars" property... Then, you can get the index in ActionScript like: var index:int = int( LoaderMax.getLoader("swf1").vars.index ); Notice I cast it as an int() because by default, any extra values parsed in the XML will be Strings. Does that help? Link to comment Share on other sites More sharing options...
Author Share Posted October 25, 2011 Yup - exactly what I was looking for - It was the referencing it via vars that was jacking me up. Exactly what I needed. Thanks -Rob Link to comment Share on other sites More sharing options...
Share Posted August 1, 2016 Hi Jack! I know it is an old post... But can you help me? Maybe it´s usefull to another mate still doing AS3... It works perfect in my proyect but... What if I wanted to dynamically change param1 and param2, after they are loaded? I have tried but haven't succeed on updating the vars! Cheers! Robert. Link to comment Share on other sites More sharing options...
Share Posted August 1, 2016 HI Robert, It isn't clear to me exactly what you are trying to do. if you have custom parameters in your XMLLoader nodes they will get attached to the vars object for the loaders. Please read the XMLLoader docs http://greensock.com/asdocs/com/greensock/loading/XMLLoader.html where the 4th code snippet describes how the "description" attribute is placed on the VideoLoader and then later read via loader.vars.description. You should be able to read and write any property of the vars object. Link to comment Share on other sites More sharing options...
Share Posted August 3, 2016 Hi Carl! Thanks for your reply! Ok I wasn't clear enough... I´m trying to pass and update a variable to a swf loaded by SWFLoader. For instance update a text field, included in the loaded swf. It works if the swf is loaded in the standard way. This is what I wrote: var Pisadaloader: SWFLoader = new SWFLoader("assets/Pisada_mc.swf", { name: "PisadaMc", alpha: 0, estimatedBytes: 1000, container: pisada_null_mc, width: 720, x: 0, y: 580, autoPlay: true }); addChildAt(Pisadaloader.content, 1); Pisadaloader.load(); Titulo = myXML.VIDEO.@TITULO; SubTitulo = myXML.VIDEO.@SUBTITULO; param1 = myXML.VIDEO.@NUMTXT; param2 = myXML.VIDEO.@NUM; this.Pisadaloader.Titulo_text.text = Titulo; this.Pisadaloader.SubTitulo_text.text = SubTitulo; Link to comment Share on other sites More sharing options...
Share Posted August 3, 2016 Ok. The example you just provided showed how to update variables (or text in a TextField) after the swf is loaded. What do you need to do differently? Link to comment Share on other sites More sharing options...
Share Posted April 9, 2018 On 03/08/2016 at 2:15 PM, Carl said: Ok. The example you just provided showed how to update variables (or text in a TextField) after the swf is loaded. What do you need to do differently? Hi Carl, sorry for this old thread, but I am not able to pass arguments to my SWF by loader. Can you help me please? My AS3 code: var mySwfLoader:SWFLoader = new SWFLoader(path, {name:'swf', container:this, width:stage.stageWidth, height:stage.stageHeight, alpha:0, bgColor:"0x000000", autoDispose:false, onComplete:function(event:LoaderEvent){ mySwfLoader.item1.text = 'TEST THIS'; timeline.add(TweenLite.fromTo(event.target.content, 2, {alpha:0, ease: Power0.easeOut}, {alpha:1, ease: Power0.easeOut}),"+="+1); } }); My .FLA and .SWF to test this: https://www.dropbox.com/sh/ecihnnzgsvpw8dr/AABQuLXV9aXfWgxeVJb8gZ9Ia?dl=0 The SWF is loaded and showed correctly, but I can not change the text of the SWF. Thanks a lot Carl. Link to comment Share on other sites More sharing options...
Share Posted April 9, 2018 Hi lwmirkk, Sorry but we really don't have a lot of time to be supporting the old AS3 loader stuff. From looking at your code it looks like you are thinking that the mySwfLoader has a TextField on it called "item1". mySwfLoader.item1.text = 'TEST THIS'; I'm gussing item1 is in the actual swf you loaded so try targeting the rawContent of the SWFLoader like mySwfLoader.rawContent.item1.text = 'TEST THIS'; https://greensock.com/asdocs/com/greensock/loading/core/DisplayObjectLoader.html#rawContent 1 Link to comment Share on other sites More sharing options...
Share Posted April 16, 2018 On 4/9/2018 at 2:54 PM, Carl said: Hi lwmirkk, Sorry but we really don't have a lot of time to be supporting the old AS3 loader stuff. From looking at your code it looks like you are thinking that the mySwfLoader has a TextField on it called "item1". mySwfLoader.item1.text = 'TEST THIS'; I'm gussing item1 is in the actual swf you loaded so try targeting the rawContent of the SWFLoader like mySwfLoader.rawContent.item1.text = 'TEST THIS'; https://greensock.com/asdocs/com/greensock/loading/core/DisplayObjectLoader.html#rawContent Thanks a lot Carl. ? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now