Hi - and welcome to Flex :)

MXML files get turned into AS prior compilation and you can do pretty
anything either in MXML or AS. A typical usecase is to setup a
Controller inside your main Application file. This can be done either in
a Script block or by tag syntax as Tracy suggested. Below are two
examples - email code, but you should get the idea :)

1) Script style
<mx:Application creationComplete="initApp()">
  <mx:Script>
  
    import foo.bar.Controller;
    private var controller:Controller;

    private function initApp():void
    {
      controller = new Controller();
      controller.init(this);
    }
  </mx:Script>
</mx:Application>

2) Tag style
<mx:Application creationComplete="controller.init(this)">
  <Controller id="controller" xmlns="foo.bar.*" />
</mx:Application>

// Controller.as
package foo.bar
{
  import mx.core.Application;

  public class Controller
  {
    public function init(application:Application)
    {
      // whatever...
    }
  }
}

Concerning ANT and the command line compilers: mxmlc is used to compile
applications (SWF files), compc is used to compile component libraries
(SWC files) so you should look out for ANT scripts that use mxmlc and
not compc :)

In addition, you might want to check what Mike Chambers blogged
recently:
http://weblogs.macromedia.com/mesh/archives/2006/04/flex_2_actionsc_1.cf
m

Dirk.

> -----Original Message-----
> From: flexcoders@yahoogroups.com
> [mailto:[EMAIL PROTECTED] On Behalf Of Sascha Balkau
> Sent: Monday, April 24, 2006 6:36 AM
> To: flexcoders@yahoogroups.com
> Subject: RE: [flexcoders] New to Flex, couple of questions
>
> Hi Tracy,
>
> An example would be great if you got any. Even if it's in 1.5
> I think it will be helpful to understand how AS and Flex
> works together.
> Thanks,
> Sascha
>
>
>
> > -----Original Message-----
> > From: flexcoders@yahoogroups.com
> [mailto:[EMAIL PROTECTED]
> > On Behalf Of Tracy Spratt
> > Sent: Saturday, 22. April, 2006 02:34
> > To: flexcoders@yahoogroups.com
> > Subject: RE: [flexcoders] New to Flex, couple of questions
> >
> > I am not doing 2.0 yet, but in 1.5 you can put your AS code
> in a class
> > file, and then either instantiate it in a tag, or make the class
> > methods static, import it and then use the static methods.
> >
> > I have a simple example in 1.5 if you want to see it.
> >
> > Tracy
> >
>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>
>
>

>
>
>


--
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