/**
* Copyright hacker_xivtwvj1 ( http://wonderfl.net/user/hacker_xivtwvj1 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/yJxs
*/
// forked from hacker_xivtwvj1's flash on 2010-4-16
package
{
import com.bit101.components.PushButton;
import flash.display.Sprite;
import flash.events.Event;
import flash.system.Security;
[SWF(frameRate="24",backgroundColor="#FFFFFF")]
public class type_demo extends Sprite
{
public var boston:Pet;
public var btn2:PushButton;
public var btn3:PushButton;
public var btn4:PushButton;
public var btn5:PushButton;
public var btn6:PushButton;
public var btn7:PushButton;
public var btn8:PushButton;
public var btn9:PushButton;
public var btn10:PushButton;
public var btn11:PushButton;
public var btn12:PushButton;
public function type_demo()
{
boston = new Pet(PetURL.BOSTON);
boston.scaleX = boston.scaleY = 2.0;
boston.x = 150;
boston.y = 300;
addChild(boston);
boston.onLoad=onLoad;
}
public function onLoad():void
{
btn2=new PushButton(this,130,340,"kamatte",onClick);
btn3=new PushButton(this,240,340,"hoeru",onClick);
btn4=new PushButton(this,350,340,"sit",onClick);
btn5=new PushButton(this,20,370,"tatsu",onClick);
btn6=new PushButton(this,130,370,"fuse",onClick);
btn7=new PushButton(this,240,370,"joy",onClick);
btn8=new PushButton(this,350,370,"sad",onClick);
btn9=new PushButton(this,20,400,"dance",onClick);
btn10=new PushButton(this,130,400,"horu",onClick);
btn11=new PushButton(this,240,400,"flip",onClick);
btn12=new PushButton(this,350,400,"buruburu",onClick);
}
public function onClick(e:Event):void
{
boston.playAction(PushButton(e.currentTarget).label);
}
}
public class action_demo extends Sprite
{
public var shiba:Pet;
public var btn1:PushButton;
public function action_demo()
{
boston = new Pet(PetURL.SHIBA);
boston.scaleX = boston.scaleY = 0.5;
boston.x = 400;
boston.y = 300;
addChild(shiba);
boston.onLoad=onLoad;
}
public function onLoad():void
{
btn1=new PushButton(this,20,340,"sleep",onClick);
}
public function onClick(e:Event):void
{
shiba.playAction(PushButton(e.currentTarget).label);
}
}
}
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
class Pet extends Sprite
{
public var onLoad:Function;
private var current:MovieClip;
private var urlLoader:URLLoader;
private var loader:Loader;
public function Pet(url:String)
{
urlLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.addEventListener(Event.COMPLETE, onLoad1);
urlLoader.load(new URLRequest(url));
}
private function onLoad1(e:Event):void
{
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoad2);
loader.loadBytes(urlLoader.data);
}
private function onLoad2(e:Event):void
{
var clazz:Class = loader.contentLoaderInfo.applicationDomain.getDefinition("Pet") as Class;
var pet:MovieClip = new clazz();
pet.front.x = 0;
pet.front.y = 0;
addChild(pet.front);
current = pet.front;
if(onLoad != null) onLoad();
}
public function playAction(code:String):void
{
current.gotoAndPlay(code);
}
}
class PetURL
{
public static var SHIBA:String = "http://stat.ameba.net/training2010/shiba.swf";
// public static var NEKO:String = "http://stat.ameba.net/training2010/neko.swf";
// public static var PANDA:String = "http://stat.ameba.net/training2010/panda.swf";
// public static var KAME:String = "http://stat.ameba.net/training2010/kame.swf";
public static var BOSTON:String = "http://stat.ameba.net/training2010/boston.swf";
}