A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Play local FLV file using AS 2.0

  1. #1
    Registered User
    Join Date
    Dec 2015
    Posts
    1

    Play local FLV file using AS 2.0

    Hi guys,

    I'm using basic AS2 for loading up a video file and playing it. While playing it, i needed to pause it as say, 5 seconds and then wait for me to push a button. Upon pushing the button it should resume. Please look at this and let me know where i'm going wrong? The video loads, and plays, and pauses at 5 seconds as meant to. It also shows the button which is, until that point hidden. But the button doesn't un-pause when i click? The funny thing is, the button does pause and un-pause if you use it anytime before the loop has implemented the stop.

    Here's the code to load the video:
    Code:
    // load video
    var nc:NetConnection = new NetConnection();
    nc.connect(null);
    myNetStream = new NetStream(nc);
    videoPlayer1.attachVideo(myNetStream);
    myNetStream.play("_assets/16_airplane.flv");
    
    // show timer
    function checkTime() {
    var ns_seconds:Number = myNetStream.time();
    trace(ns_seconds)
    }
    
    // monitor the time and stop when meant to
    setInterval(checkTime,10);
    function checkTime():Void{
    if(Math.floor(myNetStream.time) == 5){
    btn_sometimes._alpha = 20;
    myNetStream.pause();
    }
    }
    And here's the code on the button:
    Code:
    on (release) {
    	myNetStream.play();
    	
    }
    Any ideas?

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

    PHP Code:
    var ns_checker:Number;
    var 
    ns_seconds:Number;
    var 
    ns_trueTime:Number;

    ns_checker setInterval(checkTime10);

    function 
    checkTime():Void
    {
        
    ns_seconds Math.floor(myNetStream.time);
        
    trace(ns_seconds);
        
        
    ns_trueTime myNetStream.time;
        
    trace(ns_trueTime);

        if (
    ns_seconds >= 5)
        {
            
    btn_sometimes._alpha 20;
            
    myNetStream.pause();

            
    clearInterval(ns_checker);
        }

    PHP Code:
    on (release)
    {
        
    _root.myNetStream.pause();

    or
    PHP Code:
    on (release)
    {
        
    _parent.myNetStream.pause();

    or
    PHP Code:
    on (release)
    {
        
    this._parent.myNetStream.pause();

    Last edited by fruitbeard; 12-02-2015 at 12:31 PM.

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