Introduced
Through a classic example, the alarm clock, a general idea of drawing and animating using Flash ActionScript 3.0, and learning about the development of custom events through this example
Custom event-inherits from event, a public static const defines the event type, and other public variables define event properties
Paint-executes vector drawing commands through the graphics property of a Shape object
Animation-via Timer object or listener Event.enter_frame event
1. Custom events (custom events triggered after the alarm clock has been set)
Alarmevent.as
Package
{
Import flash.events.Event;
public class AlarmEvent extends Event
{
Defining event Types
public static Const Alarm:string = "ALARM";
Defines the information that is displayed when the alarm clock is ringing
public Var alermmessage:string;
constructor, msg as reminder information
Public Function alarmevent (msg:string = "alarm!")
{
Invokes the constructor of the parent class. parameter is an event type and can be accessed as a event.type
Super (ALARM);
Alermmessage = msg;
}
Overriding the Event's Clone () method
public override function Clone (): Event
{
return new AlarmEvent (alermmessage);
}
Rewrite Event's toString () method
public override function ToString (): String
{
Event.formattostring ()-Implements the utility function of the toString () method in the custom Event class
Return formattostring ("AlarmEvent", "type", "Bubbles", "cancelable", "Eventphase", "message");
}
}
}