[转]如何在Flex Builder中使用Flash CS3组件 - 商帝国咨询 - 五略商书

[转]如何在Flex Builder中使用Flash CS3组件

商帝国咨询头像

阅读 19060 | 分类:文章

经过我的多次测试,发现直接引用Flash的SWC包只能获得相应的代码提示,并不能完全解决纯FlexBuilder编译的问题。因此,如果你想彻底抛弃FLA,又希望能用Flash CS3的组件,必须先在FlashCS3中导出一个SWC,再将这个SWC引入到Flex的Library Path中。这种解决方案来自大名鼎鼎的moockblog同学:


    As a simple example, let’s assume we want to use the V3 TextArea component in Flex Builder. Here’s the general process we follow:

    1) Create a .swc file containing the desired V3 components.
    2) Add the .swc file from Step 1 to the Flex Builder project’s Library path.
    3) Import and use the component classes.

    To generate the .swc file in Flash CS3, we follow these steps:

    1) Make a new Flash CS3 ActionScript 3.0 .fla file.
    2) Drag the desired component(s) to the Library. In this example, we’ll drag the TextArea component to the Library.
    3) Choose File > Export > Export Movie.
    4) For File name, enter v3components.swf. (We don’t even want the generated .swf, but there’s no other way to get the .swc to compile.)
    5) Select a folder in which to save the .swf file.
    6) Click Save.
    7) In the Export Flash Player dialog, check Export SWC.
    8) Click OK.

    The preceding steps generate two files, v3components.swf and v3components.swc, both of which are placed in the folder selected in Step 5.

    Now let’s use v3components.swc in a Flex Builder project. Follow these steps:

    1) In Flex Builder, select File > New > ActionScript Project.
    2) For Project name, enter "V3Test.as".
    3) Click Next.
    4) For Main source folder, enter "src".
    5) For Main application file, enter "V3Test.as".
    6) On the Library path tab, click Add SWC.
    7) Browse to the v3components.swc file from the preceding procedure.
    8) Click Finish.
    9) Update the code in V3Test.as so it looks like this:

    package {
      import flash.display.Sprite;
      import fl.controls.TextArea;
      public class V3Test extends Sprite {
        public function V3Test() {
          var t:TextArea = new TextArea();
          t.text = "You're not cookin'";
          addChild(t);
        }
      }
    }

    10) Run the project.

留言区(共0条)

暂无留言,快来抢占沙发~
作者声明:非原创
平台声明:文章及评论仅代表作者本人观点,五略商书系信息发布平台,仅提供信息存储空间服务,如有侵权,请联系13521509118。转载请注明作者和出处:转自五略商书m.shangdiguo.com,作者商帝国咨询!