import jp.ojos.movieclip.BaseMovieClip; import org.casaframework.time.Interval; /** * BaseMovieClipの使用サンプル * * @author Tsuyoshi Aizu */ class Main_BaseMovieClip extends BaseMovieClip { private var _mc:BaseMovieClip; private var n:Number; function Main_BaseMovieClip() { super( ); this._onLoad = function():Void { var _si:Interval = Interval.setInterval( this, '$change', 2000 ); _si.setReps( 4 ); _si.start( ); }; this.n = 0; this.$change( ); } private function $change():Void { switch(this.n) { case 0 : this._mc = BaseMovieClip.create( this, '_mc', this.getNextHighestDepth( ), { onConstract:function():Void { this['init']( false, {_init:function():Void { trace(this); }} ); this['onEnterFrame'] = function():Void { this['dispatchEvent']('onEnterFrame', this); }; } }); this._mc.addEventObserver( this, BaseMovieClip.EVENT_INIT_COMPLETE ); this._mc.addEventObserver( this, 'onEnterFrame', '$onEnterFrame' ); break; case 1 : this._mc.removeEventObserver( this, BaseMovieClip.EVENT_INIT_COMPLETE ); this._mc.removeEventObserver( this, 'onEnterFrame', '$onEnterFrame' ); this._mc.addEventObserver( this, BaseMovieClip.EVENT_LOCK ); this._mc.lock( ); break; case 2 : this._mc.removeEventObserver( this, BaseMovieClip.EVENT_LOCK ); this._mc.addEventObserver( this, BaseMovieClip.EVENT_UNLOCK ); this._mc.unlock( ); break; case 3 : this._mc.removeEventObserver( this, BaseMovieClip.EVENT_UNLOCK ); this._mc.addEventObserver( this, BaseMovieClip.EVENT_MOUSE_DOWN, '$onMouseDown' ); this._mc.addEventObserver( this, BaseMovieClip.EVENT_MOUSE_UP, '$onMouseUp' ); this._mc.addEventObserver( this, BaseMovieClip.EVENT_MOUSE_MOVE, '$onMouseMove' ); break; case 4 : this._mc.removeEventObserver( this, BaseMovieClip.EVENT_MOUSE_DOWN, '$onMouseDown' ); this._mc.removeEventObserver( this, BaseMovieClip.EVENT_MOUSE_UP, '$onMouseUp' ); this._mc.removeEventObserver( this, BaseMovieClip.EVENT_MOUSE_MOVE, '$onMouseMove' ); this._mc.addEventObserver( this, BaseMovieClip.EVENT_UNLOAD, '$onUnload' ); //this._mc.addEventObserver(this, BaseMovieClip.EVENT_DATA, '$onData'); //this._mc.addEventObserver(this, BaseMovieClip.EVENT_LOAD, '$onLoad'); this._mc.loadMovie( 'main.jpg' ); break; } this.n++; } private function onLock(sender:BaseMovieClip):Void { trace( sender + '.lock' ); }; private function onUnlock(sender:BaseMovieClip):Void { trace( sender + '.unlock' ); }; private function onInitComplete(sender:BaseMovieClip):Void { trace( sender + '.init' ); }; //private function $onData(sender:BaseMovieClip) : Void { trace(sender + '.onData'); }; private function $onEnterFrame(sender:BaseMovieClip):Void { trace( sender + '.onEnterFrame' ); }; //private function $onLoad(sender:BaseMovieClip) : Void { trace(sender + '.onLoad'); }; private function $onUnload(sender:BaseMovieClip):Void { trace( sender + '.onUnload' ); }; private function $onMouseDown(sender:BaseMovieClip):Void { trace( sender + '.MouseDown' ); }; private function $onMouseUp(sender:BaseMovieClip):Void { trace( sender + '.MouseUp' ); }; private function $onMouseMove(sender:BaseMovieClip):Void { trace( sender + '.MouseMove' ); }; }