pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

ActionScript pastebin - collaborative debugging tool View Help


Posted by sheel on Sun 1 Nov 18:30
report abuse | download | new post

  1. package
  2. { // start package
  3.         import flash.display.MovieClip;
  4.  
  5.         public class Enemy extends MovieClip
  6.         { // start public class Enemy
  7.                 var speed:Number = 2;
  8.                
  9.                 var attackFrame:String;
  10.                 var walkFrame:String;
  11.                 var idleFrame:String;
  12.                
  13.                 public var jumpSpeed:Number = 0; // velocity
  14.        
  15.                 public function Enemy()
  16.                 { // start public function Enemy (constructor)
  17.                         var RNG=(Math.floor((Math.random() * 50)) %3)
  18.                
  19.                         if (RNG == 0)
  20.                         {
  21.                                 createEnemy1();
  22.                         }
  23.                        
  24.                         else if (RNG == 1)
  25.                         {
  26.                                 createEnemy2();
  27.                         }
  28.                        
  29.                         else if (RNG == 2)
  30.                         {
  31.                                 createEnemy3();
  32.                         }
  33.                        
  34.                 } // start public function Enemy (constructor)
  35.        
  36.                 private function createEnemy1()
  37.                 { // start createEnemy1
  38.                 trace("createEnemy1")
  39.                 attackFrame = "rockAttack";
  40.                 walkFrame = "rockWalk";
  41.                 idleFrame = "rockIdle";
  42.                 } // end createEnemy1
  43.        
  44.                 private function createEnemy2()
  45.                 { // start createEnemy2
  46.                 trace("createEnemy2")
  47.                 attackFrame = "scissorAttack";
  48.                 walkFrame = "scissorWalk";
  49.                 idleFrame = "scissorIdle";
  50.                 } // end createEnemy2
  51.        
  52.                 private function createEnemy3()
  53.                 { // start createEnemy3
  54.                 trace("createEnemy3")
  55.                 attackFrame = "paperAttack";
  56.                 walkFrame = "paperWalk";
  57.                 idleFrame = "paperIdle";
  58.                 } // end createEnemy3
  59.                
  60.                 public function Chase(handCharx, handChary)
  61.                 { // start public function Chase
  62.                         if (handCharx < this.x-10)
  63.                         {
  64.                                 this.x -= speed;
  65.                                 this.scaleX = -1;
  66.                                 gotoAndStop(walkFrame);
  67.                         }
  68.                        
  69.                         else if (handCharx > this.x+10)
  70.                         {
  71.                                 this.x += speed;
  72.                                 this.scaleX = 1;
  73.                                 gotoAndStop(walkFrame);
  74.                         }
  75.                        
  76.                         //else enemyIdle(handCharx);
  77.                 } // end public function Chase
  78.                
  79.                 /*public function enemyIdle(handCharx)
  80.                 { // start public function enemyIdle
  81.                         if (handCharx < this.x-3)
  82.                         {
  83.                                 this.x -= speed;
  84.                                 this.scaleX = -1;
  85.                                 gotoAndStop(idleFrame);
  86.                         }
  87.                        
  88.                         else if (handCharx > this.x+3)
  89.                         {
  90.                                 this.x += speed;
  91.                                 this.scaleX = 1;
  92.                                 gotoAndStop(idleFrame);
  93.                         }
  94.                 } // end public function enemyIdle*/
  95.         } // end public class Enemy
  96. } // end package

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post