Game Development Reference
In-Depth Information
super(type, bubbles,cancelable);
this.text = text;
}
public override function clone():Event {
return new CustomEventLevelScreenUpdate(type,text,
bubbles,cancelable)
}
}
}
The only real differences in all three of the custom Event classes we will create are the constant
values used to create an instance of the event and the data that is passed along with the event:
public static const UPDATE_TEXT:String = "update level text";
public var text:String;
We also need to modify the constructor and the clone functions for the new data passed.
The CustomEventScoreBoardUpdate class
This custom Event class is very similar to to CustomEventButtonId and
CustomEventLevelScreenUpdate classes. It is used to pass two String values back to the
listening function. Specifically, it is used by the GameFrameWork.as to add text to update elements
on the ScoreBoard class instance.
Create the CustomEventScoreBoardUpdate.as file in the framework package structure we created
earlier:
/source/classes/com/efg/framework/CustoEventScoreBoardUpdate.as
Here is entire code listing for this class:
package com.efg.framework
{
import flash.events.Event;
/**
* ...
* @author Jeff Fulton
*/
public class CustomEventScoreBoardUpdate extends Event {
public static const UPDATE_TEXT:String =
"update scoreboard text";
public var element:String;
public var value:String;
public function CustomEventScoreBoardUpdate(type:
String,element:String, value:String,
bubbles:Boolean=false,cancelable:Boolean=false) {
super(type, bubbles,cancelable);
this.element = element;
this.value = value;
}
Search WWH ::




Custom Search