Add up Flash (5)

Source: Internet
Author: User
Tags constructor

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");
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.