【问题标题】:view picture timer actionscript3,0(FLASH BUILDER)查看图片计时器 actionscript3,0(FLASH BUILDER)
【发布时间】:2013-01-02 19:42:44
【问题描述】:

我想在几秒钟后查看每张图片。 功能显示在程序中滚动。 请添加必要的代码。 我看不懂actionscript的定时器功能。

            function display(q:int):void{
            if(q ==0)
            {
                ue.visible= true;
                migi.visible= false;
                shita.visible= false;
                hidari.visible= false;
            }
            else if(q ==1)
            {

                ue.visible= false;
                migi.visible= true;
                shita.visible= false;
                hidari.visible= false;
            }
            else if(q ==2)
            {
                ue.visible= false;
                migi.visible= false;
                shita.visible= true;
                hidari.visible= false;
            }
            else
            {
                ue.visible= false;
                migi.visible= false;
                shita.visible= false;
                hidari.visible= true;
            }
                }

【问题讨论】:

    标签: actionscript time timer


    【解决方案1】:

    试试下面的。我试图包括 cmets 来解释我在做什么:

    import flash.utils.Timer;
    import flash.events.TimerEvent;
    
    // Put all the clips in an array to manage
    var pictures:Array = [this.ue, this.migi, this.shita, this.hidari];
    
    // Store the current image index
    var currentPicture = 0;
    
    // Delay in milliseconds to wait between each image
    var delay = 1000; 
    
    // We can reuse the same timer instance throughout cycle
    var timer:Timer = new Timer(this.delay, 1);
    timer.addEventListener(TimerEvent.TIMER_COMPLETE, timerCompleteHandler);
    
    // Hide all the pictures in the array
    function hidePictures():void 
    {
        for (var i:int = 0; i < this.pictures.length; i ++)
        {
            MovieClip(this.pictures[i]).visible = false;
        }
    }
    
    function showPicture():void 
    {
        // Show the current image
        MovieClip(this.pictures[this.currentPicture]).visible = true;
    
        // Now start the pause on the current image
        timer.start();
    }
    
    function timerCompleteHandler(event:TimerEvent):void
    {
        // Hide the old image
        MovieClip(this.pictures[this.currentPicture]).visible = false;
    
        // Increment current picture index unless we're at the end in which case loop
        this.currentPicture = (this.currentPicture < this.pictures.length - 1)
            ? this.currentPicture + 1 : 0;
    
        // Show the next picture
        showPicture();
    }   
    
    hidePictures();
    showPicture();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多