2 Replies Latest reply on Mar 26, 2014 5:45 AM by rob day

    Flash Button Component inside of a SWC

    rob day Adobe Community Professional & MVP

      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();




      The button traces but I get this error


      [object Button]

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

        • 1. Re: Flash Button Component inside of a SWC

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

          • 2. Re: Flash Button Component inside of a SWC
            rob day Adobe Community Professional & MVP

            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());










            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.