
Untitled
By: a guest on
Aug 10th, 2012 | syntax:
None | size: 1.46 KB | hits: 7 | expires: Never
import flash.events.Event;
import com.whirled.AvatarControl;
if (_ctrl == null) {
_ctrl = new AvatarControl(this);
_body = new Body(_ctrl, this, 240);
_ctrl.addEventListener(Event.UNLOAD, handleUnload);
function handleUnload (... ignored) :void {
_body.shutdown();
}
}
var _ctrl :AvatarControl;
var _body :Body;
//Change the 0.2 below to change how high above the floor the avatar will appear once it is moved. 0 is the floor and 1 is the ceiling
function fly():void{
updateRoom();
flyHeight = (roomSize[1] as int)*0.4;
_ctrl.setPreferredY(flyHeight);
}
function unFly():void{
_ctrl.setPreferredY(0);
}
function updateRoom():void{
roomSize = _ctrl.getRoomBounds();
}
var flyHeight:int = 0;
var roomSize:Array = new Array(100,100,100);
_ctrl.addEventListener(ControlEvent.STATE_CHANGED, stateHandler);
_ctrl.addEventListener(ControlEvent.ACTION_TRIGGERED, actionHandler);
function stateCodeSwitch ()
{
switch (_ctrl.getState())
{
case "<statenamehere>":
//code for that state like hotspot and movespeed
break;
/*
just keep adding
case "<statenamehere>":
//code for that state like hotspot and movespeed
break;
for any other states you want to have altered coding for
*/
default:
//The hotspot and movespeed for the avatar when it's normal goes here
break;
}
}
function stateHandler (event:ControlEvent)
{
stateCodeSwitch();
}
case "land":
//coding
break;