开发者

Flash: AS3: slideshow/movie running on a timer instead (using the template in cs5)

I am going to be making a flash intro that involves using the flash transitions to transition between pictures and video content. I'm not looking to use this whole code from the template, I just want to implement the transitions with the timer instead of a keypress event. One like as follows:

stop();

var timer1:Timer = new Timer(200);
timer1.addEventListener(TimerEvent.TIMER, blah1);
timer1.start();

function blah1(e:TimerEvent):void{
 play();
    timer1.reset()

trace("Times Fired: " + e.currentTarget.currentCount);
trace("Time Delayed: " + e.currentTarget.delay);
}

Here is the code for the slideshow template that I plan on using:

开发者_JAVA百科
    import fl.transitions.*;

// USER CONFIG SETTINGS
var buttonsOn:Boolean = true; // true, false
var pageNumberOn:Boolean = true; // true, false
var transitionOn:Boolean = true; // true, false
var transitionType:String = "Fade"; 
// END USER CONFIG SETTINGS

// EVENTS
stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_changeSlideKeyboard);
prev_btn.addEventListener(MouseEvent.CLICK, fl_prevSlideButton);
next_btn.addEventListener(MouseEvent.CLICK, fl_nextSlideButton);
function fl_changeSlideKeyboard(evt:KeyboardEvent):void
{
    if(evt.keyCode == 37) // LEFT
    {
        fl_prevSlide();
    }
    else if (evt.keyCode == 39 || evt.keyCode == 32) // RIGHT OR SPACE
    {
        fl_nextSlide();
    }
}
function fl_prevSlideButton(evt:MouseEvent):void
{
    fl_prevSlide();
}
function fl_nextSlideButton(evt:MouseEvent):void
{
    fl_nextSlide();
}
// END EVENTS

// FUNCTIONS AND LOGIC
function fl_prevSlide():void
{
    if(slides_mc.currentFrame > 1)
    {
        slides_mc.gotoAndStop(slides_mc.currentFrame-1);
        if(transitionOn == true)
        {
            fl_doTransition();
        }
        if(pageNumberOn == false)
        {
            slideNumber_txt.text = "";
        } else {
            slideNumber_txt.text = String(slides_mc.currentFrame + "/" + slides_mc.totalFrames);
        }
    }
}
function fl_nextSlide():void
{
    if(slides_mc.currentFrame < slides_mc.totalFrames)
    {
        slides_mc.gotoAndStop(slides_mc.currentFrame+1);
        if(transitionOn == true)
        {
            fl_doTransition();
        }
        if(pageNumberOn == false)
        {
            slideNumber_txt.text = "";
        } else {
            slideNumber_txt.text = String(slides_mc.currentFrame + "/" + slides_mc.totalFrames);
        }
    }
}
function fl_doTransition():void
{
    if(transitionType == "Fade")
    {
        TransitionManager.start(slides_mc, {type:Fade, direction:Transition.IN, duration:0.25});
    } 
}
slides_mc.gotoAndStop(1);
stage.scaleMode = StageScaleMode.SHOW_ALL;
// END FUNCTIONS AND LOGIC

stop();


You will need to alter the slideshow code as follows. For example, on timer event you will do what the next button would've done before. Also you will probable need to check when the slide show rich its end and decide what to do then, scroll at the beginning or stop.

var timer:Timer = new Timer(200);
timer.addEventListener(TimerEvent.TIMER, onTime);
timer.start();

function onTime(e:TimerEvent):void{
 fl_nextSlide();
 timer.reset();
}


I gather that you have those two snippets and want to use the first one to control the slide show, that comes with the second snippet.

If so, just:

function blah1(e:TimerEvent):void{
     fl_nextSlide();
    //timer1.reset();
    ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜