dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [CS3] Referencing a movieclip inside a movieclip from a class file

  1. #1
    Junior Member
    Join Date
    Apr 2008
    Posts
    5

    [CS3] Referencing a movieclip inside a movieclip from a class file

    Hello All,

    I'm trying to access a movieclip inside another movie clip from a class file that is not attached to either movieclip. For instance, I'm checking hitTests for the avatar the player uses on the game, there are two enemy movieclips. Inside each enemy movieclip is another movie clip that serves as a bounding box (specifically around the mouth of the enemy so it can eat the player). Here is what I have so far that isnt working:

    Code:
    if (_root['otter']['obbox'].hitTest(this) && touch == false) {
    			trace("Otter touched Urchin");
    			gotoAndPlay("hit");
    			_root['otter'].gotoAndPlay("eat");
    			touch = true;
    }
    The class file is for the avatar. On the stage is the otter mc and inside the otter mc is another mc called obbox which is what I'm trying to hitTest against. Needless to say, it doesn't hitTest or trace or play the animation. Is there a way to reference a nested mc? Thanks in advance.

    Terror.

  2. #2
    Senior Member inder_s2010's Avatar
    Join Date
    Apr 2004
    Location
    don't no
    Posts
    198
    i think you gave linked the class file to symbol in library. ???

    If yes then its easy.. put a trace in your class > trace(this)
    you will come to know the whole path where your avatar is placed on root like this> _level0.someMc.avatarMc

    store this reference in some variable and access other mc's like this:

    var ref = this;
    trace(ref._parent.otter.obbox)

    Suggestion: Never use _root in your class file. It is against the rule of code re-useability...
    inder

  3. #3
    Junior Member
    Join Date
    Apr 2008
    Posts
    5
    thanks Inder. That worked perfectly. Much appreciated.

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