Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hitArea in movieclips

Status
Not open for further replies.

skeletrooper

IS-IT--Management
Jun 2, 2003
19
US
Two questions:

1) How can you set a MC's hitArea by the image's alpha channel, as opposed to its rectangular dimensions? I have a complex 3D rendered object, and I want the MC "button" to be clickable only over the colored (non-transparent) parts.

2) How do you set a MC's hitArea with another MC? (what's the syntax?) My incorrect code is:

onClipEvent (load) {
_level0.3Dimage.hitArea = _level0.circle;
}


Thanks!
 
Are those non-transparent parts moving? If not you could stick all those parts' shape in the hit aera of an invisible button, and it should work as well.

Regards,

cubalibre2.gif
 
Hi again oldnewbie,

The non-transparent parts are not moving. Question #2 is answered. I'll use an invisible button. But...

The 3D rendered image (within the MC) has an alpha channel, in addition to the alpha channel of the instance. Flash isn't recognizing the transparency of the 3D image as a hit area; it just detects the 3D image dimensions (640x480), and makes that the hit area.

Here's a link to the 3D image I'm using...I only want the hit area to be the cow, not the entire 640x480 image):


-Wes
 
Hey! Figured it out!

Check out
You have to import the 640x480 image (with transparency) into the library, manually select the transparent part of the image, and delete it. Then copy the "silouette" into a new NC.

Thanks again.

-Wes
 
Problems again.

I cannot use an invisible button because the MC that is below it on the timeline has rollOver and rollOut events that need to be driven by the mask in the invisible button!

So it looks like I need to use hitArea or setMask for the movieclip, but it isn't working. What is the syntax for setMask or hitArea? Assume I have a mask MC named "maskMC".

Here's my code for movieclip oneOut:

onClipEvent (load) {
stop ();
var speed = 1;
var direction;
maskMC.hitArea; <---doesn't work
}
onClipEvent (enterFrame) {
if (direction == &quot;ff&quot;) {
gotoAndStop (_currentframe+speed);
} else if (direction == &quot;rr&quot;) {
gotoAndStop (_currentframe-speed);
}
}
on (rollOver) {
_root.oneOut.direction = &quot;ff&quot;;
}
on (rollOut) {
_root.oneOut.direction = &quot;rr&quot;;
}
on(release){
_root.gotoAndplay(&quot;commer1&quot;);
}
 
Can you post a mockup .fla if you don't want to post your original... Beats having to re-create the same setup from nothing and the info you've provided.

Regards,

cubalibre2.gif
 
Guess the code would be...

onClipEvent (load) {
stop ();
var speed = 1;
var direction;
this.hitArea = _root.maskMC; <---should work
}


Regards,

cubalibre2.gif
 
Thanks Bill.

I have to side with oldnewbie, however. How can it be done with hitArea? In the example you gave the rollOut area is too large - I need it to respond to the exact shape.

Thanks again for all the attention you've given this problem!

-Wes
 
Although I hate to admit it, Bill's solution is probably the easiest in this case and if you keep this exact concept.
All you would have to do is actually shape the mask (rather than using a quick drawn rectangle as Bill as done!), the same as your cowcut.

A hitArea would work better (but that would mean a change of concept) if your link was actually inside the cow, in the inner section being unveiled, rather than being superimposed over the cow cut, once opened.
Otherwise the hitArea has to be progressively changed, as the cowcut moves out, to cover that whole new larger area... And the mask solution then appears much more easier.

If all of this makes any sense to you!

Regards,

cubalibre2.gif
 
Yes, I think I follow.

The problem with shaping the mask is that there are 7 other cow cuts that come out of the cow (chuck, round, sirloin, etc.), and the mask accuracy needs to be almost to the pixel. Time-consuming.

Can't I have the negative space be a MC, the animated slab of meat another MC, and reference the negative space MC hit area to the animated slab MC?

I'm not 100% sure what you mean by change of concept. I still need the slab of meat to animate outwards, and the rollover/button effects to be driven by the negative space. But I can re-render, recomposite any of the component images as you suggest.

-Wes
 
I have nothing against your slab of meat animating outwards, I just ment that to me, the link that you now have superimposed over the outward piece (commercial CHUCK or whatever it is...) should in fact be in the cavity created by the slab's mouvement. If that cavity has been defined as the hitArea then it simplifies the whole thing in the sense that the link in contained in the cavity part. Otherwise, as soon as I move out of the cavity (which is the hitArea), then the slab closes and I can't hit the link!

On the other hand, I don't think masks made to match the cutout pieces of the cow would be that much work!

Regards,

cubalibre2.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top