mxmlc生成swf

Compiling an AS3 program with the Flex SDK

Here, we will describe how to compile with mxmlc. This assumes that your Flex framework is properly installed. For information on how to install it, read the Adobe Flex article.

Open a text editor, a simple one that will save the text as it appears on the screen, without any formatting. In that new text file, copy the following code:

 package  {

   import flash.display.Sprite;

   public class FilledCircle extends Sprite {

       function FilledCircle():void {

         var circle:Sprite = new Sprite();
         circle.graphics.beginFill(0xFF794B);
         circle.graphics.drawCircle(50, 50, 30);
         circle.graphics.endFill();
         addChild(circle);

       }
    }
 }

Save the file as text and give it the name of "FilledCircle.as".  Take good note of the directory in which you save that file. Preferably, put it in a  folder quite high up in the hierarchy. We will assume that the file is stored somewhere defined by "\path\to\file\".

2.1 On a mac
  1. Open a terminal window. Terminal is an application like any other. To find it, go to the Applications -> Utilities. You should see Terminal.app among the files.
  2. Double click on the application to open it.
  3. At the prompt, type:
 cd \path\to\file\
 mxmlc FilledCircle.as
2.2 On a PC
  1. From the Windows start menu, open a command prompt by choosing Start > All Programs > Accessories > Command Prompt.
    • If you can't find it, choose Start->Execute and type cmd.
  1. At the command prompt, change to the C:\Flex SDK 2\bin directory then execute the mxmlc executable on your actionscript file.
 cd C:\Flex SDK 2\bin
 mxmlc C:\path\to\file\FilledCircle.as

The mxmlc executable will compile the program and generate a .swf file name FilledCircle.swf. To run the file, open it in the Flash Player on your desktop or in a web browser that has Flash Player installed. Note that Flash Player 9 needs to be installed to view swf files generated by the Flex compiler.

2.3 On a PC by modifying the Path variable

A more practical solution is to add the path of the Flex SDK to your system:

%Path%;c:\Flex SDK 2\bin

See environment variable for technical details if the instructions below are not enough.

On a french speaking Windows XP system (sorry) the procedure is:

  • Démarrer->Paramètres->Panneau de configuration->Système
  • Select the panels: Avancé->Variables d'environnment

On an English system (sorry you may have to fix this a bit):

  • Start->Parameters->Configuration Panel->System
  • Select the panels: Advanced->Environment variables

Then:

  • Change the "Path" variable in the user variables pane by adding the flex path at the end of the existing path variable. The result may look like this:
 %Path%;c:\Flex SDK 2\bin
  • If the "path" variable doesn't exist, create it and copy the above line.

Do not remove the other pathes ! Do not edit the system variables or you may regret it bitterly, because your system will stop working if do it wrongly. !

Here is a screendump showing some of the (french) Windows panels:

Changing the User Path variable under Windows XP (french)

If you have done this right, you now can use the compiler from any place, e.g.

cd c:\soft\as3\ex1
mxmlc FilledCircle.as
2.4 Under Linux

You should add the path to the flex binaries somewhere, e.g. if you installed flex in /usr/local/flex, add this line to /etc/bash.bashrc

export PATH=${PATH}:/usr/local/flex/bin

Note: MacOSX users also could do something like this (but DKS doesn't have a Mac at hand to show how-to).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值