Skip to content
This repository has been archived by the owner on Nov 16, 2021. It is now read-only.

i got a type error in the AS3JS Live demo #19

Open
Colly001 opened this issue Sep 27, 2021 · 1 comment
Open

i got a type error in the AS3JS Live demo #19

Colly001 opened this issue Sep 27, 2021 · 1 comment

Comments

@Colly001
Copy link

The error is : TypeError: Cannot read properties of undefined(reading 'packageName')

The code i am trying to convert is :

package
{
   import flash.display.Sprite;
   import alternativa.tanks.config.Config;
   import alternativa.tanks.Game;
   import flash.events.Event;
   import alternativa.tanks.GameEvent;
   import flash.display.StageScaleMode;
   import flash.display.StageAlign;
   import flash.display.StageQuality;
   
   public class TanksTestingTool extends Sprite
   {
      
      public function TanksTestingTool()
      {
         super();
         stage.scaleMode = StageScaleMode.NO_SCALE;
         stage.align = StageAlign.TOP_LEFT;
         stage.quality = StageQuality.HIGH;
         this.loadConfig("config.xml");
      }
      
      private var config:Config;
      
      private var game:Game;
      
      private function loadConfig(url:String) : void
      {
         this.config = new Config();
         this.config.addEventListener(Event.COMPLETE,this.onConfigLoadingComplete);
         this.config.load(url);
      }
      
      private function onConfigLoadingComplete(e:Event) : void
      {
         trace("Config loaded");
         this.game = new Game(this.config,stage);
         this.game.addEventListener(GameEvent.INIT_COMPLETE,this.onGameInitComplete);
      }
      
      private function onGameInitComplete(e:Event) : void
      {
         trace("Game init complete");
         stage.addEventListener(Event.ENTER_FRAME,this.onEnterFrame);
      }
      
      private function onEnterFrame(e:Event) : void
      {
         this.game.tick();
      }
      
      private function testMapping(n:int) : void
      {
         var r:* = 0;
         var c:* = 0;
         var m:* = 0;
         var i:* = 0;
         r = 0;
         while(r < n)
         {
            c = r + 1;
            while(c < n)
            {
               m = this.mapping(r,c,n);
               trace(r,c,m);
               if(m != i++)
               {
                  throw new Error();
               }
               else
               {
                  c++;
                  continue;
               }
            }
            r++;
         }
      }
      
      private function mapping(r:int, c:int, n:int) : int
      {
         return r * (n - 1) - (r * (r + 1) >> 1) + c - 1;
      }
   }
}
@Cleod9
Copy link
Owner

Cleod9 commented Sep 28, 2021

Hey, so unfortunately I'm no longer supporting this library so I can't help beyond this, but I can at least tell you that you're receiving that error because the live demo is hard-coded to expect a class named Main to be defined. So you would need to add a stub for Main to the code input text box:

/* AS3JS File */
package
{
   public class Main
   {
   }
}

Note when working with AS3JS outside of the live demo you can define your own entry point name.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants