You're mixing Tween and TweenLite code. You've got an event listener set up
for a TweenEvent.MOTION_FINISH but TweenLite doesn't dispatch events
(TweenMax does though), and you didn't define your cloudTween variable.
The easiest thing to do would be to use TweenMax and its "repeat" property,
setting it to -1 for infinite:
TweenMax.to(parent_container2, 50, {x:-1000, repeat:-1});
Or you could use TweenLite's onComplete special property to call restart()
on your TweenLite instance, like:
var cloudTween:TweenLite = new TweenLite(parent_container2, 50, {x:-1000,
onComplete:repeatCloudTween});
function repeatCloudTween():void {
cloudTween.restart();
}
Make sure you're using v11: http://www.greensock.com/v11/
Jack
-----Original Message-----
From: John Singleton [mailto:[email protected]]
Sent: Monday, April 26, 2010 9:02 AM
To: [email protected]
Subject: [Flashcoders] Infinitely Looping Image
Hi;
I would like to have a background image of clouds loop infinitely.Here's my
code:
function BigPic():void
{
parent_container2 = new MovieClip();
var square:Sprite = new Sprite();
parent_container2.mask = square;
addChild(square);
square.graphics.lineStyle(3,0x065566);
square.graphics.beginFill(0xffffff);
square.graphics.drawRoundRect(22, 22, 966, 146, 20);
square.graphics.endFill();
addChild(parent_container2)
var path:String = "images/clouds.png";
var
req:URLRequest = new URLRequest(path);
var loader:Loader = new Loader();
loader.load(req);
loader.addEventListener(IOErrorEvent.IO_ERROR,
function(e:IOErrorEvent):void{ trace(e) });
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, BigPicLoaded);
}
function BigPicLoaded(evt:Event):void
{
var
loaderInfo:LoaderInfo = evt.target as LoaderInfo;
var
displayObject:DisplayObject = loaderInfo.content;
displayObject.width = 2000;
displayObject.height = 150;
displayObject.x = 20;
displayObject.y = 20;
parent_container2.addChild(displayObject);
//
TweenLite.to(parent_container2, 50, {x:-1000});
cloudTween.addEventListener(TweenEvent.MOTION_FINISH, restartAnimation);
}
function restartAnimation(oEvent:Event):void
{
cloudTween.start();
}
But it ain't working. Ideas?
TIA,
John
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders