A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Classes: referencing of a movieclip not being recognised

  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

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    You can give hero a name and then call it using level.getChildByName("here"). That is one solution I see at first glance.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Member
    Join Date
    Oct 2009
    Location
    Scotland
    Posts
    32
    Danke
    Last edited by juve_steve; 03-13-2010 at 01:42 AM.
    -------------------------------------------------
    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