dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: as3 evaluating

  1. #1
    Join Date
    Jun 2009
    Posts
    4

    as3 evaluating

    Hi

    In the Rifle class I want to let its parent (Weapon class) to know which bullet class to use.

    I was thinking of the following:

    ====

    class Weapon extends MovieClip {
    public var bulletClassName : String
    public function fire () : void {
    var bullet:Bullet = new bulletClassName();
    }
    }


    class Rifle extends Weapon {
    public function Rifle () {
    bulletClassName = "RifleBullet";
    }

    }

    var rifle:Rifle = new Rifle();
    rifle.fire();

    ===

    How can I do an evaluation on "new bulletClassName()"?
    Or does anyone has another solution?

    greetings

  2. #2
    Join Date
    Oct 2009
    Posts
    658
    how bout making fire as a method of an interface?

  3. #3
    Join Date
    Jun 2009
    Posts
    4
    Can you give an example?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles