AS1: Another Nested Button Menu - HitArea Within HitArea - Easy Way To Mask?
Yet again I find myself creating a nested button menu, and not having an easy way to create stacked Mouse actions.
What I want to create is a small rectangle centered in a large rectangle and both have onRelease effects. And, I want to attach them so that the large rectangle is the parent and the small rectangle is the child(this makes handling the menu easier). Also, each button should really be a movie clip with an onRelease function attached. That is the goal. There are some long ways around to do this that I am familiar with, such as creating a mask for the hit area of the parent. BUUUUUUUT - of course it would nice to do all this dynamicly (I know my spelling is bad). So is there any way to maybe EASILY subtract the area of the child from the hitarea of the parent??? Looking for alternative methods from writing some long drawing process via the lengths and widths and all.
Of Note: What I seem to know is that a onRelease function on a parent MC will disable the onRelease function of a child MC when they share a hit area.
Thanks! Birdsong
FlashKit > Flash Help > Flash ActionScript
Posted on: 05-27-2004, 01:07 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Another Nested Button Menu Q - HitArea Within A HitArea - Easy Way To Mask?
Yet again I find myself creating a nested button menu, and not having an easy way to create stacked Mouse actions.
What I want to create is a small rectangle centered in a large rectangle and both have onRelease effects. And, I want to attach them so that the large rectangle is the parent and the small rectangle is the child(this makes handling the menu easier). Also, each button should really be a movie clip with an onRelease function attached. That is the goal. There are some long ways around to do this that I am familiar with, such as creating a mask for the hit area of the parent. BUUUUUUUT - of course it would nice to do all this dynamicly (I know my spelling is bad). So is there any way to maybe EASILY subtract the area of the child from the hitarea of the parent??? Looking for alternative methods from writing some long drawing process via the lengths and widths and all.
Of Note: What I seem to know is that a onRelease function on a parent MC will disable the onRelease function of a child MC when they share a hit area.
Thanks!
Birdsong
Nested HitArea Problem
Could someboby give me the right syntax for setting the hitArea of a graphic as follows:
Obj_A and Obj_B are nested inside Obj_C and Obj_D is on the main stage. I want Obj_C's hit test to be true when (only) Obj_A hits Obj_D.
I hope this is clear, I tried to simplify this as much as possible.
This is the line I am presently using but Obj_C's hit test is true when either Obj_A or Obj_B hit Obj_D.
_root[Obj_C[i]].hitArea=_root[Obj_C[i]]+"."+[Obj_A[i]];
Thanks
Trouble With Drop Down Menu: HitArea? Scope? (slowly Going Insane…)
I'm trying to build a set of drop down menus (.fla attached below).
I had to separate the header movie clips from the submenus to work around a stacking issue and then use an alternate and invisible hitArea to keep the submenus down when I rolled off the heads. Everything works except for the submenu clips which do not respond to rollovers (they work fine in other test enviroments).
Is the alternate hitArea shape (which is above the submenu clips) interfering with rollover? The player can see nested mouseEvents, no?
Something else I'm missing?
It seems to me like I was having similar troubles before the hitArea fix (at about 4 am) and I'm still having trouble with relative and absolute paths (relative paths tend to work less often). But I could generally sort those out after a bit.
stumped, dead in my tracks, and slowly becoming insane
Button Hitarea Needs Lowering? Mx2004/7
Hi!
I have a background layer with some button hitareas on.
When hovering over a white box on a layer above the buttons underneath gets activated.
How do i prevent that?
Hitarea Broken On Filtered Button
Anyone else come across this?
I created a button with a hit area that was not directly over the button contents. The button behaved exactly as it should, the button activated when over the hit area and not when over the button content.
When I add a filter (using the properties panel) to the button however, the hitarea stops working completely. If I move the hit area so that it overlaps the button content it works in the overlapped area only.
The workaround is to place the filter inside on each of the button states.
I searched the forums here and on Adobe but didn't see any mention of this apparent bug.
Confining Hitarea Of Movieclip Used As Button
Hello all
I have a movieclip that I'm using as a button, and within the clip I have actionscript which tells the clip to gotoandplay a certain frame label on rollover. Part of that rollover animation is text which emerges out of the main area of the button (which also disappears upon rollOut). The problem is, once the text emerges, it then becomes part of the hit area within the movieclip, and that complicates the animation if the user rolls over the text before it fully disappears on rollout. Is there any way to disable the text's hitarea altogether? I tried making the text a movieclip and setting the hitarea = null, but that doesn't work because I have no idea what I'm doing. Any help would be appreciated.
Confining Hitarea Of Movieclip Used As Button
Hello all
I have a movieclip that I'm using as a button, and within the clip I have actionscript which tells the clip to gotoandplay a certain frame label on rollover. Part of that rollover animation is text which emerges out of the main area of the button (which also disappears upon rollOut). The problem is, once the text emerges, it then becomes part of the hit area within the movieclip, and that complicates the animation if the user rolls over the text before it fully disappears on rollout. Is there any way to disable the text's hitarea altogether? I tried making the text a movieclip and setting the hitarea = null, but that doesn't work because I have no idea what I'm doing. Any help would be appreciated.
Reverse Animation Using Button Hitarea
Hi there,
I'm a total noob to Actionscript / flash and i'm trying to put something together for my new site. Basically, what im trying to do is animate an image when the mouse is rolled over it, and animate it back out again when the mouse leaves the area.
Attached to this post are the two test files i'm working on. The first (titled working.fla) does exactly what im trying to do, but messes up when you run the mouse over the right-hand side of the movie area. The second (titled helpme.fla) was another test to see if I could get the same animation while hovering over a button instead of hovering over the movie clip.
So, the question is - is it possible to do this using a button as the 'hitarea' for the movie clip animation? And if so, how do I alter the included files to get this working?
Any help is greatly appreciated,
JT
Button/MovieClip Bug ... Hitarea 'shifts' In Browsers
Once in a while, I would be checking a Flash site or app in a browser, and the Flash's button's hitarea would be 'shifted' by a few hundred pixels below/away from it.
Meaning the hidden hit area of the button or movieclip does not align with the visible part of the button or movieclip. This happens in IE, Firefox, Safari on Mac and Windows, and multiple computers. But with a refresh it fixes itself.
I've only started noticing this hitarea "shift" bug, since the advent of the Javscript Active content fixes.
Has anybody experienced this issue?
Disabling The Tab Button To Protect HitArea Locations
Hey there guys,
Iam making an interactive flash game which is based on the fact that the user shouldnt know where to click. I am aware that it is easy to press the tab button to find these hit areas.
Does anyone know some action script to disable the Tab key.
Any help would be awesome.
Thanks
Hitarea
I cant understand the explanation about "hitarea" in Action Script Dictionary of Flash. Could someone tell me how to use the function of hitarea? thx very much.
Can I Use A Hitarea To...
hi
I wonder if I can use a hitarea to let some mc stay visible when the rest of the mc gets unvisible. is it possible to do something like:
if ("the object are in this area") {
visible = true
} else {
visible = false
}
how do I do this correct in actionscript?
grateful for every little help I can get
lemon_juice
How To Use HitArea()
Does anybody know if hitArea() works with flash 5? Has anybody come across a tutorial for using that? I need to use an MC as a hit area for a menu to hide. Is this the best way?
thanks in advance
HitArea
Hey
I'm making something like on the Macromedia main site..the toolbar. I have the actionscript in and it works good, but I want it so when you click on the anything other than a link in the submenu, they submenu will go away.
If you don't know what I am talking about, look at the macromedia site and at the toolbar on the top. They have it nicely done where when you click a button, the sub-menu comes out and then you click on the submenu, but what you click on isn't one of the links, the sub-menu goes away.
Well, how would you do that?
Thanks
HitArea()
How does hitArea() work.
I have 2 buttons "B1" & "B2".
I also have a movieClip on the stage "Mc1".
When I click B1, I want Mc1 to be part of B2's HitArea.
I have Tried This: (no luck)
_root.B2.hitArea(_root.Mc1);
I also tried placing B2 in a movieClip and calling it "McB1":
_root.McB1.hitArea(_root.mc);(no luck)
&
_root.McB1.B2.hitArea(_root.mc);(no luck);
Could someone please show me some working code, or explain what is happening here. I have even tried:
_root.B2.hitArea = _root.Mc1;(since it is a property...NO LUCK)
Thanks,
Chris
HitArea
I wanted to add an invisible hitArea so that the mouse responds to a square shape enclosing a cross shaped button
But the code below doesn't seem to work. Mouse behaviours continue only a interaction with the cross.
Attach Code
package flash.jane.gui.buttons{
import flash.display.Sprite;
import flash.jane.data.Settings;
import flash.events.MouseEvent;
import flash.events.Event;
public class AddButton extends Sprite{
private var cross:Sprite=new Sprite();
private var dummySprite:Sprite=new Sprite();
private var rollOverColour:int=0xBD5DD8;
public function AddButton(){
dummySprite.graphics.beginFill(0xFF00FF);
dummySprite.graphics.drawRect(0,0,20,20);
dummySprite.mouseEnabled=false;
draw();
this.hitArea=dummySprite;
addChild(cross);
this.addEventListener(MouseEvent.MOUSE_OVER,drawOn);
this.addEventListener(MouseEvent.MOUSE_OUT,drawOff);
this.addEventListener(MouseEvent.CLICK,sendEvent);
}
private function draw():void{
cross.graphics.clear();
cross.graphics.lineStyle(1,0x000000);
cross.graphics.beginFill(0xFFFFFF);
cross.graphics.moveTo(5,0);
cross.graphics.lineTo(5,5);
cross.graphics.lineTo(0,5);
cross.graphics.lineTo(0,10);
cross.graphics.lineTo(5,10);
cross.graphics.lineTo(5,15);
cross.graphics.lineTo(10,15);
cross.graphics.lineTo(10,10);
cross.graphics.lineTo(15,10);
cross.graphics.lineTo(15,5);
cross.graphics.lineTo(10,5);
cross.graphics.lineTo(10,0);
cross.graphics.lineTo(5,0);
}
private function drawOff(e:MouseEvent):void{
cross.graphics.clear();
cross.graphics.lineStyle(1,0x000000);
cross.graphics.beginFill(0xFFFFFF);
cross.graphics.moveTo(5,0);
cross.graphics.lineTo(5,5);
cross.graphics.lineTo(0,5);
cross.graphics.lineTo(0,10);
cross.graphics.lineTo(5,10);
cross.graphics.lineTo(5,15);
cross.graphics.lineTo(10,15);
cross.graphics.lineTo(10,10);
cross.graphics.lineTo(15,10);
cross.graphics.lineTo(15,5);
cross.graphics.lineTo(10,5);
cross.graphics.lineTo(10,0);
cross.graphics.lineTo(5,0);
//addChild(cross);
}
private function drawOn(e:MouseEvent):void{
cross.graphics.clear();
cross.graphics.lineStyle(1,0x000000);
cross.graphics.beginFill(rollOverColour);
cross.graphics.moveTo(5,0);
cross.graphics.lineTo(5,5);
cross.graphics.lineTo(0,5);
cross.graphics.lineTo(0,10);
cross.graphics.lineTo(5,10);
cross.graphics.lineTo(5,15);
cross.graphics.lineTo(10,15);
cross.graphics.lineTo(10,10);
cross.graphics.lineTo(15,10);
cross.graphics.lineTo(15,5);
cross.graphics.lineTo(10,5);
cross.graphics.lineTo(10,0);
cross.graphics.lineTo(5,0);
//addChild(cross);
}
private function sendEvent(e:MouseEvent){
trace(e.target.name);
dispatchEvent(new Event("addButtonEvent"));
}
public function set overColour(colVal:int){
rollOverColour=colVal;
}
}
}//package
My Movieclip Has No Hitarea
I hope you can help me...
I try to make a learning program for kids in flash mx where the
purpose of playing it ,will make them to be better in multiplication.
I got a movieclip that are moving over the screen and a sight that you can shoot the right answer with..
Annyway,the hit area on the movieclip is so small...
I have to hit exactly on a point at the movie clip....or else nothings happens..
Have tried to lay an invissible movieclip under the other and put that to be it's hit area ,but it will not work..
Can it be because i use dynamic text?
i put the fla file in here so you can take a look
HitArea Question
I need a script to place on button when the mouse is pointed on the button it will change a variable i believe it to be hitarea
<script><
If (*mouse identifier whatever it may be*.HitArea) {
_root.MouseText = "Wilcox Ave."
}
</script>
HitArea And HitTest?
okay, is there a difference between hitArea and hitTest? Because, i have an enemy in the game im making and he's a big, bulky monster. What he does is slam the ground and create a wave of solid rock (easy to avoid), and he rips a huge chunk of rock out of the ground and throws it across the screen. both attacks are relatively small and, even if you dodge the attack, you get hurt. My theroy is that, since the rock and wave are part of the same movie clip as the monster, the length of the MC grows longer so the attacks stay inside the MC's boundaries. I thought hitTest meant the hit of the image.
reply.
[F8] Need Immediate Help: MouseMove Or HitArea(?)
Hi! I'm having MAJOR difficulties getting my pullout tabs to work correctly. Mainly (now) on the "roll back in" animation. Here's what I want it to do:
When the user click the "learn more" tab it will pull out, this tab is a movie clip which houses another movie clip which has three buttons inside of it. Currently I'm using a button on the exposed tab area (when it's pulled in) to do the pullout animation (and display the buttons inside the clip(s)). So I'm using "on(press)...etc" in the pullouts movie.
My problem is that I can't get on(rollOut, dragOut) to work on frame 25 of the clip(when it's stopped so the user can click the buttons) to pull it back in because then the buttons become inactive. I've tried looking up different methods and found references to using the onClipEvent using a defined hitArea but could NOT get this to work correctly, and I don't understand the whole "mouseMove" idea.
I need to get this figured out ASAP!!!
...and I really can't recode it so i have to find a way for this to work without recoding everything else. Any ideas?
(if you'd like to see the file please email me at stellagifford@gmail.com)
I'LL BE GRATEFUL FOR ANY HELP AT ALL!
HitArea Won't Register
I'm creating dynamic buttons from an MC that has a child called "hitMC" like so:
var button:MovieClip;
var i:uint;
//CREAT NAV ITEMS
for (i = 0; i < navArray.length; i++){
button = new navItem();
button.name = "but" + i;
button.txt.text=navArray[i];
button.txt.autoSize=TextFieldAutoSize.LEFT;
button.hitMC.width=button.txt.width;
button.hitArea=button.hitMC;
button.buttonMode = true;
addChild(button);
button.addEventListener(MouseEvent.CLICK, onButtonClick);
}
I don't get any errors, but the hitArea is still outside the extents of hitMC...
HitArea Problem
Dear Forum,
I'm trying to define a button hit area of "buttonHitArea1_mc" for button "buttonT1_mc". I've been staring at this code for hours trying to figure out why this isn't working, have searched and searched and everything I've found confirms that the syntax is correct. I've checked and double checked the instance names on the stage, case and spelling is correct, and I get no errors when running the swf.
The first two lines designate the hit area, the rest of the code is included in the event that it's relevant. When I run the code and drag my mouse over buttonHitArea1_mc it doesn't register. Just to make sure I was sane, I ran the code in the second example which worked fine (I added an array in case that was the issue). Any help would be wonderful.
Thanks,
James
Code:
stop();
buttonT1_mc.hitArea=buttonHitArea1_mc;
buttonHitArea1_mc.mouseEnabled=false;
///////INITIATE SOUNDS AS INSTANCES
var homeSound:HomeSound = new HomeSound();
var abovtSound:AbovtSound = new AbovtSound();
var meeteSound:MeeteSound = new MeeteSound();
var calyndarSound:CalyndarSound = new CalyndarSound();
var gyveSound:GyveSound = new GyveSound();
var experiensSound:ExperiensSound = new ExperiensSound();
var interactSound:InteractSound = new InteractSound();
var callSound:CallSound = new CallSound();
///////INTERFACE BUTTON ARRAYS
var buttonArray:Array = new Array (buttonT1_mc, buttonT2_mc,
buttonT3_mc, buttonT4_mc, buttonT5_mc, buttonT6_mc, buttonT7_mc);
var buttonSunArray:Array = new Array (buttonSunT1_mc, buttonSunT2_mc,
buttonSunT3_mc, buttonSunT4_mc, buttonSunT5_mc,
buttonSunT6_mc, buttonSunT7_mc);
var buttonSoundArray:Array = new Array (abovtSound, meeteSound,
calyndarSound, gyveSound, experiensSound, interactSound, callSound);
///////MOVIECLIPS TO BUTTON MODE
for(var initialButtonStop:Number = 0; initialButtonStop < buttonArray.length; initialButtonStop++)
{
buttonArray[initialButtonStop].buttonMode = true;
}
///////STOPPING INTERFACE BUTTON SUNS
for(var initialSunStop:Number = 0; initialSunStop < buttonSunArray.length; initialSunStop++)
{
buttonSunArray[initialSunStop].stop();
}
//////ADD EVENT LISTENERS
for(var initialButtonListen:Number = 0; initialButtonListen < buttonArray.length; initialButtonListen++)
{
buttonArray[initialButtonListen].addEventListener(MouseEvent.MOUSE_OVER, interfaceButtonSunRise);
buttonArray[initialButtonListen].addEventListener(MouseEvent.ROLL_OUT, interfaceButtonSunSet);
buttonArray[initialButtonListen].addEventListener(MouseEvent.CLICK, interfaceButtonCLICK);
}
///////VARIABLE
var buttonObject:String;
///////ICON NUMBER FUNCTION
function iconNumberFunction(e:MouseEvent):Number
{
buttonObject = e.target.name;
var pattern:RegExp = /d+/;
var varNumeralString:Array = pattern.exec(buttonObject);
var iconNumeral:Number = Number(varNumeralString);
return(iconNumeral);
}
////// FUCTION INTERFACE ROLL OVER BUTTON
function interfaceButtonSunRise(e:MouseEvent):void
{
var iconNumeral = iconNumberFunction(e);
buttonSoundArray[iconNumeral - 1].play();
buttonSunArray[iconNumeral - 1].play();
}
///////FUNCTION INTERFACE ROLL OUT BUTTON
function interfaceButtonSunSet (e:MouseEvent):void
{
var iconNumeral = iconNumberFunction(e);
var particularSun:Object = buttonSunArray[iconNumeral - 1]
particularSun.stop();
var reverseTimer:Timer = new Timer(10);
reverseTimer.addEventListener(TimerEvent.TIMER, reversePlay);
reverseTimer.start();
/* ENTER_FRAME performs a function at the current frame rate -
it seems to not really listen, just perform*/
function reversePlay(event:Event):void
{
if(particularSun.currentFrame >1)
{
particularSun.prevFrame();
}
else
{
reverseTimer.stop();
/* If you don't remove the event listener it will continue to run */
}
}
}
///////FUNCTION INTERFACE BUTTON CLICKS
function interfaceButtonCLICK(e:MouseEvent):void
{
var iconNumeral = iconNumberFunction(e);
switch (iconNumeral)
{
case 1:
gotoAndStop("niwes and calyndar");
break;
case 2:
gotoAndStop("meete the players");
break;
case 3:
gotoAndStop("experyense");
break;
case 4:
gotoAndStop("gyve");
break;
case 5:
gotoAndStop("the tavyrn");
break;
case 6:
gotoAndStop("abovt niwebyrth");
break;
case 7:
gotoAndStop("call on vs");
break;
default:
break;
}
}
This is that small test code:
Code:
stop();
square_mc.buttonMode = true;
square_mc.hitArea=circle_mc;
circle_mc.mouseEnabled=false;
var squareArray:Array = new Array (square_mc);
squareArray[0].addEventListener(MouseEvent.MOUSE_OVER, traceTest);
function traceTest(e:MouseEvent):void
{
trace("please work");
}
HitArea Problem
Hello,
i have about ten mc's on my fla. They all have the same structure :
each mc has a textfield with a word written in it.
when i define onRelease handlers for all of these mc's, it goes wrong though....
Sometimes the hitarea is the whole word (so also between the letters) and with other mc's the hitarea is only the black lines of the text itsself (so the whole in the 'o' is not clickable.......
The textfields are all the same : arial, 10 and bold.
and i realy don't want to give in to flash's strange ways by assigning hitareas for those few mc's where it goes wrong....
I really don't understand why flash would make a difference in assigning hitArea......
anybody got ideas?? thanks!
Mouse Over/out & HitArea
Hi all,
I wrote a DisplayObject by deriving the Sprite Object.
Every Sprite contains a cuple of circles. Only the outlines will be drawed.
Code:
...
while (current != null) {
if (current.isChanged()) {
this.graphics.lineStyle(2, current.color, 1.0, true, "none");
this.graphics.drawCircle(0, 0, current.size);
model.drawLinks();
}
current = current.bottom;
}
...
To theese Sprites I add two mouse listeners to be noticed if a mouse over or mouse out event will occur.
Code:
...
removeEventListener(MouseEvent.MOUSE_OVER, mouseOver);
removeEventListener(MouseEvent.MOUSE_OUT, mouseOut);
...
My Problem is that a mouse out event is registered if a user moves the mouse above an transparent pixel between two circle lines.
I want a mouse out event only if the mouse goes out the biggest outer circle.
To solve this problem I experimented with the hitArea property and set it to a Sprite which contains a filled circle in the dimension of the biggest line circle. I set the mouseEnabled property of the hitarea to false, but no mouseOver or mouseOut events were triggered.
I thought about another way and overrode hitTestPoint (hopefully that theese method will be used internally to find mouseOver and mouseOut events). I tried two bodies. One time I implemented a manual hit test for the outer circle. Another time I tried a super call to hitTestPoint with the shape argument set to false.
[b]But I don't find a solution :-(. Does anybody have an idea for me?[b]
Thx...
Define Hitarea
i use a movieclip. see swf-file (fla-size too large)
the grey rectangle should start fading in when you reach the red square (hit area), not already when you cross the edges of the grey square....
hi,
on the attached file i tried to do the following: when you roll over the button (square) the blur background should fade in sharp. sofar flash just recognizes the whole sharp background image as hit area. i tried to mask the layer with the sharp background image.... then it would recognize the button as hit area - but would not show the image either
(if you roll out the bakground image at the edge you see what i try to achieve...)
anybody can help me?
Use Loaded PNG As Hitarea
is there a way to assign a dynamically created movie clip the hitarea of a PNG file that is loaded into it via actionscript, basically creating a none square/circle hitarea that is a mask of the bitmap image. hopefully I'm making myself clear, thanks in advance.
HitArea Does Not Work
Hey, simple enough this one;
I have my button, i want it's hitbox to be that of another Sprite I have drawn, however I do not want to add this sprite to the DisplayList with alpha=0; wasting resources. I instead try to make the hitArea of the button, that of this sprite. But when trying to do this it has no effect. Both objects in this case ARE sprites, the background is definantly being drawn in as when I add it to the displayList it works fine.
All the bugs in flash are really starting to annoy me now!
Thanks for the helpful helpfulness,
Dan
HitArea Circle
I am trying to set up a cicular movieClip as a hitArea for another, but the circular shape is not detected rather the bounding box of the movieClip. is there any way around it? am i doing something wrong?
Code:
TurretRange_mc.hitArea = TurretActive_mc.TurretHitArea;
TurretRange_mc.hitArea (TurretActive_mc.TurretHitArea);
so far i've tried these two methods.
thnx.
HitArea In Movieclips
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!
A Scripted Hitarea?
arrrhg...
I need a hitarea that dosen't get messed up by the buttons indside it. I succeded in doing it for the y axis...
ActionScript Code:
var up = false;
_root.onMouseMove = function(){
if (_root._ymouse > 200) {
if (up == false) {
ball_mc.alphaTo(50,1);
ball_mc.tween("_y",-20,2,"easeOutElastic");
up = true;
}
}else{
if(up == true){
ball_mc.alphaTo(100,1);
ball_mc.tween("_y",100,1,"easeOutElastic");
up = false;
}
}
updateAfterEvent();
but i need a box and not the whole tophalf...
Was messing about with the my_mc.getBounds but I don't know how to make a functions that trigger the movement of MC's on Rollover?
any pointers u good people??
MovieClip.hitArea
The actionscript dictionary mentions: "The hitArea property can be read out of a prototype object."
However, there is no example of how to do that. Can anyone explain?
(no need for details about how objects and prototypes work : )
Thanks!
Chris.
MovieClip.hitArea
Hi,
I am just started to learn about the new event model in Flash MX. Regarding the movieClip.hitArea property, the Flash MX help file doesnt offer any sample codes, and its usage in a more indepth level.
I have 2 movieClips, one defines the hit area (mc_navHitArea) and the other is functioning like a button (mc_navBtn). I tried to define the hit are of mc_navBtn with mc_navHitArea. I used this piece of ac in mc_navBtn:
---
this.hitArea = _root.mc_navHitArea;
---
But it doesnt work. Both movieClips are in _root, and properly named instances as above. Hope anyone can shed some light on how to correctly use movieClip.hitArea?
Thanks!
Hitarea And Selectable Text...
i want to make a button that activates to reveal a piece of selectable text, but when the cursor goes over the selectable text the button deactivates... i think it's a bit of a flash problem and not coding...
attached is my file... see if you can figure it out.
er... i've posed this question in the general forum but it seems to have stumped ppl... so...
How To Designate A HitArea For A MovieClip?
How does one designate a hitArea for a MovieClip?
I am using... myClipButton.hitArea = "_root.myHitClip";
but what do i use visually in the movie clip as the hit area?????
Please help Thank you!
Problems Defining HitArea For MC
hello,
1. in the main timeline i created static text using the Text Tool (T).
2. then I converted it to a symbol of type movie clip.
3. i also exported the movie clip for ActionScript and assigned it a custom class in the linkage dialog.
the custom class that i have extends class MovieClip and is supposed to define a hitArea for the symbol so that i could click on the text anywhere and not only on the solid parts of the letters to invoke the "press" handler.
the class is shown below. the problem is that the rectangle that i draw to fill "this" movie is not drawn the way i expected. i does not have the same dimentions as the "this" movie clip. apparently i am doing something wrong. please help.
thanks
konstantin
class textbutton extends MovieClip
{
function textbutton()
{
var h:Number = this._height;
var w:Number = this._width;
var mc:MovieClip = this.createEmptyMovieClip("mc", 1);
with (mc)
{
moveTo(0, 0);
beginFill(0, 50);
lineTo(w, 0);
lineTo(w, h);
lineTo(0, h);
lineTo(0, 0);
endFill();
}
this.hitArea = mc;
}
};
Movieclip With Hitarea And Buttons?
Why don't my buttons work???
I have created a movieclip with a hitarea, simple tween and two buttons. But my buttons don't work any more???
How can I fix this???
Controlling _X Transitions Of MC Using 1 Hitarea
Anyone here think they could pick out what I'm doing wrong with this code?
I'm trying to control the _x position of an MC using a single button using the following code. The first part works and moves the button to _x = 362, but the second half of the code doesn't bring the button back to _x = 0.
The MC starts at _x = 0, when it is at that position or below _x=100 i want it to slide to the right 362 pixels. When it's at _x = 362 or at least above _x = 100 i want it to slide back to the left at _x = 0. Using one button.
I hope that's clear enough.
Code:
if(updates._x < 100)
{
hitarea.onRelease = function ()
{
this.onEnterFrame = function ()
{
updates._x = updates._x + (362 - updates._x) / 3;
}
}
}else
{
this.onEnterFrame = function ()
{
updates._x = updates._x + (0 - updates._x) / 3;
}
}
Unable To 'hide' A Hitarea Of Mc?
Hello,
i'm having a very strange and frustrating problem :
i have a few mc's on stage, and i want to hide them with another mc at a certain point, and so i also want to disable their onRollOver function. So i just put a big square over the mc that i want to hide to make it invisible. It works for the mc itsself, but the hitarea of the mc that is hidden is still active, although there is an other mc hiding it????
Extra information : i haven't declared any external hitArea of the mc that i want to hide, so it couldn't be that the hitarea isn't obscured by the square.
The square that hides the mc is on the top layer! So all the other mc's are under it!
Even more strange : it works like it should in 2 of the 10 mc, with 8 others, you can still trigger an onRollOver of the hidden mc, althoug the mc is invisible by the square that hides it....
I tried right click and select 'bring to front' but that doesn't work either.
I have no depth assignements in my actionscript. So it couldn't be that there are some unnoticed depth swaps...
really desperate ....
can anyone hepl please???
thnx!
HitArea Error At Different Hierarchy
Hi,
Am having trouble with the mc.hitArea property.
Works fine when the calling and target clips are part of the same movie clip, but breaks when the target clip is a level higher.
ie.
Code:
referenceMC.hitArea = targetMC;
is OK, but...
Code:
referenceMC.hitArea = _parent.targetMC;
//or
referenceMC.hitArea = _root.targetMC;
...aren't working. The reference clip's mouse actions don't work, so the hitArea property is changing, a trace of refernceMC.hitArea shows the correct target clip but the target clip's mouse actions are not doing anything....
Will try some test with new .FLAs. In the meantime, if anyone sees a mistake, please let me know
Movieclip With HitArea And Buttons?
Why don't my buttons work???
I have created a movieclip with a hitarea, simple tween and two buttons. But my buttons don't work any more???
How can I fix this???
MovieClip HitArea Problem
Hello
For some time I have been doing simple games and websites in flash.
But when I make an object, a circle for example, and then put it in a MovieClip the hitarea of the MovieClip becomes a Square INSTEAD of a Circle. If I for instance would want to use this circle for an hitTest this becomes an major bug/problem in a game. I hope you understand my problem and I'm grateful for any answers.
/Kim
Buttons In A MovieClip With HitArea?
Why don't my buttons work???
I have created a movieclip with a hitarea, simple tween and two buttons. But my buttons don't work any more???
How can I fix this???
Menus, Hitarea, Buttons, And The Like
Good Day,
I am a relative newbie to ActionScript (and forums of any sort for that matter). I am working to build an animated menu system with vertical slide down/up sub nav elements when the corresponding nav element is rolled over. I am able to get the menu to appear but I am running into trouble with the following items:the menu retracts on roll out with only the nav element or the appearing sub nav menu, not with both combined
buttons do not function on the sub nav menu likely because of conflict with hitarea
My goal is to provide a smooth drop down sub nav menu that is accessible and calls forth appropriate content in the main area. The menu should appear when the nav element is rolled over, remain visible when the mouse is over the nav and sub nav elements, and disappear on roll out of either the nav or sub nav elements. Additionally I hope to animate the sub nav elements with background shading as the mouse rolls over or clicks it.
I have includded the code currently employed below. Also attached is the menu.fla file for reference.
I would appreciate any and all insight on this. As ActionScript (and its syntax) are still fresh to me, I would appreciate any guidance and corrected script code if possible.
Thank-you for reading this far and for any time you could devote to help.
Best regards,
KD
================================
ACTIONSCRIPT
================================MENU ROLL OVER / OUT:
yTargetnavSrvDropMC = -100;
navSvrTopBack.onRollOver = function() {
// update state since menu needs to be open
yTargetnavSrvDropMC = 25;
moveFunc(navSrvDropMC,yTargetnavSrvDropMC);
navSvrTopBack.hitArea = hit;
};
navSrvDropMC.onRollOut = function() {
yTargetnavSrvDropMC = -100;
moveFunc(navSrvDropMC,yTargetnavSrvDropMC);
navSrvDropMC.hitArea = _root.navServices.navSrvDropMC.navSrvDropBack;
};
SUB NAV MENU APPEAR / DISSAPPEAR:
onClipEvent (enterFrame) {
ynavSrvDropMC = getProperty(_root.navServices.navSrvDropMC, _y);
movenavSrvDropMC = _root.navServices.yTargetnavSrvDropMC - ynavSrvDropMC;
setProperty(_root.navServices.navSrvDropMC, _y, ynavSrvDropMC + (movenavSrvDropMC/3));
}
================================
Movieclip With Hitarea And Buttons?
Why don't my buttons work???
I have created a movieclip with a hitarea, simple tween and two buttons. But my buttons don't work any more???
How can I fix this???
HitArea Not Working - Baffled
Dear Forum,
I'm trying to define a button hit area of "buttonHitArea1_mc" for button "buttonT1_mc". I've been staring at this code for hours trying to figure out why this isn't working, have searched and searched and everything I've found confirms that the syntax is correct. I've checked and double checked the instance names on the stage, case and spelling is correct, and I get no errors when running the swf.
The first two lines designate the hit area, the rest of the code is included in the event that it's relevant. When I run the code and drag my mouse over buttonHitArea1_mc it doesn't register. Just to make sure I was sane, I ran the code in the second example which worked fine (I added an array in case that was the issue). Any help would be wonderful.
Thanks,
James
Code:
stop();
buttonT1_mc.hitArea=buttonHitArea1_mc;
buttonHitArea1_mc.mouseEnabled=false;
/////// INITIATE SOUNDS AS INSTANCES
var homeSound:HomeSound = new HomeSound();
var abovtSound:AbovtSound = new AbovtSound();
var meeteSound:MeeteSound = new MeeteSound();
var calyndarSound:CalyndarSound = new CalyndarSound();
var gyveSound:GyveSound = new GyveSound();
var experiensSound:ExperiensSound = new ExperiensSound();
var interactSound:InteractSound = new InteractSound();
var callSound:CallSound = new CallSound();
/////// INTERFACE BUTTON ARRAYS
var buttonArray:Array = new Array (buttonT1_mc, buttonT2_mc,
buttonT3_mc, buttonT4_mc, buttonT5_mc, buttonT6_mc, buttonT7_mc);
var buttonSunArray:Array = new Array (buttonSunT1_mc, buttonSunT2_mc,
buttonSunT3_mc, buttonSunT4_mc, buttonSunT5_mc,
buttonSunT6_mc, buttonSunT7_mc);
var buttonSoundArray:Array = new Array (abovtSound, meeteSound,
calyndarSound, gyveSound, experiensSound, interactSound, callSound);
/////// MOVIECLIPS TO BUTTON MODE
for(var initialButtonStop:Number = 0; initialButtonStop < buttonArray.length; initialButtonStop++)
{
buttonArray[initialButtonStop].buttonMode = true;
}
/////// STOPPING INTERFACE BUTTON SUNS
for(var initialSunStop:Number = 0; initialSunStop < buttonSunArray.length; initialSunStop++)
{
buttonSunArray[initialSunStop].stop();
}
////// ADD EVENT LISTENERS
for(var initialButtonListen:Number = 0; initialButtonListen < buttonArray.length; initialButtonListen++)
{
buttonArray[initialButtonListen].addEventListener(MouseEvent.MOUSE_OVER, interfaceButtonSunRise);
buttonArray[initialButtonListen].addEventListener(MouseEvent.ROLL_OUT, interfaceButtonSunSet);
buttonArray[initialButtonListen].addEventListener(MouseEvent.CLICK, interfaceButtonCLICK);
}
/////// VARIABLE
var buttonObject:String;
/////// ICON NUMBER FUNCTION
function iconNumberFunction(e:MouseEvent):Number
{
buttonObject = e.target.name;
var pattern:RegExp = /d+/;
var varNumeralString:Array = pattern.exec(buttonObject);
var iconNumeral:Number = Number(varNumeralString);
return(iconNumeral);
}
////// FUCTION INTERFACE ROLL OVER BUTTON
function interfaceButtonSunRise(e:MouseEvent):void
{
var iconNumeral = iconNumberFunction(e);
buttonSoundArray[iconNumeral - 1].play();
buttonSunArray[iconNumeral - 1].play();
}
/////// FUNCTION INTERFACE ROLL OUT BUTTON
function interfaceButtonSunSet (e:MouseEvent):void
{
var iconNumeral = iconNumberFunction(e);
var particularSun:Object = buttonSunArray[iconNumeral - 1]
particularSun.stop();
var reverseTimer:Timer = new Timer(10);
reverseTimer.addEventListener(TimerEvent.TIMER, reversePlay);
reverseTimer.start();
/* ENTER_FRAME performs a function at the current frame rate -
it seems to not really listen, just perform*/
function reversePlay(event:Event):void
{
if(particularSun.currentFrame >1)
{
particularSun.prevFrame();
}
else
{
reverseTimer.stop();
/* If you don't remove the event listener it will continue to run */
}
}
}
/////// FUNCTION INTERFACE BUTTON CLICKS
function interfaceButtonCLICK(e:MouseEvent):void
{
var iconNumeral = iconNumberFunction(e);
switch (iconNumeral)
{
case 1:
gotoAndStop("niwes and calyndar");
break;
case 2:
gotoAndStop("meete the players");
break;
case 3:
gotoAndStop("experyense");
break;
case 4:
gotoAndStop("gyve");
break;
case 5:
gotoAndStop("the tavyrn");
break;
case 6:
gotoAndStop("abovt niwebyrth");
break;
case 7:
gotoAndStop("call on vs");
break;
default:
break;
}
}
This is that small test code:
Code:
stop();
square_mc.buttonMode = true;
square_mc.hitArea=circle_mc;
circle_mc.mouseEnabled=false;
var squareArray:Array = new Array (square_mc);
squareArray[0].addEventListener(MouseEvent.MOUSE_OVER, traceTest);
function traceTest(e:MouseEvent):void
{
trace("please work");
}
HitTest HitArea Intersecting Movieclips
I am working with FMX04 and have come to a deadend with my problem. I would like to drag a ball shaped movieclip around a maze or a house-floor-plan-like background. This maze/floor plan should be a movieclip and have walls. My ball movieclip should be dragable through the maze, but not be moveable through the walls. My ball movieclip should be setup to be dragable or just to follow the mouse movement, whatever works. I am finding that this is not so easy in Flash, with two simple intersecting objects it is easy, but not if one object must move through a second movieclip that is not a simple rectangle but something shaped like a maze. There must be an easy solution?
Here is my test page:
http://206.168.112.120/~firetracker/...ash/test4.html
|