In XML, the concept of having multiple "namespace" allows <Application> and <Script> tags as defined by Adobe to coexist in the same document with <Application> and <Script> tags as defined by other people. (This may not seem like a compelling use case for Application and Script, but it is more compelling, for, say, <Button>).

 

The xmlns:mx="http://www.adobe.com/2006/mxml attribute says "tags prefixed by mx: belong to the namespace with the unique identifier http://www.adobe.com/2006/mxml", which has been chosen by Adobe to identify its own MXML tags.

 

- Gordon

 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of aaron smith
Sent: Friday, August 11, 2006 3:58 PM
To: [email protected]
Subject: Re: [flexcoders] AS3 Question

 

sweet. thanks man.. i'll give that a shot. is xmlns='...' a way of saying everything? or were you just referencing the fact that I have to import code...

thanks


On 8/11/06, Gordon Smith <[EMAIL PROTECTED]com> wrote:

That's not really what I meant... if you use <mx:Application> the MXML compiler creates the application subclass and you can't replace it with a different one. But whatever you put in the Application's <mx:Script> goes into the body of the subclass (along with the useful autogenerated stuff),So instead of writing

 

public class MyApplication extends Application

{

    -- code --

}

 

just write

 

<mx:Application xmlnx:mx='...'>

  <mx:Script>

    -- code--

  </mx:Script>

</mx:Application>

 

The only caveat I know of is that you can't write a constructor for your Application because the MXML compiler will generate one.

 

For all your components, you can write them in AS:

 

public class MyComponent extends VBox

{

  -- code --

}

 

- Gordon

 


From: [EMAIL PROTECTED]ups.com [mailto: flexcoders@yahoogroups.com] On Behalf Of aaron smith
Sent: Friday, August 11, 2006 3:17 PM
To: [EMAIL PROTECTED]ups.com
Subject: Re: [flexcoders] AS3 Question

 

I think I understand what you're saying.

I could do something like:

<mx:Application>
 <mx:Script>
    import someApplicationInstanceClass;
    var app = new someApplicationInstanceClass();
  </mx:Script>
</mx:Application>


so when I would make an instance of the "someApplicationInstanceClass" that would start the app..

also,  isn't there a variable called application? that references the Application isntance? I could pass that to the constructor of someApplicationInstanceClass?

thanks

On 8/11/06, Gordon Smith <[EMAIL PROTECTED]com> wrote:

Yes, it's possible. All MXML files simply get turned into AS3 classes and then compiled. If you turn on the <keep-generated-actionscript> option in flex-config.xml, you can see what these classes look like.

 

If you do this, however, you'll see that the MXML compiler autogenerates a lot of non-obvious stuff, some of which is required for the components to run properly. For example, when you compile an <mx:Application> it generates setup code for a bunch of CSSStyelDeclaration instances that represent the CSS styles. If these CSSStyleDeclarations aren't properly set up, most Flex components will probably generate runtime errors when they try to call getStyle().

 

So my advice is to at least use <mx:Application>. But then it is quite easy to write only AS components instead of MXML components.

 

- Gordon

 


From: [EMAIL PROTECTED] ups.com [mailto:flexcoders@ yahoogroups.com] On Behalf Of aaron smith
Sent: Friday, August 11, 2006 11:31 AM
To: [EMAIL PROTECTED]ups.com
Subject: [flexcoders] AS3 Question

 

I have been dabbling lately with creating pure AS3 projects. ( http://www.senocular.com/flash/tutorials/as3withmxmlc/ )

Is it possible to use the components that are in Flex through just AS3. I would think you can, just a matter of figuring out how.

Thanks.

 

 

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to