2 Replies Latest reply on Apr 9, 2010 5:15 AM by blacksyforce

    Split a Main Application file

    blacksyforce Level 1

      Hy, I have a question, is it possible to split a main application file into several others ?

       

      So I have an application where I keep a few objects on my stage. Each object can do a lot of things and is linked with the others. Writing the script for each object will make my main application file hard to read. Can I somehow run the application from like 5 or 6 Flex Components or Flex Application files ? If so can you give me a little sample of code ?

       

      I've tryed to add my objects on the stage from a component, but it doesn't work... I don't really understand them, they look like classes but they don't really act like ones...

        • 1. Re: Split a Main Application file
          SpaghettiCoder Level 3

          Components or Modules, Components are much easier than modules, modules keep the main app smaller, but you do have to load them later.

           

          What don't you get about components?

           

          1. Create the component,

           

          2. Register the component.

          xmlns:MyCustomComponent="theDirectoryItsIn.*"

           

           

          3. Use the component.

          <MyCustomComponent:ComponentName/>

           

          That's the MXML way.

           

          If you do it in actionscript theres a bit more coding but not a whole more.

           

          1. import your component

           

          import theDirectoryItsIn.TheComponent;

           

          2. Create an instance of it.

          var idName:ComponentName = new ComponentName();

          idName.x=10;

          idName.y=10;

           

          3. If you use FB4

          this.contentGroup.addElement(idName);

           

          if you use FB3

          this.addChild(idName);

          1 person found this helpful
          • 2. Re: Split a Main Application file
            blacksyforce Level 1

            I forgot to use the addChild method... still I don't see the difference betwean Components and Classes, except that Flex Components can use AS Classes. I have rethinked my application so I won't need a big main file, but now I have a new question: I'm working on an AIR application and I don't really need Flex for too much, just AS... is it better to use Flex Components or AS Classes in order to increase performance ?