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

スマイリーマークっぽいもの(ループ処理)

ProgressionのCommandでスマイリーマークっぽいものを作ってみる
// forked from flabaka's スマイリーマークっぽいもの
//ProgressionのCommandでスマイリーマークっぽいものを作ってみる
package {
	import flash.display.Sprite;
	import jp.progression.commands.*;
	import jp.progression.core.commands.*;
	
	public class Main extends Sprite {
		
		public function Main() {

			//シリアルリストインスタンス作成
			var s:Sprite = new Sprite();
			var loopList:SerialList = new SerialList();
			var sList:SerialList = new SerialList();
			//線の設定
			s.graphics.lineStyle(3,0x000000);
			
			//コマンド登録
			loopList.addCommand(
				new AddChild(this, s),
				function():void{
					s.graphics.beginFill(0xFFFF33);
					s.graphics.drawCircle(100,100,50);
					s.graphics.endFill();
				},
				new Wait(1000),
				function():void{
					s.graphics.beginFill(0x000000);
					s.graphics.drawEllipse(80,78,10,20);
					s.graphics.endFill();
				},
				new Wait(1000),
				function():void{
					s.graphics.beginFill(0x000000);
					s.graphics.drawEllipse(110,78,10,20);
					s.graphics.endFill();
				},
				new Wait(1000),
				function():void{
					s.graphics.moveTo(75,110);
					s.graphics.curveTo(75,120,65,120);
				},
				new Wait(1000),
				function():void{
					s.graphics.moveTo(125,110);
					s.graphics.curveTo(125,120,135,120);
				},
				new Wait(1000),
				function():void{
					s.graphics.moveTo(72,118);
					s.graphics.curveTo(100,150,128,118);
				},
				new Wait(1000),
				function():void{
					s.graphics.moveTo(128,118);
					s.graphics.curveTo(100,156,72,118);
				},
				new Wait(1000),
				new DoTweener(s,{x: 150,y:150,scaleX:2,scaleY:2,time:2})
			);
			//ループコマンドを使って顔を描写させる
			sList.addCommand(new LoopCommand(loopList));
                        //コマンド実行
                        sList.execute();
		}	
	}
}

//northprintさんのループコマンドを使わせてもらう
import jp.progression.commands.*;  
import jp.progression.core.commands.Command;   
import jp.progression.events.*;

class LoopCommand extends Command{
    
    private var _command:Command;
    public function LoopCommand(command:Command,initObject:Object = null){
        super( _execute, _interrupt, initObject );
        _command = command;
    }
    private function _execute():void{
        _command.addEventListener(CommandEvent.COMMAND_COMPLETE,commandComp);
        _command.execute();
        executeComplete();
    }
    private function commandComp(e:CommandEvent):void{
        _command.execute();
    }  
    private function _interrupt():void{
        _command.removeEventListener(CommandEvent.COMMAND_COMPLETE,commandComp);
        interruptComplete();
    }  
    public override function clone():Command{
        return new LoopCommand(_command);  
    }
}