1 Reply Latest reply on Nov 15, 2007 12:21 PM by Greg (Adobe)

    Design-Time Display of Custom Components

      Help! I've Googled until my fingers are bleeding and I still have not found an answer to this:

      I've created a custom control based on the mx:HBox control. It includes a small icon (which is static -- it's always the same) and a property I've called "caption" which sets the text value for an mx:Label control. The "caption" property shows up in the property list in FB3 and when I run the application, it displays the proper text.

      What's got me puzzled is that in design mode, the "caption" value does not display in any instance of the control. Instead I see the name of the source variable "_text" surrounded by curly braces:


      Not that this is absolutely critical, but why won't it display the proper value?

      Any suggestions would be much appreciated.
        • 1. Re: Design-Time Display of Custom Components
          Greg (Adobe)
          I'm guessing that your custom component is defined as an MXML file in the same project as the application that is using it. And that you are setting the "text" property of the mx:Label using a data binding expression or some ActionScript code.

          The problem is that Design View is limited in how it can instantiate custom components, and Design View also does not evaluate data binding expressions.

          If you want your custom components to appear in Design View as it does at runtime, you need to build your custom components in a separate Flex Library project, then add that library project to the build path of the host application project. If you do that, Design View will create actual instances of your custom component.

          When a custom component is defined in the same project as the host application, Design View does not create actual instances of the custom component. Design View, in essence, substitutes the tags inline (as if you had copied and pasted the definition of the class rather than using the custom component).

          When this tag substitution occurs, the ActionScript code for your custom component, and any data binding expressions, does not get evaluated. So this is why you see {_text}. Design View is not the mxmlc compiler and is not smart enough to evaluate that data binding expression.

          This is an area that we would like to improve upon in future versions of Flex Builder.

          -- Greg Dow
          -- Adobe Flex Builder Team