Flex Component Showing in Flex Builder

I ran into a problem a few days ago with a Flex component that I was building not showing up in Flash Builder when built using our command-line build, but showing up fine when built by the IDE (Flex Builder).

It took me a bit of searching to figure out what the problem was, which means it’s worth posting the solution here.

Flex Builder’s design view is extensible. New components that you build can show up in the Components panel, and users can drag them onto the design surface. You need to do a few things for this to work.

First, you need a design.xml file in your SWC. This file tells Flex Builder about your component. Here’s an example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<design>
    <namespaces>
        <namespace prefix="myproject" uri="http://www.adobe.com/2009/myproject" />
    </namespaces>
    <categories>
        <category id="myproject" label="myproject" defaultExpand="true" />
    </categories>
    <components>
        <component name="MyImage" namespace="myproject" category="myproject" insertStyle="control" displayName="MyImage">
            <defaultAttribute name="cellName" value=""/>
            <mxmlProperties use="mx:Image">
                <textfield id="cellName" name="Cell Name:"/>
                <combo id="autoInvokeTargetURL" name="Auto Invoke Target URL:"/>
            </mxmlProperties>
        </component>
    </components>
</design>

I had that right in my SWC, but I was missing two things. The ant script that I was using for my command-line build wasn’t including the design.xml file. After adding that, here’s what the ant target for the SWC compile looks like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<target name="build">
    <java jar="${flex.sdk.home}/lib/compc.jar" dir="." fork="true" failonerror="true">
        <jvmarg value="-Xmx512m"/>
        <arg value="-load-config=${flex.sdk.home}/frameworks/flex-config.xml"/>
        <arg value="-compiler.fonts.local-fonts-snapshot=${flex.sdk.home}/frameworks/localFonts.ser"/>
        <arg value="-headless-server=true"/>
        <arg value="-include-file=design.xml,src/design.xml"/>
        <arg value="-source-path=src"/>
        <arg value="-compiler.namespaces.namespace=http://www.adobe.com/2009/myproject,src/manifest.xml"/>
        <arg value="-include-namespaces=http://www.adobe.com/2009/myproject"/>
        <arg value="-compiler.debug=${flex.debug}"/>
        <arg value="-compiler.external-library-path+=${flex.sdk.home}/frameworks/libs/framework.swc"/>
        <arg value="-o=bin/${swc}"/>
    </java>
</target>

Note the include-file line, which gives the name of the file and then the source path to it.

And the other thing that was missing was the namespace mapping. The compiler.namespaces.namespace argument identifies the namespace for the component (which has to match the namespace from the design.xml) and the manifest to use for the classes in that namespace.

The last piece is the manifest file. Here’s what that looks like:

1
2
3
4
<?xml version="1.0"?>
<componentPackage>
    <component id="MyImage" class="org.stevex.myproject.MyImage"/>
</componentPackage>

With all this set up, dropping the SWC into a Flex project’s libs folder will immediately show the MyImage component in the Components panel ready to drag onto the design surface.

One Response to “Flex Component Showing in Flex Builder”

  1. Cristian Says:

    Hello,

    thanks for the post,

    I have added a component where some events, all are working properly.

    I could not add in the main palette.

    I tried

    The other properties, get and setters are ok.

    PS: I’m referring to the Standard View, in the other tabs I see normally.

    Thanks.

Leave a Reply

 




 
buy cheap Endep online buy cheapest Endep and Endep how to order Amitriptyline online without prescription buy Amitriptyline without rx from us pharmacy online Amitriptyline purchase purchase online prescription Amitriptyline without purchasing Amitriptyline online without prescription order generic Amitriptyline buy Endep no prescriptions how to order Endep online without prescription comprare Endep generico Endep online buy Endep in england buy cheap Endep online free consult Endep purchased online without prescription what is Endep Endep tabletten buy Endep no perscription cod Endep non rx fedex overnight free want to buy Anafranil in usa Aricept overdose buy discount Aricept on line Aricept buy Aricept online Aricept order buy Aricept pills Nizoral suppliers cheap order rx Nizoral canada Nizoral order Nizoral usa cod comprar Nizoral generico buy Nizoral 200 mg buy cheap Nizoral under without rx buy cheap Nizoral with dr. prescription Prozac 200 mg buy Lisinopril australia el Nizoral generico buy Lisinopril tablets without rx next day delivery Lisinopril with no script buy Lisinopril c o d purchase arimidex no scams order Arimidex order amex Arimidex canadian pharmacy buy Arimidex without doctor order rx free Arimidex buy Abilify with american express buy Abilify cod order Finpecia without a prescription cheap order rx Finpecia purchase Famvir no visa online without prescription buy Famvir paypal without rx buy Famvir without Famvir without prescription medications Famvir without persription purchase Famvir online no membership overnight shipping Famvir no physician approval Amitriptyline purchase order Amitriptyline free next day airAmitriptyline on line Valtrex no rx needed cod accepted buy next day Fluoxetine buy Fluoxetine line purchase Fluoxetine cod delivery buy Fluoxetine 20 mg purchase Fluoxetine buy cheap Fluoxetine under without rx purchase Fluoxetine visa without prescription Fluoxetine by mail Fluoxetine for pets Fluoxetine 10mg Amitriptyline purchase online how to order Famvir online without a rx Prozac Amitriptyline no perscription Famvir next day purchase Anafranil no prescription cheap buy cheapest Anafranil next day delivery on Anafranil saturday Anafranil buy Anafranil buy Anafranil overnight where to purchase Anafranil no prescription no fees Anafranil drug buy Lisinopril where Lisinopril buy on line order Lisinopril online no membership overnight shipping no prescription required for Lisinopril order maxalt cash on delivery Maxalt from canada buy cheapest Maxalt purchase Maxalt visa without prescription buy Maxalt uk Maxalt 10 mg purchase Maxalt no visa online without prescription purchase generic Lisinopril online Lisinopril no prescription to buy maxalt order online no membership overnight how to get a arimidex rx Aricept without a perscription fedex Aricept overnight without a prescription Donepezil prescription order buy genuine Aricept Aricept uk sales prescription Proscar buy Proscar pay cod Maxalt apotheke buy no perscription Proscar purchase Proscar online buy cheap fedex Prednisone maxalt with no presciption buy Maxalt shipped cod Proscar online Prednisone order buy Amitriptyline with amex Accutane 40 mg delivered overnight buy brand Accutane 40 mg Accutane 40 mg orderd online without prescription where to purchase generic Accutane 40 mg online without a rx how to get 40 mg Accutane without next day delivery 40 mg Accutane with no script buy Amitriptyline online Accutane 40 mg online no prescription buy Accutane 40 mg online us pharmacy Accutane 40 mg best buy buy Accutane 40 mg c o d order 40 mg Accutane cash on delivery no presciption 40 mg Accutane