0 Replies Latest reply on Feb 16, 2011 7:54 AM by Michael Maurel

    Re: Library element to class

    Michael Maurel

      That was a mistake when I wrote down my script. Here is a copy of exactly what I have ;

       

       

       

      In main.fla:

      a movieClip "tShoe", exported for AS, for class "tShoe" and for base class "scripts.Token"

      a movieClip "tCar", exported for AS, for class "tCar" and for base class "scripts.Token"

      a movieClip "tDog", exported for AS, for class "tDog" and for base class "scripts.Token"

       

      In main.as:

      public function monopoly() {
                  aPlayer = new Array;
                  createScene();
      }

      private function createScene(){
                  createUserPanel();
                  createBoard();
                  createToken();
      }

      private function createToken(){

                  aToken = new Array();

                  aToken[0] = new Token("tShoe");

                  aToken[0].x = 447,5;

                  aToken[0].y = 447,5;

                  addChild(aToken[0]);

      }

       

       

      In scripts/Token.as:

      public class Token extends MovieClip{
              public var pToken:MovieClip;
              public var pCase:Number;
             
              public function Token(pShape:String="tShoe") {
                  switch(pShape){
                      case "tDog":
                          this.pToken = new tDog();
                          break;
                      case "tCar":
                          this.pToken = new tCar();
                          break;
                      default:
                          this.pToken = new tShoe();
                          break;
                  }
                  this.pCase = 0;
              }

       

      }

       

       

       

      And when I run my code, I have now : "Error #1023 : Stack overflow"

       

      If I put "flash.display.MovieClip" as base class for my library elements, the scripts runs without error, but no token is created on the scene