all groups > flash actionscript > july 2007 >
You're in the

flash actionscript

group:

Buttons inside draggable content


Buttons inside draggable content lukeduke7
7/11/2007 10:01:25 PM
flash actionscript:
I have a button that when clicked makes a movie visible. That movie is
draggable. I have a button inside that movie that I want to close or "hide" the
movie. For some reason it doesn't seem to recognize the button in the movie, it
seems to recognize everything as the draggable content. My question is, how can
I get buttons to work inside draggable content?

I was told to try hitTest() but don't know much about it. After hours of
reading about it I couldn't get a grasp of how it would help my situtation.
Most of the tutorials and information was directed toward situtions involving
boundries or collision movements of objects.

Question: How can I get buttons inside a movie that is draggable to work and
be recognized as buttons? Is hitTest the answer and if so, is there an example
of how to use it in my situation?

Below is what I have for code so far. I have also provided a link of what I am
trying to achieve.

LINK: (click skip to skip video)
http://www.hp.com/personalagain/us/en/shaun_white.html

Thanks in advance for any ideas or information! It will be greatly appreciated!
Luke

//DOUBLE CLICK TO SHOW CONTENT
//set initial variables
click = false;
//function for the button press
button_btn.onPress = function() {
//if this is the first click
if (!click) {
timer = getTimer()/1000;
_root.click = true;
}
else {
timer2 = getTimer()/1000;
//if it is a double click
if ((timer2-timer)<.25) {
//toggle the box mc on and off
if (_root.box_mc._visible==false) {
_root.box_mc._visible = true;
} else {
_root.box_mc._visible = false;
}
} else {
timer = getTimer()/1000;
_root.click = true;
}
}
};

//DRAGGING CONTENT
//border variables
left = 0;
top = 0;
right = Stage.width;
bottom = Stage.height;
//drag the mask
_root.box_mc.onPress = function() {
startDrag(this);
}
_root.box_mc.onRelease = function() {
stopDrag();
}
stop();
Re: Buttons inside draggable content Rob Dillon
7/12/2007 12:00:00 AM
Instead of making the clip itself draggable, create an invisible button
the same size as the clip to be dragged and place it in a layer below
the close button.

Now you have a draggable clip that will drag from any point except the
Re: Buttons inside draggable content SymTsb
7/12/2007 12:07:39 AM
This is an issue of nested buttons. As long as you have a movie clip with an
event handler attached to the entire mc, you won't be able to access the
actions underneath it. You can do hit tests to check when the mouse is over
the button but that gets difficult when the content containing the button is
draggable and as such will follow the mouse around the screen.
AddThis Social Bookmark Button