Jump to content
GreenSock

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

Search the Community

Showing results for tags 'as 3.0'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • GreenSock Forums
    • GSAP
    • Banner Animation
    • Jobs & Freelance
  • Flash / ActionScript Archive
    • GSAP (Flash)
    • Loading (Flash)
    • TransformManager (Flash)

Product Groups

  • Club GreenSock
  • TransformManager
  • Supercharge

Categories

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Personal Website


Twitter


CodePen


Company Website


Location


Interests

Found 1 result

  1. Hi, I have found the following code to loop through an array of swf's - which works really smoothly (thanks). I would like to re-use this code to load other arrays of swf's. Could I make a separate class so I could re-use the code in a more streamlined way rather than pasting it over and over (any advice how to do this would be great)? Also how can I center the x and y co-ordinates of the loader? Thanks! import com.greensock.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; import flash.display.MovieClip; import flash.events.Event; import flash.events.MouseEvent; private var loaderIndex:Number = -1; private var currentLoader:SWFLoader; private var urls:Array = ["movie0.swf","movie1.swf","movie2.swf",]; private var swfs:LoaderMax = new LoaderMax({onComplete:completeHandler,onChildComplete:childCompleteHandler}); private function startMovieOne(event:MouseEvent):void { homePage_mc.visible = false; // Loop through urls and create a queue of swf loaders for (var i:Number = 0; i < urls.length; i++) { swfs.append( new SWFLoader(urls, {container:movieTwo_mc, autoPlay:false, width:480, height:480, scaleMode:"proportionalInside"}) ); } swfs.load(); btnListener(); } function childCompleteHandler(e:LoaderEvent):void { trace(e.target + " loaded"); e.target.content.visible = false; } function completeHandler(e:LoaderEvent):void { trace("all swfs loaded"); initCurrentLoader(); addEventListener(Event.ENTER_FRAME, trackSWFPlayback); } 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.gotoAndPlay(1); } function trackSWFPlayback(e:Event):void { //trace(currentLoader.rawContent.currentFrame); //detect if the loaded swf is on the last frame if (currentLoader.rawContent.currentFrame == currentLoader.rawContent.totalFrames) { trace("swf done"); //hide and stop current swf currentLoader.content.visible = false; currentLoader.rawContent.stop(); //set up and play the next swf; initCurrentLoader(); } } private function btnListener():void { home_btn.addEventListener(MouseEvent.CLICK,resetScreens); } public function resetScreens(event:MouseEvent):void { //unload content currentLoader.content.visible = false; currentLoader.rawContent.stop(); trace("unloaded"); homePage_mc.visible = true; }
×