1 Reply Latest reply on Mar 29, 2012 2:04 AM by Innovatology

    Packages cannot be nested

    shawnanderson66

      I'm a newbie and have started a simple tabbed mobile project.

      I keep getting "packages cannot be nested".

       

      my main mxml file:

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:TabbedViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

                                                                                        xmlns:s="library://ns.adobe.com/flex/spark">

                                                                                       

                <fx:Script source="cBut/cFields.as">

                </fx:Script>

                                      

                <s:ViewNavigator label="Results" width="100%" height="100%" firstView="views.ResultsView"/>

                <s:ViewNavigator label="Setup" width="100%" height="100%" firstView="views.SetupView"/>

       

                <fx:Declarations>

                          <!-- Place non-visual elements (e.g., services, value objects) here -->

                </fx:Declarations>

       

      </s:TabbedViewNavigatorApplication>

       

      my .as file:

       

      package

      {

                public class cFields

                {

                               public function cFields()

                               {

                               }

                }

      }

       

      what am I doing wrong?

      thanks

        • 1. Re: Packages cannot be nested
          Innovatology Level 3

          The <fx:Script source="cBut/cFields.as"> tag will insert your cFields.as file into the MXML file (similar to an include in C/C++). That will cause an invalid syntax, as you've noticed.

           

          Give your package a name (in this case it should be called cBut because that is the name of the folder it is in) then use the import statement inside your script tag. Make sure you adhere to the recommended file, namespace, package and class naming structure. That's usually a reverse-DNS style: com.adobe.utils.bla.bla.bla.

           

          If you package name is blank and the source is in the default folder, you don't need to import it.

           

          Look up the package keyword in the help.