A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: hitTest() problem

  1. #1
    Senior Member
    Join Date
    Feb 2002

    hitTest() problem


    I have a scrolling image bar at the bottom of a webpage. This bar moves into position when a button is pressed. I have a movieclip over the main area of the webssite which has an alpha of 0%. Now when the mouse is over this mc the bar stays at a certain _y and when the mouse moves off, it goes to another _y and dissapears behind a mask.

    Now my problem is this: The .swf works perfectly but when it is embedded into a HTML page it doesn't work very well, sometimes it works sometimes it doesn't and if you move the mouse off the hitTest area quickly it doesn't work at all. I have also noticed that when you move the mouse off, the hitTest area seems to be in the correct place but as you move it back over, it has shifted.

    Here is the code:

    this.onEnterFrame = buttons;

    function buttons (){
    menu_mc.button1_mc.btn_txt = "Contact"
    menu_mc.button2_mc.btn_txt = "Portfolio"
    menu_mc.button3_mc.btn_txt = "Services"
    menu_mc.button4_mc.btn_txt = "Profile"
    menu_mc.button5_mc.btn_txt = "Home"

    if( _root.btnPressed == _root.menu_mc.button2_mc){
    if(_root.hit_area.hitTest(_root._xmouse,_root._ymo use,true)){
    _root.thumbBarHolder = 502
    } else {
    _root.thumbBarHolder = 574

    Anyone ever encountered this problem before? and is there a solution or is there something wrong with my coding? Is there another way of doing this? Should I base the hit area on mouse coordinates instead of using an mc and hitTest()?

    Thanks in advance for any help offered.


  2. #2
    Senior Member
    Join Date
    Feb 2002

    Problem solved

    Well I finally worked out what the problem was.

    There was nothing wrong with my code. I was publishing the swf with a transparent windowless background and this was causing issues.

    I have now put a larger mc with alpha = 0 into the background so that my mouse is still over something in the website when it comes off the hit area and it all works fine.


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