Link to home
Start Free TrialLog in
Avatar of veematics
veematics

asked on

Flash HitTest Problem

hello,
i got problem with my flash. I create a project optimize for 1024x768 screen resolution. To make it compatible with higher resolution, i use calculation with Stage.width so the content will be keep in the center (for the swf i use 100% width).

The problem arise with buttons that use hitTest instead of rollOver... because it seem, when i test on 1440 screen.. hitTest area is not reflect to new position, so it's detect on wrong area.

for example:
go to : http://www.doxadigital.com/domus2010/ and choose domus in middle icon. In home area,in 1440 screen,  when cursor on About Us, the other button doesn't slide to the right... i need to reduce my browser size to 1024 , then it begin to work as intended.

i hope this clarify my situation... i got headache caused by this HitTest problem...
Avatar of Antonio Estrada
Antonio Estrada
Flag of Mexico image

Interesting... care to post your fla to take a look at it?

-V
Avatar of veematics
veematics

ASKER

it's a client work that supposed not published yet... by the way, i think the problem arise with on stage resize because i did this code:

var stageListener:Object=new Object();
stageListener.onResize=function(){
      position();
};

Stage.align="TL";
Stage.scaleMode="noScale";
Stage.addListener(stageListener);

function position() {
      this.container._x=(Stage.width-1024)/2;
}
position();

if i delete the listener... it work without problem, but when the screen resize , it would not automatically set to center.

i also try with using onEnterFrame like this:
blank.onEnterFrame=function(){
      //trace(Stage.width);
      this._parent.container._x=(Stage.width-1024)/2;
      
};

sampe problem with hitTest..

i googled find 'potential' solution regarding localToGlobal or vice versa.. but still unable to solve...
And what's the original _x position for the container?

How is it calculating that if it's not being resized?

What is "container"?

That's why your fla (or a stripped down version if you want) would be easier to look at :)

-V
Correction: It still broken when display the .swf in html....

And what's the original _x position for the container? What is "container"?
container is a blank movie clip symbol.. it start in x=0, y=0.

How is it calculating that if it's not being resized?
at first time it will recalculate to set in center whatever the Stage.width is
function position() {
      this.container._x=(Stage.width-1024)/2;
}
position();

i'll arrange a stripped down version
here's the stripped down version,:
http://rapidshare.com/files/409460799/debug.rar

please try the .swf first before open the fla.. default display will be 1024x768.

the behavior for menu is simply: zoom 'n slide.. the selected menu get zoom (via tween).. other will slide to left/right depend on selected menu

the problem:
when you stretch the width...  "about us" button will stop the sliding effect which using hitTest function coded on home.swf (home.fla on line 172), the longer you stretch (i'm using dual monitor though) the longer sliding effect will not work.. as it still stay on the current position (not getting update with the container's position)

sorry for my bad english i hope you guys understand what my problem is..

thanks
This is perfect, let me play a bit with it and I'll get back to you.

-V
ASKER CERTIFIED SOLUTION
Avatar of Antonio Estrada
Antonio Estrada
Flag of Mexico image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No..i'm sorry mate.. result still the same.

 i expand the swf to fill dual monitor.... the menu is in center.. but hitTest fail to do its job. Also if you test on single monitor with 1440 screen width.. you'll see the anomality..
Vulturous really provide good solution, he really master actionscript in and out...
Sorry for my last respond when i said it didn't work.. it turn out i work on the stripped version when i test on the real project.... localToGlobal is the real solution i don't really why localToGlobal could solve the problem..  do you mind to explain what the real problem and why localtoGlobal could provide me the solution ?
Interesting, just tried it on a1680x1050 (my home PC) and it works fine on every case. Here, I took a screenshot of it, check it out: http://vulturous.110mb.com/eefiles/screen.png

I'm afraid I can't try the dual monitor thing since I don't have two here, perhaps if I bug some guys at the office tomorrow morning I can get my hands into one, but could you post a screenshot of what it's doing so I can take a look at it?

And, not to sound arrogant, but are you sure you changed the code and compiled the swf...  and that that compiled swf was the one you tried?

Maybe if you uploaded it to a server to try it out you got a cached version of it and that's why it looks the same?

-V
Oh ... err... disregard my last comment.

LocalToGlobal does the trick 'cause the _xmouse and _ymouse values are actually properties of the MovieClip class. In ActionScript 2.0, every elemnt out there is a subclass or implements in some way the MovieClip class, so even the _root (your swf) inherits the properties like _xmouse and _ymouse.

Since the swf is being loaded by another swf, the _xmouse position WILL be the same if the area is the same, when you expand it, and tell the parent swf that it WON'T scale, the home swf suffers a bit from it, gaining a bit of an offset from the movement Flash does. that's why if the stage was the same size or smaller, nothing wen't awry.

Hope that clears it up, and I'm glad to help.

-V