In Flex 2, the @Resource(...) directive autogenerated code to access
resources directly from a ResourceBundle instance. In Flex 3, it
autogenerates code to access them through a new ResourceManager. The
general policy is to always access resources through the ResourceManager
as the "central repository" for all resources, so that there is only one
instance of each bundle and so that the locale can be switched at
runtime.
In Flex 3, base classes like UIComponent, Formatter, and Validator now
have a resourceManager property to make the @Resource directive work,
but Cairngorm's ServiceLocator doesn't have such a property.
Try adding
<mx:Script>
import mx.resources.IResourceManager;
import mx.resources.ResourceManager;
private var resourceManager:IResourceManager =
ResourceManager.getInstance();
</mx:Script>
and see whether that makes the compiler happy. If that doesn't work, try
using a binding expression like
url="{ResourceManager.getInstance().getString('myServiceBundle',
'myServiceUrl')}"
instead of
url="@Resource(...)"
But please file this as a bug at http://bugs.adobe.com/flex
<http://bugs.adobe.com/flex> . We should probably make the MXML compiler
autogenerate a resourceManager property if necessary so that
@Resource(...) will work in any class.
- Gordon
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of kramus0
Sent: Wednesday, September 12, 2007 9:56 AM
To: [email protected]
Subject: [flexcoders] Re: Using @Resource directive with Moxie
Hi again,
maybe it is just a simple namespace problem. I am using Cairngorm and
so I have a different namespace for my ServiceLocator where I use the
HTTPService. Here an other code snippet.
Thanks for your help.
Markus
<?xml version="1.0" encoding="utf-8"?>
<cairngorm:ServiceLocator
xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
xmlns:cairngorm="http://www.adobe.com/2006/cairngorm
<http://www.adobe.com/2006/cairngorm> ">
<mx:HTTPService id="myService" url="@Resource(key='myServiceUrl',
bundle='myServiceBundle')"/>
The compiler error is on the last line, where it tries to allocate the
Resource. Like I said in the 2.0.1 SDK that was fine.
--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "kramus0" <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> when I use the 2.0.1 SDK I can use a localized value for the url in a
> HTTPService and it would look like this:
>
> <mx:HTTPService id="myService" url="@Resource(key='myServiceUrl',
> bundle='myServiceBundle')"/>
>
> But when I try to compile the same code with the Moxie SDK I get an
> error that basically says:
>
> Error: Try to access a not defined property resourceManager.
>
> (My actual error message is in german language: "Error: Zugriff auf
> eine nicht definierte Eigenschaft resourceManager.")
>
> So, what is going wrong? Did anyone have the same problem?
>
> Thanks, Markus
>