0 Replies Latest reply on Jul 6, 2007 10:48 PM by rodeored

    How to  make actionscript projects work

    rodeored
      Below are 2 packages that work together. The Reparenting2 class has 2 ParentBox objects. The problem is I can't figure out how to set up a project so they will work. If I put them in the same file I get this error:
      A file found in a source-path can not have more than one externally visible definition. ParentBox;Reparenting2

      If I put them in 2 actionscript files with ParentBox as the main application file of an actionscript project, ParentBox is the only file that is used. How do I get the project to use the other file too ?

      Also, where can I find a tutorial that explains this kind of stuff ? Is there a better forum or newsgroup for questions like this ?

      package {
      import flash.display.Sprite;
      public class ParentBox extends Sprite {
      public function ParentBox(){
      init();
      }
      private function init():void{
      graphics.lineStyle(1, 0);
      graphics.drawRect(-50, -50, 100, 100);
      }
      }
      }

      package {
      import flash.display.Sprite;
      import flash.events.MouseEvent;
      public class Reparenting2 extends Sprite {
      private var parent1:ParentBox;
      private var parent2:ParentBox;
      private var ball:Sprite;
      public function Reparenting2() {
      init();
      }
      private function init():void {
      parent1 = new ParentBox();
      addChild(parent1);
      parent1.x = 60;
      parent1.y = 60;
      parent2 = new ParentBox();
      addChild(parent2);
      parent2.x = 170;
      parent2.y = 60;
      ball = new Sprite();
      parent1.addChild(ball);
      ball.graphics.beginFill(0xff0000);
      ball.graphics.drawCircle(0, 0, 40);
      ball.graphics.endFill();
      ball.addEventListener(MouseEvent.CLICK, onBallClick);
      }
      public function onBallClick(event:MouseEvent):void{
      parent2.addChild(ball);
      }
      }
      }