2 Replies Latest reply on Feb 17, 2011 6:44 AM by todd.lang

    How to get code-behind working?

    todd.lang

      So, I've been at it for hours now  and I'm still unable to divine the dark sequence that will allow me to  have a code-behind setup for my application.  I'm using Flash Builder 4  and trying to create an AIR desktop application.

       

      Here's what I've tried:

       

      Start Flash Builder 4

       

      Start a new Flex Project called "TtA", setting it to run for Desktop

       

      First,  fix the immediate error I have about a complaint about not being able  to find my locale by going to the properties of the solution and  changing the Flex Compiler options from "-locale en_CA" to "-locale  en_US".  (Good job on shipping something broken out of the box, guys!)

       

      In the solution, create a new package called "components"

       

      Create  a new ActionScript class called "TtAClass" in the "components" folder,  making it a descendant of "spark.components.WindowedApplication"

       

      In my "(default package)" edit TtA.MXML to add 'xmlns:my="components.*"' and change the 's:WindowedApplication' to 'my:TtA'.

       

      I'm left with the error "Adobe AIR application is missing the corresponding TtAClass-app.xml."

       

       

      So,  that leads me to believe the app code-behind file can't see the  required -app file and it doesn't match what I originally called my app,  so let's change it to "TtA.as".

       

      That brings me to"Adobe  AIR application is missing the corresponding TtA-app.xml.".  Well, at  least it's looking for the right one now.  So, let's try moving TtA.as  to the default package.

       

      Well, now it says "Unable to  locate specified base class 'TtA' for component class 'TtA'.", which is  bizarre since it's right next to the file it *can* see.  Also,  conveniently it did fixup my MXML file so that it is importing the file  in its new location.  Specifically it added 'xmlns:local="*"' to my MXML  file and changed the root element of my file.

       

      So, at this  point I'm in a dangerous state.  If I do much more eventually the Flash  Builder process flies off in to space consuming massive amounts of RAM  and eventually halting my PC.

       

       

       

      tl;dr - I  can't figure out how to correctly create a code-behind file for my  default MXML application.  Can someone please help me?