Progression4 Amateur
/**
* Copyright checkmate ( http://wonderfl.net/user/checkmate )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/o8xA
*/
package {
import flash.display.*;
import flash.events.*;
import jp.progression.casts.*;
import jp.progression.commands.*;
import jp.progression.commands.lists.*;
import jp.progression.commands.net.*;
import jp.progression.config.*;
import jp.progression.data.*;
import jp.progression.events.*;
import jp.progression.scenes.*;
import jp.progression.*;
[SWF( width=465, height=465, backgroundColor=0xFFFFFF, frameRate=30 )]
public class Amateur extends Sprite {
public var manager:Progression, self:Amateur;
// Graphics
public var face:MovieClip;
public var hair:MovieClip;
public var eyeBrowLeft:MovieClip, eyeBrowRight:MovieClip;
public var eyeLeft:MovieClip, eyeRight:MovieClip;
public var nose:MovieClip;
public var mouth:MovieClip;
private var _status:Array;
// Do Something
public function atReady():void {
addChild( face );
addChild( mouth );
addChild( nose );
addChild( eyeLeft );
addChild( eyeRight );
addChild( eyeBrowLeft );
addChild( eyeBrowRight );
addChild( hair );
_status = [];
for ( var i:int = 0, l:int = numChildren; i < l; i++ ) {
var child:DisplayObject = getChildAt( i );
_status.push( {
x:child.x,
y:child.y,
scaleX:child.scaleX,
scaleY:child.scaleY,
rotation:child.rotation
} );
}
stage.addEventListener( MouseEvent.CLICK, _click );
}
private function _click( e:MouseEvent ):void {
for ( var i:int = 0, l:int = numChildren; i < l; i++ ) {
var child:DisplayObject = getChildAt( i );
var status:Object = _status[i];
child.x = status.x + ( Math.random() - 0.5 ) * 10;
child.y = status.y + ( Math.random() - 0.5 ) * 10;
child.scaleX = status.scaleX + ( Math.random() - 0.5 ) / 2;
child.scaleY = status.scaleY + ( Math.random() - 0.5 ) / 2;
child.rotation = status.rotation + ( Math.random() - 0.5 ) * 10;
}
}
public function Amateur() {
CheckmateBuilder.initialize( this );
}
}
}
import flash.display.*;
import flash.events.*;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import jp.progression.casts.*;
import jp.progression.commands.*;
import jp.progression.commands.lists.*;
import jp.progression.commands.net.*;
import jp.progression.config.*;
import jp.progression.data.*;
import jp.progression.events.*;
import jp.progression.scenes.*;
import jp.progression.*;
class CheckmateBuilder extends EventDispatcher {
public static var GRAPHICS_URL:String = "http://swf.wonderfl.net/static/assets/checkmate04/AmateurAssets.swf";
private static var _target:Amateur;
private static var _manager:Progression;
public static function initialize( target:Amateur ):void {
if ( _target ) { return; }
_target = target;
_target.self = target;
Progression.initialize( new BasicAppConfig() );
_manager = new Progression( "index", _target.stage );
_manager.root.addEventListener( SceneEvent.SCENE_LOAD, _sceneLoad );
_manager.root.addEventListener( SceneEvent.SCENE_INIT_COMPLETE, _sceneInitComplete );
_manager.goto( _manager.root.sceneId );
}
private static function _sceneLoad( e:SceneEvent ):void {
_manager.root.addCommand(
new LoadSWF( new URLRequest( GRAPHICS_URL ) ),
function():void {
var loader:Loader = Loader( this.latestData );
var domain:ApplicationDomain = loader.contentLoaderInfo.applicationDomain;
_target.face = new ( domain.getDefinition( "Face" ) as Class );
_target.face.x = 234;
_target.face.y = 242;
_target.hair = new ( domain.getDefinition( "Hair" ) as Class );
_target.hair.x = 233;
_target.hair.y = 194;
_target.eyeBrowRight = new ( domain.getDefinition( "EyeBrowRight" ) as Class );
_target.eyeBrowRight.x = 190;
_target.eyeBrowRight.y = 218;
_target.eyeBrowLeft = new ( domain.getDefinition( "EyeBrowLeft" ) as Class );
_target.eyeBrowLeft.x = 270;
_target.eyeBrowLeft.y = 218;
_target.eyeRight = new ( domain.getDefinition( "EyeRight" ) as Class );
_target.eyeRight.x = 190;
_target.eyeRight.y = 248;
_target.eyeLeft = new ( domain.getDefinition( "EyeLeft" ) as Class );
_target.eyeLeft.x = 272;
_target.eyeLeft.y = 243;
_target.nose = new ( domain.getDefinition( "Nose" ) as Class );
_target.nose.x = 236;
_target.nose.y = 275;
_target.mouth = new ( domain.getDefinition( "Mouth" ) as Class );
_target.mouth.x = 242;
_target.mouth.y = 322;
}
);
}
private static function _sceneInitComplete( e:SceneEvent ):void {
_target.atReady();
}
}