Pure as preloader created using [frame ()] data labels

Source: Internet
Author: User

 

The principle is to use the [frame ()] label to change the orientation of the document class. For specific operations, you can check on the Internet. There is a lot of information in this regard. I will only post the source code here and share it with you.

Code

 1 default program entry:
2
3 Package
4 {
5 import flash. display. Sprite;
6 Import MX. Core. bitmapasset;
7
8 [frame (factoryclass = "systemmanager", label = "hello")]
9
10 public class myapplication extends sprite {
11
12 [embed (Source = "test.png")]
13 private var bigpiccls: class;
14
15 public function myapplication (){
16 var B: bitmapasset = new bigpiccls () as bitmapasset;
17 addchild (B );
18}
19}
20}
21
22

 

Code

 1. Main Document class pointed:
2
3 package {
4 Import flash. display. displayobject;
5 import flash. display. movieclip;
6 Import flash. display. stagealign;
7 Import flash. display. stagescalemode;
8 Import flash. Events. event;
9 Import flash. Events. progressevent;
10 Import flash. utils. getdefinitionbyname;
11
12 public class systemmanager extends movieclip
13 {
14 private var preloader: preloader;
15
16 public function systemmanager (){
17 stage. scalemode = stagescalemode. no_scale;
18 stage. align = stagealign. top_left;
19
20 stop ();
21
22 preloader = new preloader ();
23 addchild (preloader );
24
25 preloader. x = stage. stagewidth/2-preloader. width/2;
26 preloader. x = stage. stageheight/2-preloader. Height/2;
27
28 loaderinfo. addeventlistener (progressevent. Progress, progresshandle );
29 loaderinfo. addeventlistener (event. Complete, completehandler );
30}
31
32 private function progresshandle (E: progressevent): void
33 {
34 preloader. setprogress (E. bytesloaded, E. bytestotal );
35}
36
37 private function completehandler (E: Event): void {
38 loaderinfo. removeeventlistener (progressevent. Progress, progresshandle );
39 loaderinfo. removeeventlistener (event. Complete, completehandler );
40
41 removechild (preloader );
42 preloader = NULL;
43
44 nextframe ();
45
46 initapplication ();
47}
48
49 private function initapplication (): void {
50/** cannot be written directly here:
51 var app: Application = new application ();
52. all resources in the application will be compiled to the first frame.
53. In this case, preloader will be meaningless, and you will not be able to see preloader, so you will jump to the second frame.
54 **/
55 var appcls: class = getdefinitionbyname ("myapplication") as class;
56 var app: displayobject = new appcls () as displayobject;
57 addchild (APP );
58}
59}
60}
61
62
Code

 1 progress bar:
2
3 Package
4 {
5 import flash. display. Sprite;
6 Import flash. Text. textfield;
7
8 public class preloader extends Sprite
9 {
10 public function preloader ()
11 {
12 var T: textfield = new textfield ();
13 T. Border = true;
14 t. Text = "loading ......";
15
16 addchild (t );
17}
18
19 public function setprogress (loaded: uint, total: uint): void
20 {
21 var T: textfield = getchildat (0) as textfield;
22 t. Text = "load:" + loaded/1000 + "/" + total/1000;
23
24 trace ("load:" + loaded/1000 + "/" + total/1000 );
25}
26}
27}
28

 

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.