# Migrating from AS2 to AS3 (built a class, but what about it's image etc?)

**URL:** <https://forum.kirupa.com/t/migrating-from-as2-to-as3-built-a-class-but-what-about-its-image-etc/230029>\
**Category:** Uncategorized\
**Created:** [June 22, 2007, 3:19am UTC](https://forum.kirupa.com/t/migrating-from-as2-to-as3-built-a-class-but-what-about-its-image-etc/230029 "2007-06-22T03:19:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chesso](https://avatars.discourse-cdn.com/v4/letter/c/f14d63/32.png) [@Chesso](https://forum.kirupa.com/u/Chesso)\
**Post date:** [June 22, 2007, 3:19am UTC](https://forum.kirupa.com/t/migrating-from-as2-to-as3-built-a-class-but-what-about-its-image-etc/230029/1 "2007-06-22T03:19:19Z")

</div>

So I have now migrated my flash projects bullet movieclip code into a class, like so:

```auto

package 
{
  import flash.display.MovieClip;
  import flash.display.DisplayObject;
  import flash.events.*;
  import String;

 public class Bullet extends MovieClip
 {
   // Class wide variables.
   var bmove:int = 1;
   var b_name = this.name;
   var t_bullet:String = b_name.substring(b_name.indexOf("_")+2, 20);
   var o_tower:int = parent.target_array["bullet_"+t_bullet][0];
   var etarget:String = parent["enemy_basic1_"+o_tower];
  
  // Bullet class constructor.
  public function Bullet():void
  {
    this.addEventListener(Event.ENTER_FRAME, enter_frame, false, 0, true);
  }
 
  // Bullet class, Enter Frame event.
  private function enter_frame(Event)
  {
    if (this.DisplayObject.x < 0 || this.DisplayObject.y < 0 || parent.enemy_array[o_tower] < 1) { parent.removeChild(this) }  
  
    if (parent[etarget]._y < this.DisplayObject.y) { this.DisplayObject.y -= bmove; }
    else if (parent[etarget]._y > this.DisplayObject.y) { this.DisplayObject.y += bmove; }
    
    if (parent[etarget]._x < this.DisplayObject.x) { this.DisplayObject.x -= bmove; }
    else if (parent[etarget]._x > this.DisplayObject.x) { this.DisplayObject.x += bmove; }
   
    if (this.DisplayObject.hitTestObject(parent[etarget]))
    {
     parent[etarget].hp -= parent.target_array["bullet_"+t_bullet][1];
     parent.removeChild(this);
    }
  }
  
 }
}

```

Which as far as I know is fine, but it has no image, or any of the movieclip properties the original bullet did, how do I fix this? I still have my bullet movieclip on the stage, it just doesn’t have any actionscript in it now (as I moved it to a class).

Am I supposed to somehow attach this movieclip (won’t this cause bloat, the class itself extends a MovieClip type and then I go and add/attach a seperate MovieClip to it?).

**P.S.** If anyone finds anything wrong with the above class, feel free to let me know, it will certainly help (I have the class compiling without error but perhaps I might run into problems later down the track with some things), and those arrays are meant to be created in the frames onLoad event.
