hitTest problem...

  • hiya... i am using the hitTest function to tell whether the mouse has rolled over or off a specific area... the problem i have is that the area is the full size of my flash... and for some reason when i roll in andout from the top it is fine... but when i rollin and out from the bottom or sides it wont start again...? why? is it because it needs to read a non hit within the flash window? is there a hitTest on the actual flash animation window? or do i simply need to make the border area larger?

    hope im making sense...


  • umm... im pretty sure theres a better way to do what you are attempting to do, but i can't think of it right now;)


  • Here's another idea that don't work.

    var b = Stage.getBounds(this);
    this.onEnterFrame = function(){
    if (_xmouseb.xMax _ymouseb.yMax) {
    trace("in stage");
    }else{
    trace("out of stage");
    }
    I know this dont work. Stage can't provide but the Stage.height and Stage.width not getbounds. but I figure unless the swf always thinks there's a cursor on stage that since it's a onEnterFrame call that it will continue to be called. So if I can wrap the var b with the Stage's bounds this should work in theory.


    For jjcorreia-
    I thought to make something more dynamic and work flow friendly.


  • Why do you keep posting things that dont work?? This thread could go on for years posting things that dont work.

    For jjcorreia-
    I thought to make something more dynamic and work flow friendly.

    The solution provided is dynamic and workflow friendly enough. It is also the most cpu friendly solution. Trying to find bizarre combinations of items that wont consistently work is not work friendly. Sometimes a simple solution is all you need.

    :puzzled:


  • That doesnt work. MouseMove events stop firing when your cursor leaves the flash stage. (Fortunately AS 3.0 has a special event made specifically for alerting your movie when the mouse has left, so we wont have to have cheap solutions anymore :) ).

    The solution I provided earlier or a variant of it should be sufficient and easy enough.


    thats why I say to have it pad in words one pixel. that way it fires before you leave the swf.


  • Could be a problem with the height property or maybe an onEnterFrame command shut down to soon, incorrect hitTest, scope issue etc etc. As JJ pointed out earlier, its difficult to help blindfolded. Can you post a sample?

    Pablo.


  • thats why I say to have it pad in words one pixel. that way it fires before you leave the swf.

    That may not be very reliable. If the mouse cursor misses that one pixel for any rason then it wont fire. Theres no reason to use something that risky over a simple method like I showed.

    And why would you use getBounds when you should just use Stage.width and Stage.height?


  • not sure what you mean FizixMan?

    but yes i am basically creating something where by you enter the flash animation area and it stops scrolling and then when you leave it continues scrolling... the area is the whole flash animation... and as FizixMan said it is only firing from the top...

    so what would be the best way to do this?


  • Or you could use the boundaries of the stage.


    onMouseMove = function(){
    if(_xmouse > Stage.width
    _xmouse < 0
    _ymouse > Stage.height
    _ymouse < 0){
    trace("mouse out of bounds")
    }
    }

    That doesnt work. MouseMove events stop firing when your cursor leaves the flash stage. (Fortunately AS 3.0 has a special event made specifically for alerting your movie when the mouse has left, so we wont have to have cheap solutions anymore :) ).

    The solution I provided earlier or a variant of it should be sufficient and easy enough.


  • Or you could use the boundaries of the stage.


    onMouseMove = function(){
    if(_xmouse > Stage.width
    _xmouse < 0
    _ymouse > Stage.height
    _ymouse < 0){
    trace("mouse out of bounds")
    }
    }


  • alright people start giving some constructive post.

    anyone?

    Your post has been the least constructive so far, whereas I was making a valid inquiry into his issue.

    We have to first understand better what he is trying to accomplish before we can give him the best solution. I can throw any solution at him, but it would be more effective and educate him better if its the proper solution, not some random alternative that may cause other issues.


  • Why do you keep posting things that dont work?? This thread could go on for years posting things that dont work.
    The solution provided is dynamic and workflow friendly enough. It is also the most cpu friendly solution. Trying to find bizarre combinations of items that wont consistently work is not work friendly. Sometimes a simple solution is all you need.

    :puzzled:

    Your right you did provide a fulfilling solution to the problem. I hope it help the person who needed the help. I my self never once until I had read this thought that I would ever need such a solution to this problem. But being a novice I thought I could expand upon my knowledge of Action scripting by having a engaging conversation on possibly providing a better solution. In a sense I'm just practicing to be a better programmer.

    I under stand the hole "if it's broke to fix it". I also under stand how to keep it simple. It's very simple to see your logic here, and I'm doing nothing to discredit it. I just don't see how out side the job why it would be trivial to try to learn something new. Why would some one such as your self who has the ability to show their credentials, obviously has skills in this field and has put forth the effort here in this topic wish to stop any one else from proceeding in this topic. I guest I'm just disappointed that you would rather be negative here then be a participant. And don't take this as a insult I just wish to learn more myself.


  • Instead of hitTest, use the onRollover and onRollOut methods. You can hide the cursor hand change by setting useHandCursor to false.

    See the link http://www.jacobcorreia.com/kirupa/bdd/mouseout/ as well as the attached fla.


  • I was thinking something like this to getbounds but this wont work too

    var bounds_obj:Object = Stage.getBounds(this);
    for (var i in bounds_obj) {
    trace(i+" --> "+bounds_obj[i]);
    }but I get

    There is no method with the name 'getBounds'how can you get bounds of the stage and place them in a object.

    I figure once you can do this there is a better way to see if you go out of bounds that don't require a _mc.



    edit:
    var bounds_obj:Object = _root.getBounds(this);
    for (var i in bounds_obj) {
    trace(i+" --> "+bounds_obj[i]);
    }but I get output

    yMax --> 6710886.35
    yMin --> 6710886.35
    xMax --> 6710886.35
    xMin --> 6710886.35which I think is the max allowed of a stage which is kinda cool to know though I would never think that any one could use so much but hay what ever.


  • alright people start giving some constructive post.

    anyone?


  • I believe the problem lies partly with the browser. Rolling off some sides doesn't fire to flash that you've "left" the area. In Flash your mouse cursor just stays where it is. So when you bring your cursor back in from the browser, since it never actually left the area, it doesn't fire an event that you've rolled back onto it.


    Maybe you could try having an even for onMouseMove and do the hittest then?


  • Why are you running a hitTest for the full size of the flash movie?







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about hitTest problem... , Please add it free.