Flex 4 error: declaration must be contained within the <Declarations> tag

November 3rd, 2008 by ryanstewart

I was messing with the RemoteObject tags in Flex 4 and got the following error that is fairly straight forward, but I thought it was worth blogging since it’s a change from Flex 3.

declaration must be contained within the tag since it does not implement mx.core.IUIComponent.

In Flex 4 there are some changes to how you can place tags in your application. We’ve got a new Declarations tag which is similar to the Script. In Flex 4, that’s where everything that isn’t some kind of UI component goes. IUIComponent extends basically everything that renders on the screen. Anything that doesn’t, things like RemoteObject or HTTPService. Currently it doesn’t look like other classes, like ArrayCollection or the filters have to be in that Declarations tag.

Posted in Flex

2 Responses

  1. Deepa Subramaniam

    Its important to note that visual elements that are not UIComponents (ie: the new graphic elements in Gumbo like Rect, Ellipse, etc) can live in a Flex 3 Application, but must be wrapped in a Group. If you don’t do this, you’ll get the error you mention above.

  2. andhdo

    <fx:Declarations>
    <!– Place non-visual elements (e.g., services, value objects) here –>
    <s:RemoteObject
    id="service"
    destination="helloAction"
    />

    </fx:Declarations>

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

About Ryan Stewart – Rich Internet Application Mountaineer

A blog by a Platform Evangelist at Adobe covering Adobe's RIA platform. Includes posts about Adobe Flex, Adobe AIR, ColdFusion, LiveCycle, Thermo, and everything in between.