Recommended Posts

Hi I am using this code which I took from this forum somewhere  :-P

import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;

LoaderMax.activate([ImageLoader]);

var index:int = 0;
var currentImage:Sprite;
var urls:Array = ["images/rm_01.jpg","images/rm_02.jpg","images/rm_03.jpg","images/rm_04.jpg", "images/rm_05.jpg","images/rm_06.jpg",
"images/rm_07.jpg" , "images/rm_08.jpg" , "images/rm_09.jpg" , "images/rm_10.jpg" , "images/rm_11.jpg" , "images/rm_12.jpg"];

var queue:LoaderMax = LoaderMax.parse(urls,{onComplete:onCompleteHandler,onProgress:onProgressHandler,maxConnections:1,onChildComplete:onChildCompleteHandler}, {alpha:0});
queue.load();

function onCompleteHandler(e:LoaderEvent):void {
	trace("all images loaded");
	showNextImage();
}

function onProgressHandler(e:LoaderEvent):void {
	trace(e.target.progress);
}


function onChildCompleteHandler(e:LoaderEvent):void {
	trace(e.target + " loaded");
	}


function showNextImage() {
	trace("image " + index)
	currentImage = LoaderMax.getContent(urls[index]);
	currentImage.alpha = 0;
	TweenLite.to(currentImage, .5, {alpha:1});
	addChild(currentImage);
	if (index < urls.length-1) {
		index++;
			} else {
		index = 0;
		
	}
	TweenLite.delayedCall(2, showNextImage);
	}

Some of mine images are not the same size due height and width. Could you please help me, so when the new image coming to show up the previous will start to fading .to(alpha :0) 

 

;)

Share this post


Link to post
Share on other sites

I tried to solve it myself for some time...

function showNextImage() {
	trace("image " + index)
	currentImage = LoaderMax.getContent(urls[index]);
	currentImage.alpha = 0;
	//TweenLite.to(currentImage, .5, {alpha:1});
	TweenLite.fromTo(currentImage, 5, {alpha:1}, {alpha:0});
	addChild(currentImage);
	if (index < urls.length-1) {
		index++;
			} else {
		index = 0;
		
	}
	TweenLite.delayedCall(3, showNextImage);
		}

...and I just changed TweenLite.to to .fromTo and timing and it seems working fine.

;)

  • Like 1

Share this post


Link to post
Share on other sites

Glad you found a solution. Thanks for letting us know.

Share this post


Link to post
Share on other sites

Can I have anotherone please? :)

I am trying to pause and resume....can you please help me with functions pause and resume  at the bottom ;)

import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;


LoaderMax.activate([ImageLoader]);

var index: int = 0;
var currentImage: Sprite;
var urls: Array = ["images/rm_01.jpg", "images/rm_02.jpg", "images/rm_03.jpg", "images/rm_04.jpg", "images/rm_05.jpg", "images/rm_06.jpg",
	"images/rm_07.jpg", "images/rm_08.jpg", "images/rm_09.jpg", "images/rm_10.jpg", "images/rm_11.jpg", "images/rm_12.jpg"
];

var queue: LoaderMax = LoaderMax.parse(urls, {
	onComplete: onCompleteHandler,
	onProgress: onProgressHandler,
	maxConnections: 1,
	onChildComplete: onChildCompleteHandler
}, {
	alpha: 0
});
queue.load();

function onCompleteHandler(e: LoaderEvent): void {
	trace("all images loaded");
	showNextImage();
}

function onProgressHandler(e: LoaderEvent): void {
	trace(e.target.progress);

}

function onChildCompleteHandler(e: LoaderEvent): void {
	trace(e.target + " loaded");

}


function showNextImage() {
	trace("image " + index)
	currentImage = LoaderMax.getContent(urls[index]);
	currentImage.alpha = 0;
	//TweenLite.to(currentImage, .5, {alpha:1});
	TweenLite.fromTo(currentImage, 3, {
		alpha: 1
	}, {
		alpha: 0
	});
	addChild(currentImage);
	if (index < urls.length - 1) {
		index++;
	} else {
		index = 0;


	}
	TweenLite.delayedCall(3, showNextImage);
}

var pauseB: pauseBtn = new pauseBtn;
addChild(pauseB);
pauseB.x = 300;
pauseB.y = 100;

pauseB.addEventListener(MouseEvent.ROLL_OVER, pause);
pauseB.addEventListener(MouseEvent.ROLL_OUT, resume);

function pause(): void {
	pauseB.stop();
	pauseB.removeEventListener(TimerEvent.TIMER, showNextImage);
	TweenMax.pauseAll(true, true);
}

function resume():void{
	
}

Share this post


Link to post
Share on other sites

Its really hard to look at that code and suggest exactly how to add play and pause functionality. We stopped creating our Flash products years ago and unfortunately our support is very limited to direct questions about the API. We just don't have the resources to re-work old projects like this. Sorry.

Share this post


Link to post
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.