Add up Flash (4)

Source: Internet
Author: User

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----* *
}
}

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.