Hi,
absolutely loving these classes, though am having a few problems with them. I am basically trying to create a swf rotator that loads and then displays swfs 1 by 1 based on which number is selected from a navigation menu e.g. (1)(2)(3). I have managed to get the swfs to load fine, but the problem I am having is that they are being loaded as a contentDisplay element and not as MovieClips and as a result I am unable to directly access them. I found some help on your site about using rawContent to solve this problem but struggled to get it to work the way I want.
I need to pass variables in and also control the timeline of each of these swfs so ideally I would want to load them in with movieClip names of rotator1, rotator2, rotator3 etc. To control the timeline of these swfs I would want the code to be rotator1.gotoAndPlay("start");, rotator1.stop(); for example.
Other questions I have are:
1) Can loaderMax stop all movie clips within the swf and then autoplay once it is fully loaded?
2) I am using flashVars passed from the html to the swfs, does loaderMax have a clever way of passing these variables or should I just do this the normal way?
Here is my code so far:
thanks again!!
package demos
{
import com.greensock.TweenLite;
import com.greensock.easing.Back;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.LoaderMax;
import com.greensock.loading.SWFLoader;
import com.greensock.loading.display.ContentDisplay;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class GetLoader_Test extends Sprite
{
private var nav_btn:MovieClip;
private var navNum:uint = 1;
private var urls:Array = ["swfs/testswf_01.swf","swfs/testswf_02.swf","swfs/testswf_03.swf"];
private var rotator:ContentDisplay;
public function GetLoader_Test()
{
//create a LoaderMax named "mainQueue" and set up onProgress, onComplete and onError listeners
var queue:LoaderMax = new LoaderMax({name:"mainQueue",maxConnections:1,onProgress:_progressHandler,onComplete:_queueCompleteHandler});
// Loop through urls and create a queue of swf loaders
for (var i:Number = 0; i < urls.length; i++)
{
queue.append( new SWFLoader(urls[i], {name:"rotator_"+(i+1), autoPlay:false}) );
}
//prioritize the first swf named "rotator_1"
LoaderMax.prioritize("rotator_1");
queue.load();
}
private function _progressHandler(event:LoaderEvent):void
{
this.progress_mc.progressBar_mc.scaleX = event.target.progress;
}
private function _queueCompleteHandler(event:LoaderEvent):void
{
removeChild(progress_mc);
rotator = LoaderMax.getContent("rotator_1");
rotator.alpha = 0;
swfContainer.addChild(rotator);
TweenLite.to(rotator, 1, {alpha:1});
// Create the nav buttons based on urls passed in
for (var i:Number = 0; i < urls.length; i++)
{
nav_btn = new navNum_btn();
nav_btn.name = "nav_btn_"+(i+1);
nav_btn.x = i * nav_btn.width;
nav_btn.y = 0;
nav_btn.value_txt.text = (i+1);
nav_btn.mouseEnabled = true;
nav_btn.mouseChildren = false;
navContainer.addChild(nav_btn);
// Assign _changeRotator click function to nav buttons
nav_btn.addEventListener(MouseEvent.CLICK, _changeRotator, false, 0, true);
}
}
private function _changeRotator(event:MouseEvent):void
{
// Get the number of the button clicked based on the text found within it
navNum = event.target.value_txt.text;
// Fade the rotator out and remove it from stage
TweenLite.to(rotator, 1, {alpha:0, onComplete:_fadeIn});
}
private function _fadeIn():void
{
swfContainer.removeChild(rotator);
// Change and fade in the rotator based on the number clicked
rotator = LoaderMax.getContent(urls[navNum - 1]);
swfContainer.addChild(rotator);
TweenLite.to(rotator, 1, {alpha:1});
}
}
}