I found a simple tween with the following code:
import com.greensock.*;
import com.greensock.easing.*;
bars.cacheAsBitmap=true;
img.cacheAsBitmap=true;
img.mask=bars;
//create TimelineMax instance and set to repeat infinitely
var timeline:TimelineMax=new TimelineMax({repeat:-1,repeatDelay:1,yoyo:true});
//speed vars
var duration:Number=.5;
//loop through bar in bars clip and add tween to timeline
for (var count:Number = 1; count <=10; count++) {
//create reference to each individual clip
var mc:MovieClip=bars["bar"+count];
timeline.append(TweenMax.from(mc, duration, {x:"64", alpha:0, ease:Cubic.easeOut}), -.4);
}
In the example the image and mask are both on the stage from the start - not added dynamically.
you can see it here: http://www.jimslounge.com/tweenTest/mask_bars.swf
I would like to integrate it into my slide show
here is the code:
import com.greensock.*;
import com.greensock.easing.*;
var bars:Bars = new Bars();
var xmlLoader:URLLoader; // slideshow xml loader
var xmlSlideshow:XML; // slideshow xml
var strXMLPath:String = "slideshow-data.xml";
var loader:Loader;
var intSlideCount:int;
var holder:Sprite = new Sprite();
xmlLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, onXMLLoadComplete);
xmlLoader.load(new URLRequest(strXMLPath));
function onXMLLoadComplete(e:Event):void {
xmlLoader.removeEventListener(Event.COMPLETE, onXMLLoadComplete);
xmlSlideshow = new XML(e.target.data); // create new xml with the received data
intSlideCount = xmlSlideshow..image.length(); // get total slide count
loadSlide(null);
}
function loadSlide(e:Event):void {
trace("we loaded slide");
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, displaySlide);
loader.load(new URLRequest(xmlSlideshow..@src[1]));
trace(loader.contentLoaderInfo);
}
function displaySlide(e:Event):void {
holder.addChild(loader);
bars.cacheAsBitmap=true;
holder.cacheAsBitmap=true;
holder.mask=bars;
addChild(holder);
var timeline:TimelineMax=new TimelineMax({repeat:-1,repeatDelay:2.5,yoyo:true});
var duration:Number=.5;
for (var count:Number = 1; count <=10; count++) {
//create reference to each individual clip
var mc:MovieClip=bars["bar"+count];
timeline.append(TweenMax.from(mc, duration, {x:"64", alpha:0, ease:Cubic.easeOut}), -.4);
bars.width=holder.width;
bars.height=holder.height;
}
}
I create an instance of a Sprite, load an external image using xml, add the image as a child of the Sprite instance "holder", add holder the the stage then run the tween.
this is what it looks like http://www.jimslounge.com/tweenTest/my_mask_bars.swf
The tween doesn't run till I re-size the stage and when it runs gives a different effect.