Introduced
With 3 simple examples, there is a perceptual understanding of using the Flash ACTIONSCRIPT 3.0 Development Program
Hello World-demonstrates the most basic interaction. By pressing a button, the corresponding information is displayed on the UI
Clock-demonstrates how to do the most basic animation processing. That is, when the clock, the minute, the second hand do the rotation animation
Timer-demonstrates a slightly more complex interaction. That is, a timer that you can start, pause, and stop operations on.
1, Hello World
A label named Lblmsg is placed on the UI, a textinput named Txtname, a button named Btnhello
Greeter.as
// 包名称要与文件的目录结构对应,类名称要与文件名对应
package code
{
/**//*
* 打招呼类
*/
public class Greeter
{
/**//*
* 打招呼方法
* @param name 名称
* @return 打招呼的结果
*/
public static function sayHello(name:String = "World"):String
{
return "<font color='#FFFFFF'>Hello: " + name + "</font>";
}
}
}
Hello.as
Package
Package
{
Import related Classes
Import Flash.display.MovieClip;
Import fl.events.ComponentEvent;
Import flash.events.TimerEvent;
Import Flash.utils.Timer;
Import Flash.text.TextField;
Import Flash.display.SimpleButton;
Import flash.events.MouseEvent;
Import flash.events.Event;
Import Flash.utils.getTimer;
Import code. Greeter;
public class Hello extends MovieClip
{
Constructors
Public Function Hello ()
{
Inithello ();
}
/**//*----Hello to start the Demo----* *
function Inithello ()
{
Assign a value to the HTMLText property of a Label component
Lblmsg.htmltext = Greeter.sayhello ();
Adding an event handler for an object (first argument: event type; second argument: event handler, i.e. a method)
Txtname.addeventlistener (Componentevent.enter, SayHello);
Btnhello.addeventlistener (Componentevent.button_down, SayHello);
}
function SayHello (e:componentevent): void
{
Lblmsg.htmltext = Greeter.sayhello (txtName.Text);
}
/**//*----Hello Demo End----* *
}
}