HZNM.COM
welcome to my space
X
Search:  
 HOME   HitTest doesn't work in loaded mcs?!
HitTest doesn't work in loaded mcs?!
Published by: admin 2010-03-15
Welcome to:hznm.com

  • I've tried _lockroot, as well as using _root, this, setting a global variable to 'this' and using it, but nothing seems to work!?

    I set up the attached files (testDrawPolyShell.swf loads drawPoly.swf), so that the first mouseClick uses attachMovie to add the poly and the second clip does a hitTest between the poly and the cursor position. It works fine stand-alone, but the hitTest doesn't work in the loaded movie...here's the code that's in drawPoly.swf:
    Topic, Path 4 Mouse Help::
    The reason why the hittest was working on your standalone version and not I've never tested myself this turn around, so if ti's still doesn't work,
    http://www.bonuslevel.org/forum/topic_4396.html
    HOME

    this._lockroot=true;
    this.createEmptyMovieClip("draw_area", 5);
    this.onMouseDown = function() {
    poly = new Object();
    poly.x = _xmouse;
    poly.y = _ymouse;
    draw();
    };
    function draw() {
    if (this.draw_area.start_point.hitTest(_root._xmouse, _root._ymouse, false)) {
    removeMovieClip(this.draw_area.start_point);
    } else {
    temp = this.draw_area.attachMovie("start_point", "start_point", 2);
    temp._x = poly.x;
    temp._y = poly.y;
    }
    }
    Hit Test Object? [Archive] - kirupaForum::
    20 posts - Last post: Aug 6I have added a trace for the y position of the MC and its always at 50 which ever . ace one sound, load another, or change props, running one packs 'em back up again But it doesn't seem to work, any help on this?
    http://www.kirupa.com/forum/archive/index.php/t-319135.html
    HOME

    Any ideas??

    Thanks!!!


  • try this out:
    var draw_area:MovieClip = this.createEmptyMovieClip("draw_area", 5);
    this.onMouseDown = draw;
    //
    function draw():Void {
    // test for parent's xmouse and ymouse as this is loaded into another swf
    if (draw_area.hitTest(this._parent._xmouse, this._parent._ymouse)) {
    draw_area.start_point.removeMovieClip();
    } else {
    var sp:MovieClip = draw_area.createEmptyMovieClip("start_point", 0);
    trick7 - Flash で cover flow 表現::
    2007年1月29日 各MCをクリックした時の移動やアルファ・明度は全て Fuse で管理、Fuse の .. and add Function with hitTest, I make a code but it doesn't working, . It seems that the reflection class doesn't work when I load XML into
    http://www.trick7.com/blog/2007/01/29-222233.php
    HOME
    sp.attachMovie("start_point", "poly", 0, {_x:this._xmouse, _y:this._ymouse});
    }
    }


  • I threw in a variable and an if statement so it only does the prototype function once, which worked...

    Thanks!!!


  • I added the following code into my loaded movie:

    MovieClip.prototype.oldHitTest = MovieClip.prototype.hitTest;
    MovieClip.prototype.hitTest = function(x, y, sf) {
    var obj = {x:x, y:y};
    trace("hittest");
    this._parent.localToGlobal(obj);
    return this.oldHitTest(obj.x, obj.y, sf);
    };

    which made hitTest work great stand-alone or in a loaded mc. However, if I unload the movie and then load it again...it doesn't work and it freezes up?!

    In the trace, I get a "256 levels of recursion" error...

    You can see what I mean at:
    http://www.brianwpiper.com/hitTest.htm

    Anyone have any ideas??

    Thanks!!


  • Cool...thanks...still doesn't work though...I think it's a problem with assigning the prototype to the _parent twice?? Maybe??


  • Thanks! That works in the movie when it's loaded into another movie, but I wanted to make it so that it will work stand-alone OR as a nested movie...

    Found the answer at:
    http://www.bit-101.com/blog/?p=499

    Apparently, hitTest needs to call the _xmouse and _ymouse locations from the root movie. It works if I remove _lockroot, but I need that in my actual loaded movie (not in the test file) so that my components will work...

    This new code works GREAT and supports both versions just using this!!

    WOOHOO!!!


  • you should use removeMovieclip instead of unload. That will only work tho, if you attached it with AS





  • Challenging Books For A 14 Year Old?
    First guitar : acoustic or electric?

    You are looking at:hznm.com's HitTest doesn't work in loaded mcs?!, click hznm.com to home
  • wedding videotape
  • the photoforum chatroom
  • help with scanning very glossy pics
  • center af point keeps changing
  • advice on crop
  • d80 exposure questions
  • what do i need for a simple ebay studio
  • posting pic problem
  • fixed lens or zoom
  • b w in camera or photoshop
  • kenko tubes
  • cold weather shooting
  • is school worth it
  • sharpness and focal length
  •  
  • best lens for street photography
  • my photos gallery
  • newbie query
  • best time of day to shoot outside
  • digital slr or film slr for beginner
  • lighting questions
  • focus hunting
  • online photog courses
  • digital framing
  • 35mm help orange pictures blurry pictures
  • cool clouds
  • over my head
  • help choosing lenses
  • starting a photography biz
  •  Homepage | Add to favorites | Contact us | Exchange links | LOGIN | Site map | 
    Copyright© 2008 hznm.com        Site made:CFZ