Jump to content

Codepen Notification

You didn't provide a codepen sample that illustrates the problem. It really helps us quickly identify problems. This isn't mandatory, but it will get you better/faster results. Would you like to add one?

SlideShow

Started by Luigi Vercotti, Feb 27 2017 10:53 AM - - - - -

5 replies to this topic
Luigi Vercotti

Post #1 by Luigi Vercotti , 27 February 2017 - 10:53 AM

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) 

 

;)


"I BELIEVE IN PEACE AND BASHING TWO BRICKS TOGETHER." Monty Python
  • Back to top

Luigi Vercotti

Post #2 by Luigi Vercotti , 27 February 2017 - 12:50 PM

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.

;)


"I BELIEVE IN PEACE AND BASHING TWO BRICKS TOGETHER." Monty Python
  • Back to top

Carl
  • Carl
  • 5,634 Likes (Superhero)
  • 7,863 posts

Post #3 by Carl , 27 February 2017 - 03:13 PM

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


  • Back to top

Luigi Vercotti

Post #4 by Luigi Vercotti , 01 March 2017 - 09:29 AM

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{
	
}


"I BELIEVE IN PEACE AND BASHING TWO BRICKS TOGETHER." Monty Python
  • Back to top

Carl
  • Carl
  • 5,634 Likes (Superhero)
  • 7,863 posts

Post #5 by Carl , 02 March 2017 - 07:24 PM

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.


  • Back to top

anotheruser

Post #6 by anotheruser , 23 March 2017 - 10:15 AM

I think Carl should stop answering flash related questions , so noone would ask


  • Back to top




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

3rd Party Advertisement