• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Flash Button Component inside of a SWC

Community Expert ,
Mar 25, 2014 Mar 25, 2014

Copy link to clipboard

Copied

I'm publishing a SWC from FlashCC for use in a FlashBuilder Air project and I get errors when I compile.

Inside of the SWC I have a MovieClip with a button component (fl.controls.Button). In Flash Builder I can make an instance of the MovieClip but when I run the app I get a coercion error:

cannot convert flash.display::MovieClip@56ebee1 to fl.controls.Button.

If I remove the button component from the MovieClip and recompile the SWC there's no error.

If i simply try to add a button instance like this:

var b:Button=new Button();

trace(b);

addChild(b);

The button traces but I get this error

[object Button]

TypeError: Error #2007: Parameter child must be non-null

Views

542

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 25, 2014 Mar 25, 2014

Copy link to clipboard

Copied

Is it possible the SWC tries to instantiate a class that is referenced through a library?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 26, 2014 Mar 26, 2014

Copy link to clipboard

Copied

LATEST

When adding a Button directly to the app I can solve the null problem by setting the default button styles, which are included in the SWC like this:

            var btn:Button=new Button();

            btn.setStyle( "upSkin", new Button_upSkin());

            btn.setStyle( "downSkin", new Button_downSkin());

            btn.setStyle( "overSkin", new Button_overSkin());

            btn.setStyle( "disabledSkin", new Button_disabledSkin());

            btn.setStyle( "selectedUpSkin", new Button_selectedUpSkin());

            btn.setStyle( "selectedDownSkin", new Button_selectedDownSkin());

            btn.setStyle( "selectedOverSkin", new Button_selectedOverSkin());

            btn.setStyle( "selectedDisabledSkin", new Button_selectedDisabledSkin());

           

            btn.label="Hello";

            btn.width=100;

            btn.height=22;

            airapp.addChild(btn);

What I really want to do is avoid the coding and make button and other component instances inside of MovieClips in Flash and include them in the SWC.

I can get components to work with Flash Professional Projects, but this is an ActionScript Project, so I need the SWC.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines