The UI method created by the as3 script using flash CS6

Source: Internet
Author: User

I have never touched on flash development before. I didn't know how to call the UI and as3 script created in Flash connector stional CS6. After learning, you need to know two methods:

1. Flash CS6 releases the entire FLA as SWC, which is used for direct compilation with flashdevelop. The object is directly compiled into SWF.

2. Flash CS6 is released as SwF, and as3 is loaded during loader running.

The first method is more direct. I will record the second method.

First, flash CS6 releases FLA into SWF.

As loads SWF through loader, in a class inherited from sprite:

Public class main extends sprite {private var City: SPRITE; private var TF: textfield; public function main (): void {If (stage) Init (); else addeventlistener (event. added_to_stage, init);} private function Init (E: event = NULL): void {removeeventlistener (event. added_to_stage, init); TF = new textfield; TF. TEXT = "init text"; addchild (TF); var helloloader: loader = new loader; var URL: URLRequest = new URLRequest ("abc.swf"); helloloader. load (URL); helloloader. contentloaderinfo. addeventlistener (event. complete, oncomplete);} private function oncomplete (Event: Event): void {city = event.tar get. content as sprite; // The root container addchild (city) created by Flash CS; var BTN: displayobject = city. getchildbyname ("btn_ OK"); // a button on the container. Get this object if (BTN! = NULL) BTN. addeventlistener (mouseevent. Click, onclick);} private function onclick (Event: mouseevent): void {TF. Text = "Click BTN ";}

Let's take a look at oncomplete, mainly in the method of getting the root container and a component by name.

This is confusing when you don't know it. After you know it, it feels very natural and simple.

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.