flsg -> RE: Flash Q&A Thread 4 (8/28/2007 22:50:23)
|
somebody621: this is the getter/setter I'm talking about. The real ones are: public function set mass(m:Number):void{} public function get mass():Number{} use: mass=123//execute the function set mass() but I don't like the real getter/setter method. It's like giving a name to a variable, which already has a name BTW, m could be uint in AS3 also, remove the "_" before your variables, that's "cool" in AS2 only. Now variables without "_" is cool. XD EragonZZZZ: a custom event is something like a watch() function or checking a variable value in an onEnterFrame is AS2. In AS2, when the value changes, you track it with a conditional statement, then do some code. In AS3, if you fire a costum event, everything that register for that event get the notification(doesn't need to be a variable change). For example: //in the "Player" class:
public static const PLAYER_DEAD:String="player_dead"
//later, when the player dies:
dispatchEvent(new Event(Player.PLAYER_DEAD))
//in any other class, they register for that event(for example, a Screen class):
var myP:Player=new Player()
myP.addEventListener(Player.PLAYER_DEAD, dispLoseWord)
private function dispLoseWord(e:Event):void{
stage.addChild(youLose_mc)
} the PLAYER_DEAD's value could be anything, you won't use it I hope this is clear enough Very nice Flsg, you're my AS hero!!! < Message edited by Artix -- 8/28/2007 22:55:37 >
|
|
|
|