nickolas9
03-15-2010, 06:48 PM
Hi, I would appreciate it greatly if someone could help me out in understanding the general approach to controlling the flow of a movie. I've done some basic programming (Java) before so I'm familiar with loops, conditional statements, OOP, etc. but I'm still a beginner and a little stuck with how to use actionscript that is time / sequence sensitive.
Specifically, I'm trying to create a slideshow / image rotator that crossfades images from an XML file. I know, there are dozens of tutorials on photo galleries, but I just haven't found one that works how I would like it to and I've failed at trying to tweak them for my needs.
I'm thinking that my general approach would be something like this:
Set upper image holder alpha to 0
Load first image into holder in upper layer
Fade in upper holder
Increment array that holds image paths
Load second image to lower layer
Fade out upper holder
Increment array that holds image paths
The problem I'm having is that the different steps execute instantly one after another. I have a suspicion that I need to use event listeners like Loader() / Event.COMPLETE. But how do I make it "pause" so that it can complete the crossfade? If I use a timer, won't it start repeating the timed function and immediately move on to calling the loadNextImage function while still repeating the other fadeImage function?
(Incomplete implementation)
myTimer.addEventListener(TimerEvent.TIMER, fadeImage);
loadNextImage();
function fadeImage(event:TimerEvent):void {
//someImage.alpha += 5
//and as a side note-- how do I get the timer to stop once
//the image is at alpha 100?
}
function loadNextImage():void {
//...
}
So, I'm sorry this is kind of long, but I don't know how to ask the question in a more simple way. But basically, how do you approach a situation where you need to delay certain instructions while a function is completing (loading an image, crossfading images, etc.) and then execute the next instruction? Is there a way of "chaining" the functions all together?
Thanks for any help!
Specifically, I'm trying to create a slideshow / image rotator that crossfades images from an XML file. I know, there are dozens of tutorials on photo galleries, but I just haven't found one that works how I would like it to and I've failed at trying to tweak them for my needs.
I'm thinking that my general approach would be something like this:
Set upper image holder alpha to 0
Load first image into holder in upper layer
Fade in upper holder
Increment array that holds image paths
Load second image to lower layer
Fade out upper holder
Increment array that holds image paths
The problem I'm having is that the different steps execute instantly one after another. I have a suspicion that I need to use event listeners like Loader() / Event.COMPLETE. But how do I make it "pause" so that it can complete the crossfade? If I use a timer, won't it start repeating the timed function and immediately move on to calling the loadNextImage function while still repeating the other fadeImage function?
(Incomplete implementation)
myTimer.addEventListener(TimerEvent.TIMER, fadeImage);
loadNextImage();
function fadeImage(event:TimerEvent):void {
//someImage.alpha += 5
//and as a side note-- how do I get the timer to stop once
//the image is at alpha 100?
}
function loadNextImage():void {
//...
}
So, I'm sorry this is kind of long, but I don't know how to ask the question in a more simple way. But basically, how do you approach a situation where you need to delay certain instructions while a function is completing (loading an image, crossfading images, etc.) and then execute the next instruction? Is there a way of "chaining" the functions all together?
Thanks for any help!