Skip navigation
HanseeFlashEntuiast
Currently Being Moderated

Need help to structure classes and folders!

Jul 22, 2012 4:00 AM

Tags: #problem #flash #3.0 #action #actionscript #as3.0 #ac3 #actionscript3 #function

Hello everyone:)
I have been programming a while in Actionscript 3 now. But most of the time I haven't been doing so big projects. So I have just had  1 folder with the Fla, and Main Class and some other classes for different objects. But yesterday I found out i need some more structure when the projects getting bigger. so what I would like to to is have the main folder with fla, and a folder in that folder again with classes or somthing. But I can't figure it out. Have searched around the web and yeah tryed alot. So Now I found out I need help to solve this problem:)!
Hope someon can help me out with this one, becuase it should be pretty easy, but I can figure it out right now.

 

 

 

Thank's !

 
Replies
  • Currently Being Moderated
    Jul 22, 2012 4:32 AM   in reply to HanseeFlashEntuiast

    It is not clear to me what you cannot figure out.  MAybe the tutorial linked below will be useful for you.

     

    http://www.gotoandlearn.com/play.php?id=30

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 22, 2012 7:00 AM   in reply to HanseeFlashEntuiast

    If you want to store a class named Animal inside a folder named Animal (I would change one of the names to not be the same), then you create the Animal folder, and then in your class file you define the path to it as part of the package definition...

     

    package Animal   // this Animal refers to the folder name, not the class

    {

     

          import flash.display.MovieClip;

     

          public class Animal extends MovieClip { // this Animal is the class file name

     

     

    In your Main document class you need to import that Animal class using...

     

          import Animal.Animal;

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 22, 2012 8:08 AM   in reply to HanseeFlashEntuiast

    You'll have to show code to get help with code.  Try to limit it to code that which is relevant to the problem.

     

    In simplest terms, the following Animal class in the Animal folder will trace when instantiated in the Main.as using - var an:Animal = new Animal();  :

     

    package Animal
    {
        import flash.display.MovieClip;

        public class Animal extends MovieClip {
     
           public function Animal():void {

               trace("I am an animal");
           }
        }
    }

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 22, 2012 11:46 AM   in reply to HanseeFlashEntuiast

    Have you assigned the MainAs to be the document class for the MainFLA.fla file?

     

    Do you have an object in the library that is linked to the "Classes.Animal" class?

     

    I would declare the animal1 variable where you have it, but I would not instantiate it until inside the MainAs function.

     

              public class MainAs extends MovieClip {

     

                             public var animal1:Animal;

     

                             public function MainAs() {

                                       // constructor code

                                       animal1 = new Animal();

                                       addChild(animal1);

                             }

     

    Is the code you show for placement of the Animal object a typo or do you really have it assigning the x property twice?

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 22, 2012 1:34 PM   in reply to HanseeFlashEntuiast

    You're welcome

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points