home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mobiclic 161
/
MOBICLIC161.ISO
/
pc
/
DATA
/
DSS161
/
DSS161_00
/
DSS161_00.swf
/
scripts
/
dss161
/
engineaddons
/
gamesprotos
/
Actor.as
next >
Wrap
Text File
|
2014-01-15
|
9KB
|
345 lines
package dss161.engineaddons.gamesprotos
{
import com.milanpresse.engine.config.Config;
import dss161.engineaddons.facades.GameEngine;
import flash.display.MovieClip;
import flash.display.Stage;
import flash.system.ApplicationDomain;
public dynamic class Actor implements IElementBase
{
public static var game:GameEngine;
protected var _e:GameEngine;
public var config:Config;
public var stage:Stage;
protected var actors:Vector.<Actor>;
protected var _name:String;
protected var _parentActor:Actor = null;
protected var isSleeping:Boolean = false;
public var vars:Object;
protected var sleepExtern:Function = null;
protected var wakeExtern:Function = null;
protected var destroyExtern:Function = null;
public function Actor(param1:GameEngine = null, param2:Actor = null, param3:* = null)
{
this.actors = new Vector.<Actor>();
this.vars = {};
super();
if(param1 != null)
{
Actor.game = param1;
}
this._e = Actor.game;
this.stage = Actor.game.stage;
this._parentActor = param2;
}
public function start() : void
{
}
public function addActor(param1:* = undefined) : *
{
var mc:MovieClip = null;
var actor:Actor = null;
var classe:Class = null;
var prop:String = null;
var params:* = param1;
if(params is Actor)
{
this.actors.push(params);
params.parentActor = this;
return params;
}
if(params == undefined)
{
params = {"type":Actor};
actor = new Actor(game);
}
else
{
if(params.type == undefined || params.type == null)
{
classe = ApplicationDomain.currentDomain.getDefinition("dss161.engineaddons.gamesprotos.actors.actorClip.ActorClip") as Class;
}
else if(params.type is Class)
{
classe = params.type;
}
else if(params.type is String)
{
classe = ApplicationDomain.currentDomain.getDefinition(params.type) as Class;
}
delete params.type;
try
{
actor = classe["create"](this._e,params);
}
catch(err:Error)
{
actor = new classe(params);
}
}
if(actor == null)
{
for(prop in params)
{
}
return null;
}
actor.parentActor = this;
if(params.name != undefined)
{
actor.name = params.name;
}
this.actors.push(actor);
return actor;
}
public function getActors() : Array
{
var _loc1_:Array = [];
var _loc2_:int = 0;
while(_loc2_ < this.actors.length)
{
_loc1_.push(this.actors[_loc2_]);
_loc2_++;
}
return _loc1_;
}
public function getActor(param1:*) : *
{
var _loc2_:int = 0;
var _loc3_:int = 0;
if(param1 is Actor)
{
_loc2_ = this.actors.indexOf(param1);
if(_loc2_ != -1)
{
return this.actors[_loc2_];
}
}
else if(param1 is String)
{
_loc3_ = 0;
while(_loc3_ < this.actors.length)
{
if(this.actors[_loc3_].name == param1)
{
return this.actors[_loc3_];
}
_loc3_++;
}
}
return null;
}
public function removeActor(param1:Actor) : void
{
if(this.actors.indexOf(param1) != -1)
{
this.actors.splice(this.actors.indexOf(param1),1);
}
}
public function get sleep() : Function
{
return this._sleep;
}
public function set sleep(param1:Function) : void
{
this.sleepExtern = param1;
}
protected function _sleep() : void
{
if(this.sleepExtern != null)
{
this.sleepExtern();
}
var _loc1_:int = 0;
while(_loc1_ < this.actors.length)
{
if(this.actors[_loc1_] != null)
{
this.actors[_loc1_].sleep();
}
_loc1_++;
}
}
public function get wake() : Function
{
return this._wake;
}
public function set wake(param1:Function) : void
{
this.wakeExtern = param1;
}
protected function _wake() : void
{
if(this.wakeExtern != null)
{
this.wakeExtern();
}
var _loc1_:int = 0;
while(_loc1_ < this.actors.length)
{
if(this.actors[_loc1_] != null)
{
this.actors[_loc1_].wake();
}
_loc1_++;
}
}
public function foreach(param1:Function) : void
{
var _loc2_:Vector.<Actor> = this.actors.slice();
var _loc3_:int = _loc2_.length;
var _loc4_:int = 0;
while(_loc4_ < _loc3_)
{
if(_loc2_[_loc4_] != null)
{
param1(_loc2_[_loc4_]);
}
_loc4_++;
}
}
public function get destroy() : Function
{
return this._destroy;
}
public function set destroy(param1:Function) : void
{
this.destroyExtern = param1;
}
public function getByProperty(param1:String, param2:*) : *
{
var _loc3_:int = this.actors.length;
var _loc4_:int = 0;
while(_loc4_ < _loc3_)
{
if(this.actors[_loc4_].hasOwnProperty(param1) && this.actors[_loc4_][param1] == param2)
{
return this.actors[_loc4_];
}
_loc4_++;
}
return null;
}
public function destroyChildren() : void
{
var _loc1_:Vector.<Actor> = this.actors.slice();
var _loc2_:int = _loc1_.length;
var _loc3_:int = 0;
while(_loc3_ < _loc2_)
{
if(_loc1_[_loc3_] != null)
{
_loc1_[_loc3_].destroy();
}
_loc3_++;
}
this.actors.length = 0;
}
protected function _destroy() : void
{
if(this.destroyExtern != null)
{
this.destroyExtern();
}
var _loc1_:Vector.<Actor> = this.actors.slice();
var _loc2_:int = _loc1_.length;
var _loc3_:int = 0;
while(_loc3_ < _loc2_)
{
if(_loc1_[_loc3_] != null)
{
_loc1_[_loc3_].destroy();
}
_loc3_++;
}
this.actors.length = 0;
if(this._parentActor != null)
{
this._parentActor.removeActor(this);
}
}
public function restore() : void
{
var _loc1_:Vector.<Actor> = this.actors.slice();
var _loc2_:int = _loc1_.length;
var _loc3_:int = 0;
while(_loc3_ < _loc2_)
{
if(_loc1_[_loc3_] != null)
{
_loc1_[_loc3_].restore();
}
_loc3_++;
}
}
public function dissociate() : void
{
var _loc1_:Vector.<Actor> = this.actors.slice();
var _loc2_:int = _loc1_.length;
var _loc3_:int = 0;
while(_loc3_ < _loc2_)
{
if(_loc1_[_loc3_] != null)
{
_loc1_[_loc3_].dissociate();
}
_loc3_++;
}
}
public function get name() : String
{
return this._name;
}
public function set name(param1:String) : void
{
this._name = param1;
}
public function get parentActor() : Actor
{
return this._parentActor;
}
public function set parentActor(param1:Actor) : void
{
this._parentActor = param1;
}
}
}