[FlashDevelop] 002.FlashDevelop + layaflash play swf and turn to HTML5

Source: Internet
Author: User

In the previous tutorial, I explained how to build the FlashDevelop environment and create a small demo of Hello. So next, let's look at how to implement the SWF file and turn it into a HTML5 file that you can play on your browser. So first we have to have a swf file , the directory structure is as follows

So with the file, we need a media to play the SWF , which is a class, Layaflash has a class that is flash.display.MovieClip, we can inherit it , build play a movie class that belongs to you.

Package{import Iflash.swf.utils.SWFTools;        Import Flash.display.MovieClip;           Public dynamic class Dragon_5 extends MovieClip        {public                   function dragon_5 ()             {                  super ();          Swftools.initclass (Dragon_5, this);}}}         

With this playback class, we can implement loading the SWF and play it.

Package{import Flash.display.loader;import Flash.display.movieclip;import Flash.display.sprite;import Flash.events.event;import Flash.net.urlrequest;import Flash.system.applicationdomain;import Flash.system.loadercontext;public class Main extends Sprite {public Function main () {iflash.setsize (600,600);// Set the stage width height iflash.setbgcolor ("#ffffff");//Set the stage background color, the default #000000IFlash. Setorientationex (1);//Set the mobile screen display, the default horizontal screen @param value 0 Vertical screen 1 Horizontal screen iflash.showinfo (true);//Set whether to display FPS information, default true to show if (stage) init (); Else AddEventListener (Event.added_to_stage, init);} Private Function init (e:event = null): void {RemoveEventListener (event.added_to_stage, init); var context:loadercontext = new Loadercontext (false,applicationdomain.currentdomain) var loader:loader = new Loader (); Loader.contentLoaderInfo.addEventListener (Event.complete,oncompletehandler); Loader.load (New URLRequest ("res/ Data.swf "), context);} Private Function Oncompletehandler (e:event): void {var mclip:class = ApplicationDomain.currentDomain.getDefinition (' DragoN_5 ') as Class;var movie:movieclip = new Mclip (); movie.x = (STAGE.STAGEWIDTH/2); movie.y = (STAGE.STAGEHEIGHT/2) + 100;add Child (Movie);}}}

So we know how to do swf file playback, very simple.

Then, we'll use the macro to turn the project into HTML5. But when you're done with your browser , you'll see nothing , because your SWF hasn't turned into a usable HTML file , which we use with Layabox software

Then copy all the files and folders under the output directory to the HTML5 directory and open it.

Conclusion

    • Benefited and mastered the Layaflash SWF play

This site article is for baby bus SD. Team Original, reproduced must be clearly noted: (the author's official website: Baby bus )

Reprinted from "Baby bus Superdo Team" original link: http://www.cnblogs.com/superdo/p/4658198.html

[FlashDevelop] 002.FlashDevelop + layaflash play swf and turn to HTML5

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.