my actorclass currently works
however i want to add collision sounds on a per actor basis. i have defined a var _sound:Sound and have tried to add a third peramiter to function gameActor as mySound:Sound and set _sound = mySound. but when i call _sound.play i get errors. how would i go about getting it to read a sound from the library in a similar way to movieclips so i could name the sounds linkage to what i want depending on the actor.
Code:
package
{
import flash.display.DisplayObject;
import flash.events.EventDispatcher;
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import flash.media.Sound;
/**
* ...
* @author ...
*/
public class gameActor extends EventDispatcher
{
protected var _body:b2Body;
protected var _costume:DisplayObject;
protected var _sound:Sound;
public function gameActor(myBody:b2Body, myCostume:DisplayObject)
{
_body = myBody;
_costume = myCostume
updateMyLook();
}
public function updateNow():void
{
updateMyLook();
childSpecificUpdating();
}
protected function childSpecificUpdating():void
{
}
public function destroy():void
{
//todo
}
private function updateMyLook():void
{
_costume.x = _body.GetPosition().x * Physivals.RATIO;
_costume.y = _body.GetPosition().y * Physivals.RATIO;
_costume.rotation = _body.GetAngle() * 180 / Math.PI;
}
}
}
{
import flash.display.DisplayObject;
import flash.events.EventDispatcher;
import Box2D.Collision.*;
import Box2D.Common.Math.*;
import Box2D.Dynamics.*;
import Box2D.Collision.Shapes.*;
import flash.media.Sound;
/**
* ...
* @author ...
*/
public class gameActor extends EventDispatcher
{
protected var _body:b2Body;
protected var _costume:DisplayObject;
protected var _sound:Sound;
public function gameActor(myBody:b2Body, myCostume:DisplayObject)
{
_body = myBody;
_costume = myCostume
updateMyLook();
}
public function updateNow():void
{
updateMyLook();
childSpecificUpdating();
}
protected function childSpecificUpdating():void
{
}
public function destroy():void
{
//todo
}
private function updateMyLook():void
{
_costume.x = _body.GetPosition().x * Physivals.RATIO;
_costume.y = _body.GetPosition().y * Physivals.RATIO;
_costume.rotation = _body.GetAngle() * 180 / Math.PI;
}
}
}
however i want to add collision sounds on a per actor basis. i have defined a var _sound:Sound and have tried to add a third peramiter to function gameActor as mySound:Sound and set _sound = mySound. but when i call _sound.play i get errors. how would i go about getting it to read a sound from the library in a similar way to movieclips so i could name the sounds linkage to what i want depending on the actor.