Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by alflasy

  1. Hi, I am something really weird going on. I am loading an images from xml file and there is one large image in xml that is loaded only when the user click a button. So I am using getContent and get Loader to get image and then display.The weird this is that it doesn't work on first load in browser it works after the browser is refreshed. It works locally fine. It just doesn't work when I clear the browser cache and load the app. I know where it is breaking but I don't know why and so can't really fix it. It thought its my machine and network but its happening in client machine and location too. Here is the code snippet ExternalInterface.call("console.log", LoaderMax.getLoader(url)+'___getLoader'); ExternalInterface.call("console.log", LoaderMax.getContent(url)+'___getContent'); var imgName:ImageLoader = LoaderMax.getLoader(url) var lgImg:ContentDisplay = LoaderMax.getContent(url); ExternalInterface.call("console.log", '===================SUCESS============='); So first two call always success and this third call only success after the page is refreshed or I disable browser cache in firebug net tab. Also let me tell you what I do to load the image after its succeed. So on a click event I just add imgName.load(true); addChild(lgImg); Amazingly I have a similar scenario in my app and I am loading a SWF from the same XML file and it works great no issues using the same method but in different class.
  2. I think I got it now. the below code works for me but not sure its the right way to do it. function moduleXMLLoaderInit(event:LoaderEvent):void { var getChildrenNum = moduleXMLLoader.getChildren()[0].getChildren(); for(var ch=0; ch<getChildrenNum.length;ch++){ if(getChildrenNum[ch].vars.rawXML.@remove== 'true'){ getChildrenNum[ch].dispose(true) } } }
  3. So,I tried to dispose the xml child in InIt event but it thows error not not sure if that can be done below is my code function moduleXMLLoaderInit(event:LoaderEvent):void { //trace("init " + moduleXMLLoader.content.children().@remove); // Works var getChildrenNum = moduleXMLLoader.content.children(); for(var ch=0; ch<getChildrenNum.length();ch++){ trace(getChildrenNum[ch].@remove)// WOrks if(getChildrenNum[ch].@remove== 'true'){ getChildrenNum[ch].dispose(true);//ERROR } } ERROR TypeError: Error #1006: value is not a function. at module_fla::MainTimeline/moduleXMLLoaderInit() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at com.greensock.loading::XMLLoader/_receiveDataHandler() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at flash.net::URLLoader/onComplete() I tried getChildren() but that didn't work in Init event. As I think it expecting the children name as parameter and it cannot be predicted in my case.
  4. Hi, I am streaming sound on frames in a moviclip and its placed on stage. The movie runs with below code but no sound as soon as I comment out the code and run this movie without TimelineLite and it play and sound fine. Attached FLA too sndcoin.stop(); var tl:TimelineLite = new TimelineLite(); tl.append(new TweenMax(sndcoin, 10, {frame:200}));
  5. Yes, the error is due to this line. event.target.vars.rawXML.dispose(true) Actually I don't want to load any content from that XML node. Like if I have total 10 slides then when reload a function will look for remove attribute if two found then it should only load 8 slides. So when I just disposed event.target then image is removed but the content is loading and so the slide number stays same. Thats why I am disposing XML node.
  6. Got it and working but also throwing error. any idea? function imageLoadComplete(event:LoaderEvent):void { if(event.target.vars.divsn){ trace(event.target.vars.rawXML) event.target.vars.rawXML.dispose(true) } } I thought onInit would be best place to dispose that part of XML but was not able to get attribute and target the XML node to remove. Thanks
  7. Hi, I know I wanted to this but not sure when and now its the right time to ask after spending three hours of searching. I am loading bunch of images through xml file. Its a slide by slide images with information. While user is browsing at slide 5 users are ask to select division. After the division is selected and submit button is hit the slide show is reloaded with same slide except some. So, I want to remove some images from images on fly without editing the XML. I was looking in to remove() but can't find much information about how to do that. Here is my xml file and I want to remove all the image that has attribute remove=true <ImageLoader name="img_1" url="5.jpg" remove='true'></ImageLoader> <ImageLoader name="img_2" url="6.jpg"></ImageLoader> <ImageLoader name="img_3" url="7.jpg" ></ImageLoader> <ImageLoader name="img_4" url="8.jpg" remove='true'></ImageLoader? Thanks
  8. Wow, that's good to know. I can change the name of course at one place to some thing else. By getting rawContent I was just trying to have access to course swf so that I have access to all public vars and function which now I know I can still get it by using Object(parent.parent.parent). But its still curiosity why I cant access it by getting rawContent as I use to do it in my last project where I was not using document classes.
  9. Thanks Carl, that worked. I tried earlier without static but it didn't worked because I was targeting parent.parent.preant as sprite and not as object. But what about the rawContent? I still can't access it. trace(LoaderMax.getLoader("course").rawContent);//Error
  10. Hi Carl, thanks for your quick response. I tried to make it as basic as possible and attached it. Please let me know what you think. documetClassTest.zip
  11. Hi, I had great time working on my last project with loader max and thanks Carl for all help. Last time it was my first project so I was not messing around with custom classes and all goes well. In this new project I am work with custom document classes where I parent with document class and its loading child swf with XML loader and chlid swf has its own document class. So document class on parent have variables like this as all classes have public class course extends Sprite { private var courseXMLLoader:XMLLoader; private var courseSWFs; private var targetSWFs; public static var tests = 'tessssst' public function course () { ///code here.... } Now I have succesfully loaded swf and swf has similar class which is trying to get the value of tests. It sound like regular action script and nothing to do with loaderMax. But I can get the var tests when I not using Loadermax but I have issue when I am using loaderMax. So here is the code that fails in child document class public class slideModual extends Sprite { private var slideXMLLoader:XMLLoader; private var menuFormat:TextFormat = new TextFormat(); private var ansHolder:Sprite; public function slideModual() { this.addEventListener(Event.ADDED_TO_STAGE, thisAddedToStage ) } private function thisAddedToStage(e:Event){ trace(Sprite(parent.parent) // Trace - Sprite on parent trace(Sprite(parent.parent).tests) // Trace - ERROR trace(LoaderMax.getLoader("course")); //Trace - LoaderMax 'course' trace(LoaderMax.getLoader("course").tests); //Trace - ERROR trace(LoaderMax.getLoader("course").rawContent); //Trace - ERROR } } } Any Idea please I can easily get it work when these traces on frame but not in document classes. Thank you
  12. Yep, did it. Appreciate all you help Carl and it works like a charm. Great Plugin with excellent support.
  13. Thanks Carl, Great reply. All my problems are fixed with the below code in course.fla function onInit(e:LoaderEvent):void{ //note module2.swf will be behind module.swf addChild(LoaderMax.getContent("module2.swf")); addChild(LoaderMax.getContent("module.swf")); addChild(bar); } function completeHandler(e:LoaderEvent):void{ trace("courseXMLLoader *** COMPLETE ***"); //trace(e.target.content) } Now I get the stage and the onComplete event is fired last. Still have few question. As you said I don't have to use the image holder and I agree, that's the power of LOADERMAX, but still I need to use it as I have lot of content that needs to stay with the image and it shows and hide off the stage when needed. So I use image holder to keep image and its content together. I am still using the image holder with the above code and all looks to work fine. Do you think its loading the image multiple times? Another question is about about hardcoding the module.swf file name in onInit function. I don't want to do that. I want to have the freedom of using any file name and get that name from course.xml. I am loading mulitple SWFs from course.xml. May be I can set all the file name in array and loop through the array and call addChild. Are there better options with in LoaderMax. Also thanks for encouragement. I always get in to these kind of challenging issues and I enjoys that as I am learning new things from it. I have been looking at LoaderMax for quit some time but this is the first time I am using it and its already getting so interesting. Lets see what challenge I face next. Thank you
  14. Alright, attached the simplified files. Notice that when you play the module by itself all works well but as you load in parent swf then images are not resize and get stage null. Take of the requiredRoot then child works fine in parent as well but preloader breaks. So issues. Image break out of holder when using requiredRoot. Not using required root breaks the preloader. Stage is always null in parent swf till you set event listener ADDED_TO_STAGE.(that flash issue) but adding ADDED_TO_STAGE breaks the preloader. There are also possibility that I am calling ADDED_TO_STAGE at wrong time. Actually I am calling it on very top when (parent is loader) true and then when added to stage load the XML loader hope explain well. Thank you. module.zip
  15. Here's some progress. In process of simplifying my project to get to the core of the issue. I removed all the stage reference from my child FLA. Now pre-loader works fine but my very first old issue still stays there and that is when I add requireWithRoot:this.root then the position of all the images are lost. Now heres what I found. I am adding each image in its own container call imageHolder. Then I am setting the x and y position of the imageHolder. Now when I preview child by its then all is happy. Child loaded in its own holder and holder are place right on its place. below is the sample code var imageHolder:Sprite; var img:ContentDisplay; var num = 0 function onchildComplete(e:Event){ imageHolder = new Sprite(); img = e.target.content as ContentDisplay; imageHolder.addChild(img); imageHolder.x = 100*num num++ } now as soon as I add requireWithRoot:this.root. then image lost all its position when child swf loaded in parent swf but place right when its playing by it self. Here is the important thing I noticed that requireWithRoot:this.root added then image doesn't load in its holder and that is why even though imageHolder are posed right image fall out of its position. Still digging in....
  16. Thanks Carl, this explains a lot and I got my test flas working great with your wonderful instructions. But the issue in my project is still not solves as its calling the child complete event later then parent complete event. After playing around for couple hours I found that I have added the below code because I was getting stage undefined. addEventListener(Event.ADDED_TO_STAGE, addedToStage); So here's the overall scenario To make preloader work I have to add requireWithRoot:this.root, but then I loose the stage. To get back the stage I added ADDED_TO_STAGE. then I loose the preloader. So its cycle. Looking for more options. Thanks
  17. Tried all variation estimated bytes in swf and xml but can't get to work. I added link to the zip in which I added exact extimatedBytes in swf as well as in XML for each files. Not sure where I wrong. http://alnoor.us/module2.zip Thanks
  18. So, suppose if module2.xml has 20 images then I have to add all the estimated sizes of 20 images in the module2.fla and also in course.fla to get the smooth preloading %
  19. Yes, it helped to clear the error and complete event is fired after all the children and images are loaded BUT Now the percentage of the module2.swf starts in between from 30% Like, the startup is fine all the four images load fine till 50 % and then its tile for module2,swf to load images it drops to 30% below is the trace report. Looks like something is happening when its ignoring the XML courseXMLLoader.progress = 0 courseXMLLoader.progress = 3 courseXMLLoader.progress = 3 courseXMLLoader.progress = 21 courseXMLLoader.progress = 26 *** COURSE XML CHILD IS = ImageLoader 'loader6' (lobster.png) *** COURSE XML CHILD IS = ImageLoader 'loader5' (whale.png) courseXMLLoader.progress = 35 *** COURSE XML CHILD IS = ImageLoader 'loader8' (bird.png) *** COURSE XML CHILD IS = ImageLoader 'loader7' (crab.png) *** COURSE XML CHILD IS = XMLLoader 'loader3' (module.xml) ignore xml courseXMLLoader.progress = 48 *** COURSE XML CHILD IS = SWFLoader 'loader1' (module.swf) courseXMLLoader.progress = 51 courseXMLLoader.progress = 50 courseXMLLoader.progress = 37 courseXMLLoader.progress = 42 courseXMLLoader.progress = 48 courseXMLLoader.progress = 54 courseXMLLoader.progress = 60 courseXMLLoader.progress = 66 courseXMLLoader.progress = 72 courseXMLLoader.progress = 77 courseXMLLoader.progress = 83 courseXMLLoader.progress = 89 courseXMLLoader.progress = 95 *** COURSE XML CHILD IS = ImageLoader 'loader11' (test.jpg) *** COURSE XML CHILD IS = XMLLoader 'loader9' (module2.xml) ignore xml *** COURSE XML CHILD IS = SWFLoader 'loader2' (module2.swf) courseXMLLoader.progress = 100 courseXMLLoader *** COMPLETE ***
  20. Hi Carl, I have attached the zip. Its based on the same zip that you sent but I tried to add the same scenario that I have in my project. But before getting the the complete progress of all child in one preloader I am hit by error. Looks like the its trying to convert xml in comtent display. When I trace e.target.content it also getting me raw XML thats why getting error. FYI, I am not gettind the same error in my my project. Below is the test result of function configSWFLoadComplete(event:LoaderEvent):void { trace("child = " + e.target + " " e.target.content); configSWFs = event.target.content as ContentDisplay; addChild(configSWFs); } Trace Result child = SWFLoader 'menu' (skin/menu.swf)__[object ContentDisplay] child = SWFLoader 'control' (skin/controller.swf)__[object ContentDisplay] child = SWFLoader 'help' (skin/help.swf)__[object ContentDisplay] child = SWFLoader 'header' (skin/header.swf)__[object ContentDisplay] child = SWFLoader 'module' (modules/module.swf)__[object ContentDisplay] **********assets Loaded********* Here is the link to download the zip http://alnoor.us/nestedLoaders.zip Can you please look in it Thanks
  21. This is how my xml look like <?xml version="1.0" encoding="iso-8859-1"?> <config name='course'> <SWFLoader name="menu" url="skin/menu.swf" estimatedBytes="49307" load="true" x="0" y="0" /> <SWFLoader name="control" url="skin/controller.swf" estimatedBytes="78596" load="true" x="0" y="0" /> <SWFLoader name="help" url="skin/help.swf" estimatedBytes="49307" load="true" x="0" y="0" /> <SWFLoader name="header" url="skin/header.swf" estimatedBytes="33855" load="true" x="0" y="0" /> <SWFLoader name="module" url="modules/module.swf" estimatedBytes="77928" load="true" x="0" y="0" /> </config>
  22. Thanks Carl, your example is great but I think something is wrong in my code which is creating issue. The difference between your example and mine is that mine course.xml is loading 4 different SWF and yours only one. Also I am not using the onInit listener in course.fla. Below is the code. I tried to use on Init listener it but it throws error. I am sure something is wrong in course.fla and not in module.fla as it loads fines when I just have one swf in course.xml import com.greensock.*; import com.greensock.loading.*; import com.greensock.loading.display.*; import com.greensock.events.LoaderEvent; var getModuleName; var configSWFs:ContentDisplay; LoaderMax.activate([SWFLoader]); var configLoader:XMLLoader = new XMLLoader("assets/xmls/course.xml", { name:"course", maxConnections:1, estimatedBytes:5000, onComplete:configCompleteHandler, onProgress:ConfigProgressHandler, onChildProgress:configSWFProgressHandler, onChildComplete:configSWFLoadComplete }); configLoader.load(); function ConfigProgressHandler(event:LoaderEvent):void { trace("progress: " + event.target.progress); } function configCompleteHandler(event:LoaderEvent):void { LoaderMax.getLoader("header").rawContent.courseTitleTxt = configLoader.content. @ courseTitle; LoaderMax.getLoader("header").rawContent.dispatchEvent(new Event("setCourseTitle")); var getModuleAsDisplay:ContentDisplay = LoaderMax.getContent("module"); getModuleName = configLoader.content.SWFLoader[3]. @ url setChildIndex(getModuleAsDisplay, 1); } function configSWFProgressHandler(event:LoaderEvent):void { //trace("progress: " + event.target.progress); } function configSWFLoadComplete(event:LoaderEvent):void { configSWFs = event.target.content as ContentDisplay; addChild(configSWFs); }
  23. Hi Now I have another scenario where I can't get the progress of child images. Let me explain. I have a parent SWF name course.swf that loads XML. name course.xml Now course.xml has a SWFLoader that loads SWF name module.swf. This works fine and I can get the progress of module.swf. Now here is the Issue. module.swf load another XML name module.xml and that xml loads bunch of images. Now I want the grand parent(course.swf) to get the progress of its child SWF and its grand child images all together. Is that possible? Thanks
  24. I think it for me mySWFLoader.load(true); But, it reloads all the slides and keeps the existing ones Like if I have 10 slides in the SWF then after running mySWFLoader.load(true) it add 10 more so then I get 20 slide. Now how can I clear the existing slide and then run load(true) Its amazing how quickly it loads the relaods the slides. Great LoaderMax!!! Thanks