Share Posted October 4, 2010 I want to access some public functions inside a loaded SWF. private var contentor:MovieClip; private var loaderSwf:LoaderMax; ... public function LoaderClass():void { loaderSwf = new LoaderMax( { name:"loaderSwf", onOpen:startHandler, onProgress:progressHandler, onComplete:completeHandlerSwf, onError:errorHandler } ); } private function completeHandlerSwf(event:LoaderEvent):void { contentor = new MovieClip; contentor = event.target.rawContent as MovieClip; dispatchEvent(new Event(Event.COMPLETE)); } I get this error: "ReferenceError: Error #1069: Property rawContent not found on com.greensock.loading.LoaderMax and there is no default value." If I try to access the rawContent trow the loader: private function completeHandlerSwf(event:LoaderEvent):void { contentor = new MovieClip; contentor = loaderSwf.rawContent as MovieClip; dispatchEvent(new Event(Event.COMPLETE)); } I get this error: "1119: Access of possibly undefined property rawContent through a reference with static type com.greensock.loading:LoaderMax." I'm I missing some import? Some newbie error? Link to comment Share on other sites More sharing options...
Share Posted October 4, 2010 Yep, it's a newbie error You want to use the rawContent property of the SWFLoader that you used to load the swf, NOT the LoaderMax instance. A LoaderMax is like a queue of loaders (SWFLoaders, ImageLoaders, XMLoaders, whatever). BAD: var queue:LoaderMax = new LoaderMax({onComplete:completeHandler}); queue.append( new SWFLoader("child.swf") ); function completeHandler(event:LoaderEvent):void { trace("rawContent: " + event.target.rawContent); //ERROR! event.target refers to the LoaderMax! } GOOD: var queue:LoaderMax = new LoaderMax(); queue.append( new SWFLoader("child.swf", {onComplete:completeHandler}) ); function completeHandler(event:LoaderEvent):void { trace("rawContent: " + event.target.rawContent); //Correct - event.target refers to the SWFLoader } Notice how I attached the onComplete listener to the SWFLoader. There are many other ways to do this too, but the above example is probably the simplest. Here's another idea where you can use the name of the SWFLoader to get the rawContent: var queue:LoaderMax = new LoaderMax({onComplete:completeHandler}); queue.append( new SWFLoader("child.swf", {name:"mySWF"}) ); function completeHandler(event:LoaderEvent):void { trace("rawContent: " + LoaderMax.getLoader("mySWF").rawContent); } Link to comment Share on other sites More sharing options...
Author Share Posted October 4, 2010 hehehehe newbie errors!! It works now! Thank you so much for the fast reply, you save me some hours of sleeeepp! fantastic work! Link to comment Share on other sites More sharing options...
Share Posted November 18, 2011 Hello Jack, I'm getting the same message here but i'm not using an LoaderMax instance, I'm using SWFLoader. Here's my code. import com.greensock.*; import com.greensock.events.TweenEvent; import com.greensock.events.LoaderEvent; import com.greensock.loading.*; var loaderIndex:Number = -1; var currentLoader:SWFLoader; var swfs:LoaderMax = new LoaderMax({name:"mainQueue", onComplete:loadComplete, onChildComplete:childCompleteHandler}); ///This append method of yours is how I want to load the swfs//// swfs.append(new SWFLoader("pair1.swf", {container:container_mc, autoPlay:false})); swfs.append(new SWFLoader("pair2.swf", {container:container_mc, autoPlay:false})); swfs.append(new SWFLoader("pair3.swf", {container:container_mc, autoPlay:false})); swfs.append(new SWFLoader("pair4.swf", {container:container_mc, autoPlay:false})); swfs.load(); function childCompleteHandler(e:LoaderEvent):void { trace(e.target + " loaded"); e.target.content.visible = false; } function loadComplete(e:LoaderEvent):void{ trace("swf loaded"); //reference the TimelineMax in the loaded swf // Carl, this mainOut is the finial timeline that completes the activity/// var loadedTimelineMax:TimelineMax= e.target.rawContent.mainIn; initCurrentLoader(); trace(loadedTimelineMax); //track when the loaded TimelineMax is done playing loadedTimelineMax.addEventListener(TweenEvent.COMPLETE, timelineCompleteMessage); //tell the loaded TimelineMax to play loadedTimelineMax.play(); } function initCurrentLoader() { loaderIndex++; if (loaderIndex == swfs.numChildren) { //reset back to 0 if the last swf has already played loaderIndex = 0; } //dynamically reference current loader based on value of loaderIndex currentLoader = swfs.getChildAt(loaderIndex); //make the content of the current loader visible currentLoader.content.visible = true; //tell the current loader's swf to to play currentLoader.rawContent.startTimelineMax(); //currentLoader.rawContent.gotoAndPlay(1); } function timelineCompleteMessage(e:TweenEvent):void{ trace("the parent has detected that the TimelineMax in the loaded swf is COMPLETE"); } function timelineStartMessage():void{ trace("the timeline started playing and the child swf told the parent swf to display this message\n"); } Do you what I'm doing wrong? Ben. Link to comment Share on other sites More sharing options...
Share Posted November 18, 2011 You are using a LoaderMax instance. You set its onComplete to loadComplete() and then inside that method, you tried e.target.rawContent. The e.target would reference the LoaderMax (since it's the thing dispatching the COMPLETE event) and LoaderMax instances don't have a "rawContent" property. See what I mean? Link to comment Share on other sites More sharing options...
Share Posted November 18, 2011 ok I get it. But how about if I use SWFLoader instead? var swfs:SWFLoader = new SWFLoader({name:"mainQueue", onComplete:loadComplete, onChildComplete:childCompleteHandler}); Link to comment Share on other sites More sharing options...
Share Posted November 18, 2011 Could you be a little more specific with your question? I'm not sure what exactly you're looking for, what the problem is, or where the confusion might be. Link to comment Share on other sites More sharing options...
Share Posted November 18, 2011 Sorry. So if I don't use the LoaderMax instance to load the swfs because the e.target.rawContent can't reference it. Could I use the SWFLoader instead ? would that solve the error message I'm getting? I've been able to have a single child swf load and animate its content fine and now I'm trying to load a number of swfs in a sequence one after the other but I am getting the rawContent error message. The other issue is that all swfs are playing simultaneously. What I looking at doing is having the first swf play through its animation & when the first is completed it's animation the second swf starts etc.... So should I do this? var swfs:SWFLoader = new SWFLoader({name:"mainQueue", onComplete:loadComplete, onChildComplete:childCompleteHandler}); swfs.append(new SWFLoader("pair1.swf", {container:container_mc, autoPlay:false})); swfs.append(new SWFLoader("pair2.swf", {container:container_mc, autoPlay:false})); swfs.append(new SWFLoader("pair3.swf", {container:container_mc, autoPlay:false})); swfs.append(new SWFLoader("pair4.swf", {container:container_mc, autoPlay:false})); function loadComplete(e:LoaderEvent):void{ trace("all swfs loaded"); var loadedTimelineMax:TimelineMax= e.target.rawContent.mainIn; Link to comment Share on other sites More sharing options...
Share Posted November 18, 2011 ben, it seems this project of yours started from the initial thread here: viewtopic.php?f=6&t=6385 started by someone else and now it continues in this thread here that is a month old also started by someone else. It's very difficult for GreenSock or I to offer help if the proper context is not given or if the discussion of the same project is taking place in multiple threads. I think I have some idea of what you are trying to do and if possible I will create a third solution to address your problem of having multiple swfs load and play their TimelineMax sequences in order later today or sometime this weekend. right now it appears a few lines of code are in the wrong place or won't work without some modification carl Link to comment Share on other sites More sharing options...
Share Posted November 19, 2011 Hi Carl, Yes I guess I should have posted to the other thread. I only posted on this thread after I didn't a search on this site for the same error message that I was getting so I thought I'd post here instead. I do appreciate the help. Ben. Link to comment Share on other sites More sharing options...
Share Posted November 22, 2011 attached is an example that -loads 2 swfs -each of these swfs have TimelineMax animations -after both swfs load ---swf1' s TimelineMax plays and when it is done playing ---swf2' s TimelineMax plays and when it is done playing ---swf1' s TimelineMax plays and when it is done playing etc Link to comment Share on other sites More sharing options...
Share Posted November 23, 2011 Thanks Carl. Much appreciated. I'll give it a go and post my results. Cheers, Ben. 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