tags:

views:

20

answers:

2

Hello there,

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.

+1  A: 

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.

www.Flextras.com
Thanks,I tried put the script in like this: <mx:Script><![CDATA[ import components.journal.Journal; import mx.controls.Alert; internal function Handler():void { var a : Journal = new jour.Journal();}]]></mx:Script>It complains about "access of undefined property jour",could you help me on this please,thanks!
Robert
In the AS version I think you need to omit the "jour." portion after "new".
Wade Mueller
Right you are Wade; my typo. Sorry about that!
www.Flextras.com
+3  A: 

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();

sdolan