A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Classes: referencing of a movieclip not being recognised

Threaded View

  1. #1
    Member
    Join Date
    Oct 2009
    Location
    Scotland
    Posts
    32

    Classes: referencing of a movieclip not being recognised

    I have a main .fla file that has a movieclip with an instance name level. Within this there is another movieclip called hero.

    I have a main class with the following function:

    public function beginLevel() {

    var cHero:Hero = new Hero;
    createFunction1();

    }
    I then have a Hero class with the following code:

    public class Hero extends MovieClip {

    private var hero:Object;

    public function createHero() {

    hero = new Object();
    hero.mc = level.hero;
    hero.startx = hero.mc.x;
    hero.starty = hero.mc.y;
    }
    }
    In the main flash file, the hero movieclip is nested inside the level movieclip.

    The line hero.mc = level.hero; is used to make it easier for me to manipulate the hero's attributes later on. However when I compile this, I get the error message: Access of undefined property level.

    I'm not really sure how to get this class file to recognise the movieclips in the main flash file.

    Any help would be greatly appreciated.
    Last edited by juve_steve; 03-12-2010 at 02:00 PM.
    -------------------------------------------------
    Don't F**K with Fedor

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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center