简体   繁体   English

如何从SWC在Flash Builder项目中添加SimpleButton?

[英]How to add a SimpleButton in a Flash Builder project from SWC?

I exported a SWC from Flash CS3 and the assets works, except the Buttons, they look like another library items. 我从Flash CS3导出了SWC,并且素材资源工作正常,除了Buttons之外,它们看起来像另一个库项目。

The code: 编码:

package {
    // ...
    import flash.display.Sprite;
    import flash.display.SimpleButton;
    import res.botoes.Pause;
    // ...

    public class Cena extends Sprite {
        // ...
        private var botao:SimpleButton;
        // ...

        public function Cena() {
            // ...
            botao = new Pause() as SimpleButton;
            addChild(botao);
            // ...
        }
        // ...
    }
}

try this; 尝试这个;
first create SimpleButton and Pause instance, Then cast Pause to SimpleButton,sure about the syntax, otherwise check your custom classes 首先创建SimpleButton和Pause实例,然后将Pause强制转换为SimpleButton,确定语法,否则检查自定义类

// ...
         private var _pause:Pause();
         private var botao:SimpleButton;
// ...
         public function Cena() {
            // ...
            _pause = new Pause();
            _botao = new SimpleButton();
            botao = _pause as SimpleButton;
            addChild(botao);
            // ...
         }
// ...

Solved. 解决了。

My new solution: Make a MovieClip for each state of the buttons, then construct the buttons this way: 我的新解决方案:为按钮的每种状态制作一个MovieClip,然后按以下方式构造按钮:

var pause:SimpleButton = new SimpleButton(
        new PauseU().
        new PauseO(),
        new PauseD(),
        new Mascara()
    );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM