A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Help needed in my trial script

  1. #1
    Registered User
    Join Date
    Jul 2015
    Posts
    2

    Help needed in my trial script

    Hello all,

    I am a beginner in AS3 scripting,

    I have been trying to make a script which will play pause and reset button,

    I have succeeded in playing and resetting but not in pausing the flash file.

    i am not able to completely pause the animation.

    Please Check the scipt given and help me.



    Script:

    package lib
    {

    import flash.display.MovieClip;
    import flash.events.*;


    public class Controlstry extends MovieClip
    {


    public function Controlstry()
    {
    // constructor code
    addEventListener(Event.ADDED_TO_STAGE,init);
    }
    private function init(evt=null)
    {
    if (video_mc != null)
    {
    playBtn.addEventListener(MouseEvent.MOUSE_DOWN, playVideo);
    pauseBtn.addEventListener(MouseEvent.MOUSE_DOWN, pauseVideo);
    replayBtn.addEventListener(MouseEvent.MOUSE_DOWN,r eplayVideo);
    }
    }

    private function playVideo(evt:MouseEvent)
    {
    if (video_mc.currentFrame == video_mc.totalFrames)
    {
    video_mc.gotoAndPlay(2);
    }
    else
    {
    video_mc.play();
    }
    }

    private function pauseVideo(evt:MouseEvent)
    {
    video_mc.stop();
    }

    private function replayVideo(evt:MouseEvent)
    {
    video_mc.gotoAndPlay(2);
    }
    }
    }
    Attached Files Attached Files

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    HI,

    It is because you only allow it to play if the currentFrame == totalfFrames

    PHP Code:
    private function playVideo(evt:MouseEvent)
            {
                
    //if (video_mc.currentFrame == video_mc.totalFrames)
                //{
                    //video_mc.gotoAndPlay(2);
                //}
                //else
                //{
                    
    video_mc.play();
                
    //}
            


  3. #3
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    PHP Code:
    package lib
    {
        
    import flash.display.MovieClip;
        
    import flash.events.*;

        public class 
    Controlstry extends MovieClip
        
    {
            public function 
    Controlstry()
            {
                if (
    stage)
                {
                    
    init();
                }
                else
                {
                    
    addEventListener(Event.ADDED_TO_STAGE,init);
                }
            }
            
            private function 
    init(evt:Event null)
            {
                
    removeEventListener(Event.ADDED_TO_STAGE,init);
                if (
    video_mc != null)
                {
                    
    playBtn.addEventListener(MouseEvent.MOUSE_DOWNplayVideo);
                    
    pauseBtn.addEventListener(MouseEvent.MOUSE_DOWNpauseVideo);
                    
    replayBtn.addEventListener(MouseEvent.MOUSE_DOWN,replayVideo);
                }
            }

            private function 
    playVideo(evt:MouseEvent)
            {
                
    //if (video_mc.currentFrame == video_mc.totalFrames)
                //{
                //video_mc.gotoAndPlay(2);
                //}
                //else
                //{
                //video_mc.play();
                //}
                
    video_mc.play();
            }

            private function 
    pauseVideo(evt:MouseEvent)
            {
                
    video_mc.stop();
            }

            private function 
    replayVideo(evt:MouseEvent)
            {
                
    video_mc.gotoAndPlay(2);
            }
        }


  4. #4
    Registered User
    Join Date
    Jul 2015
    Posts
    2
    Quote Originally Posted by fruitbeard View Post
    PHP Code:
    package lib
    {
        
    import flash.display.MovieClip;
        
    import flash.events.*;

        public class 
    Controlstry extends MovieClip
        
    {
            public function 
    Controlstry()
            {
                if (
    stage)
                {
                    
    init();
                }
                else
                {
                    
    addEventListener(Event.ADDED_TO_STAGE,init);
                }
            }
            
            private function 
    init(evt:Event null)
            {
                
    removeEventListener(Event.ADDED_TO_STAGE,init);
                if (
    video_mc != null)
                {
                    
    playBtn.addEventListener(MouseEvent.MOUSE_DOWNplayVideo);
                    
    pauseBtn.addEventListener(MouseEvent.MOUSE_DOWNpauseVideo);
                    
    replayBtn.addEventListener(MouseEvent.MOUSE_DOWN,replayVideo);
                }
            }

            private function 
    playVideo(evt:MouseEvent)
            {
                
    //if (video_mc.currentFrame == video_mc.totalFrames)
                //{
                //video_mc.gotoAndPlay(2);
                //}
                //else
                //{
                //video_mc.play();
                //}
                
    video_mc.play();
            }

            private function 
    pauseVideo(evt:MouseEvent)
            {
                
    video_mc.stop();
            }

            private function 
    replayVideo(evt:MouseEvent)
            {
                
    video_mc.gotoAndPlay(2);
            }
        }


    Thank you it has solved my problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center