CS3 Hit test on buttons misbehaving.
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Hit test on buttons misbehaving.

  1. #1
    Registered User
    Join Date
    Feb 2014
    Posts
    1

    Angry Hit test on buttons misbehaving.

    Hello,

    I have been using flash for a while now 2 years or so, but I have never come across this before and I am stumped. I have a game I am making and there are dozens of buttons, but 5-6 of them for reasons unknown only have a hit test of about 6% of the actual button. Strange little places on the image where the hit tests work. I have tried adding a transparent square over the top in all states including the hit state and it still doesn't pick up the hit frame or the image.

    I have tried deleting the few buttons and creating new symbols and dropping them in but still the same issue. The only script I have on the frame is a few if statements and a few for loops.

    I have spent the last 2 days googling around and only found about 5-6 posts regarding this and all of them were un-answered, I'm hoping one of you skilled developers might know what's causing this and if so what the fix is. Thanks!

    Code:
    AttackMinion.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_3);
    
    function fl_MouseClickHandler_3(event:MouseEvent):void
    {
    	if (Object(root).CurrentTurn == 1)
    	{
    		Object(root).Player1Action = 1;
    		Object(root).Player1XP +=  AttackCardCount;
    		Object(root).Player1AttackCount -=  AttackCardCount;
    		if (Object(root).Player1Passive == 1)
    		{
    			Object(root).Player1RetDmg += Math.floor(AttackCardCount/2);
    			if (Object(root).Player1RetDmg >= 1)
    			{
    				Object(root).Player1RetDmg -=  1;
    			}
    		}
    		else
    		{
    			Object(root).Player1RetDmg += Math.floor(AttackCardCount/2);
    		}
    		Object(root).Player1RetDmg -= Object(root).Player1Armour
    		for (i=1; i<=Object(root).Player1RetDmg; i++)
    		{
    			Object(root).Player1Discard.push(new AsheWoundDraw());
    		}
    		for (i=1; i<=AttackCardCount; i++)
    		{
    			Object(root).Player1Discard.push(new AsheAttackDraw());
    		}
    		this.gotoAndStop(1);
    	}
    	else if (Object(root).CurrentTurn == 2)
    	{
    		Object(root).Player2Action = 1;
    		Object(root).Player2XP +=  AttackCardCount;
    		Object(root).Player2AttackCount -=  AttackCardCount;
    		if (Object(root).Player2Passive == 1)
    		{
    			Object(root).Player2RetDmg += Math.floor(AttackCardCount/2);
    			if (Object(root).Player2RetDmg >= 1)
    			{
    				Object(root).Player2RetDmg -=  1;
    			}
    		}
    		else
    		{
    			Object(root).Player2RetDmg += Math.floor(AttackCardCount/2);
    		}
    		Object(root).Player2RetDmg -= Object(root).Player2Armour
    		for (i=1; i<=Object(root).Player2RetDmg; i++)
    		{
    			Object(root).Player2Discard.push(new AsheWoundDraw());
    		}
    		for (i=1; i<=AttackCardCount; i++)
    		{
    			Object(root).Player2Discard.push(new AsheAttackDraw());
    		}
    		this.gotoAndStop(1);
    	}
    }

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Posts
    106
    I am confusing the title of your post with your question. Typically a "HitTest" is used to describe the collision of two objects in flash like when you determine if a drag and drop is successful.

    By quickly looking at your code, it appears that this button is just manipulating number data and moving the timeline to frame 1.

    If you could attach the .fla I could take a look and see if i can help you.

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

Poll by Flashkit.com