2
votes

Im writing my first application in Flash Builder but I have much experience with Flash. I and trying to use the button class in flash builder but my error says "the imports button could not be found". I tried importing flash.display, flash.ui to see it Button was hidden somewhere else. The point is to dynamically load buttons and their labels via xml. Any help is appreciated. Thanks!

<fx:Script>
    <![CDATA[
        import flash.events.*;
        import mx.controls.Button;

        private function doAdd(e:Event):void {

            var buttonList:XMLList = new XMLList(cutsXML.cut.@name);
            for(var i=0; i<buttonList.length(); i++){
                var btn:Button = new Button();
                btn.label = buttonList[i];
                buttonBox.addElement(btn);
            }
        }
    ]]>     
</fx:Script>

<s:VGroup left="30" right="30" top="50" bottom="30" id="buttonBox">
</s:VGroup>

2

2 Answers

1
votes

Im guessing you are creating a mobile app? As mx components are not available (by default) in mobile apps.

You can either use the spark button - spark.components.Button - or manually include the mx components by importing the mx.swc library (found within flex sdk)

1
votes

Add the mx.swc to your project, that'll do.

In Flash Builder 6.0, do the following:

  • Right-click on the project in the Package Explorer perspective
  • Properties...
  • Flex Build Path (in the left side navigation pane)
  • Click Add SWC...
  • Find the mx.swc on your box. On OSX at the time of this writing it was:

    /Applications/Adobe Flash Builder 4.6/sdks/4.6.0/frameworks/libs/mx/mx.swc

  • Click OK

  • Rebuild your project