Kevin
Kevin

Reputation: 6831

question on flex mxml reference

I declared a namespace at the top of my mxml file Radio.mxml;

xmlns:jour="components.journal.*"

I now have another mxml file Journal.mxml is under the components/journal folder,the Radio.mxml is at the root folder which contains the components folder.

Now I want to access the Journal.mxml in the Radio.mxml using the name space,how could I do that,I've tried

var a = new jour.Journal();

but it seems not right,could anyone help a little bit?Many thanks.

Upvotes: 0

Views: 220

Answers (2)

JeffryHouser
JeffryHouser

Reputation: 39408

It sounds like you're on the right track, but there is a slight disconnect. You're mixing MXML and ActionScript syntax I think.

In ActionSCript you can do this:

import components.journal.Journal;
var a : Journal = new Journal();

In MXML, you would do something like this:

<TopLevelComponent xmlns:jour="components.journal.*">
  <jour:Journal />
</TopLevelComponent>

I do not believe that ActionScript can reference the namespace you define in MXML.

Upvotes: 1

Sam Dolan
Sam Dolan

Reputation: 32542

xmlns:jour="components.journal.*" only defines the namespace for you mxml components. So you can do something like: <jour:Journal id='my-journal' />.

If you want use your Journal class inside of your actionscript, you'll need to import it seperately: import components.journal.Journal then use it like var a = new Journal();

Upvotes: 3

Related Questions