Jump to content
Search Community

trying to use tween in my slideshow[SOLVED]

attaboy test
Moderator Tag

Recommended Posts

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.

Link to comment
Share on other sites

yo attaboy!

 

great job of integrating the mask effect with an externally loaded image!

it seems it is all working except the variable transparency of the mask.

 

your code looks really good. the only thing I would suggest as a fix is this:

 

bars.cacheAsBitmap=true;

holder.cacheAsBitmap=true;

holder.mask=bars;

addChild(holder);

 

the problem may be that you are setting the holder.mask = bars BEFORE it is added to the stage. try moving it up above bars.cacheAsBitmap = true;

 

that is only a guess.

 

if that doesn't fix it, zip up all your files and post them here. I'll take a look at it tomorrow. let me know if you get it working.

 

Carl

 

ps. if other snorkl.tv files give you trouble feel free to post in the comments over there. I do my best to address each comment.

Link to comment
Share on other sites

You never added your "bars" object (the mask) to the stage. That's a rather important detail :)

 

addChild(bars);

 

By the way, you might want to check out LoaderMax for loading your XML and images. It could simplify things quite a bit and it gets around some bugs in Adobe's Loader. http://www.greensock.com/loadermax/

 

Check out tip #3 here:

http://www.greensock.com/loadermax-tips/#3

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...