In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: forked from: Progression Command Test

Progression 俺俺コマンド Test
Get Adobe Flash player
by hacker_mdkhktcb 20 Sep 2009
    Embed
// forked from jakeno's forked from: Progression Command Test
// forked from northprint's Progression Command Test
// write as3 code here..
// Progression 俺俺コマンド Test
package {  
    import flash.display.Sprite;  
    import jp.progression.commands.*;
    
    public class Prog_test2 extends Sprite {  

         public function Prog_test2(){  
            var sList:SerialList = new SerialList();
            sList.addCommand(
                new PlayMovie(this, "http://narayama.heteml.jp/movie/P1020474.flv", 400, 300, true)
            );
            sList.execute();  
        }  
    }
}

import jp.progression.commands.*;
import jp.progression.core.commands.Command; 
import flash.display.DisplayObjectContainer;  
import flash.events.NetStatusEvent;  
import flash.media.Video;  
import flash.net.NetConnection;  
import flash.net.NetStream;  
import caurina.transitions.Tweener;

class PlayMovie extends Command{  
    private var _movieURL:String;
    private var _movieWidth:uint;
    private var _movieHeight:uint;
    private var _connection:NetConnection;
    private var _netStream:NetStream;
    private var _obj:Object;
    private var _movieObj:Video;  
    private var _movieContainer:DisplayObjectContainer;
    private var _waitForComplete:Boolean = false;

    public function PlayMovie(container:DisplayObjectContainer = null, movieURL:String = null, movieWidth = 0, movieHeight = 0, waitForComplete:Boolean = false, initObject:Object = null ){
        _movieURL = movieURL;
        _movieWidth = movieWidth;
        _movieHeight = movieHeight;
        _movieContainer = container;
        _waitForComplete = waitForComplete;
        super( _execute, _interrupt, initObject );
    }

    //MOVIEの状態
    private function onMovieProgress (event : NetStatusEvent) {
        if (event.info.code == "NetStream.Play.Stop"){
            if ( _waitForComplete ) {
                executeComplete();
            }
            //ムービーが終わったらフェードアウトする
            Tweener.addTween(_movieObj,{
                            alpha:0,time:1,onComplete:endExec});
        }
    }
    //イニシャライズ処理
    private function initStream():void {
        _netStream = new NetStream(_connection);
        _movieObj = new Video();
        var customClient:Object = new Object();
        _netStream.client = customClient;
        //指定されたコンテナの表示リストに追加
        _movieContainer.addChild(_movieObj);
        //幅、高さ設定
        _movieObj.width = _movieWidth;
        _movieObj.height = _movieHeight;
        _movieObj.attachNetStream(_netStream);
        //再生
        _netStream.play(_movieURL);
        _netStream.addEventListener(NetStatusEvent.NET_STATUS, onMovieProgress);
        //ムービー完了待ちをするかどうか
        if ( _waitForComplete ) {
            return;
        }
        executeComplete();
    }
    //終了処理  
    private function endExec():void {
        if (_movieObj) {
            if ( _waitForComplete ) {
                _netStream.removeEventListener(NetStatusEvent.NET_STATUS , onMovieProgress);
            }
            _movieContainer.removeChild(_movieObj);
            _movieObj = null;
            _netStream.close();
            _netStream = null;
            _connection = null;
        }
    }
    private function _execute():void{
        //長いムービーだとタイムアウトになるから
        timeOut = 0;
        //初期処理
        _connection = new NetConnection();
        _connection.connect(null);
        initStream();
    }         
    private function _interrupt():void{
        endExec();
        // 中断処理を終了します
        interruptComplete();
    }
    public override function clone():Command{
        return new PlayMovie( _movieContainer,_movieURL,_movieWidth,_movieHeight,_waitForComplete,this );
    }
    
}