PDA

View Full Version : Buttons Inside of MC not working


terraform
10-07-2008, 06:36 PM
sorry for the n00b question
I have wasted a day of google searches and tutorial searches trying to figure out what I am doing wrong.

this is what I need done

I want a Movie Clip to house 5 buttons that will link to frame labels on the main time line.
(this will be my main menu navigation)

I have created 5 separate buttons
then created a Movie Clip.
dragged each of the 5 buttons into the movie clip
gave instance names for all of them.
then I dragged the movie clip to my main timeline and gave that an instance name.

I then went into the Movie clip and attempted to use AS3 to get the button instances to navigate to the frame labels.

no go

when I test my movie it keeps looping through the whole main timeline no matter how many stop commands I put in the main timeline or in the Movie clip itself.

if I have no AS in the Movie clip then the movie tests with the Movie clip working (no
scrolling through the timeline and rollover works fine but I still can not command the CLICKs)

I am sure I am overlooking something simple
any suggestions would be greatly appreciated.

as a post script I have tried so many AS variables I thought it best to not enter any here
and see if someone could help me from scratch instead of fixing an already confused problem.

THX

rondog
10-07-2008, 07:48 PM
can you post your fla?

snickelfritz
10-07-2008, 10:46 PM
Similar question answered here:
http://www.actionscript.org/forums/showthread.php3?t=185268

terraform
10-09-2008, 09:14 AM
the fla

http://www.zshare.net/download/202606243e6301d6/


@ Mrwicked
I have posted a .fla here I have tried many incarnations of AS this happens to be my last attempt. (not necessarily the best or closest but the last)

@snickelfritz
thanks for the post on the other site and for the reference post on this one.

I believe I understand what you are getting at with these suggestions.
but when I attempt to make the buttons out of mc symbols instead of button symbols I keep running into a problem of how to make the mc react like button symbols I have created (ie up one sm symbol, over a pop out sub like menu, hit the entire sm symbol and pop out area all maintaining transparency)

I don't know if I explained that well. (you can check my .fla also it would make things more clear)

in the end I want a menu with transparency in the back (my background will be changing so I need the transparency in the back) and I would like it amendable so if I want to add another menu item in the future.
and I would like it to reside in one mc.

I am sure it is possible but as I have mentioned before .... pretty new at this.

thanks for your patience and help.

rondog
10-09-2008, 05:57 PM
The reason your movie keep looping no matter how many stops you put in is because you have an error in your AS. You have undefined names. Change:

s_btn.addEventListener(MouseEvent.CLICK, onSClick);
function onSclick(evt:MouseEvent):void
{
gotoAndStop("still");
}




m_btn.addEventListener(MouseEvent.CLICK, onMClick);
function onMclick(evt:MouseEvent):void
{
gotoAndStop("move");
}


to..

s_btn.addEventListener(MouseEvent.CLICK, onSClick);
function onSClick(evt:MouseEvent):void
{
gotoAndStop("still");
}




m_btn.addEventListener(MouseEvent.CLICK, onMClick);
function onMClick(evt:MouseEvent):void
{
gotoAndStop("move");
}


Its the capital 'C' that was messing up your code..

terraform
10-09-2008, 06:11 PM
thank you mrwicked for helping me to stop the looping.
that kind of stuff really drives me nuts. (still new to coding and have some fat fingers)

*however I still can not get the buttons to direct to the frame labels.

is it possible to nest buttons within a MC and have them behave correctly on the main
timeline?

I would gladly go with snickelfritz suggestion however I can not figure out how to make
a movie clip react the way I need the button to react. (ie invisible hit area, and transparency maintained, I am sure it is possible.... but again I am new to this.)

any thoughts or suggestions are again greatly appreciated.
thanks for everything so far

snickelfritz
10-09-2008, 09:49 PM
You don't actually need all of those discrete functions and listeners.
Name the movieclip container for the buttons "buttons".
Name your target frame labels with the same name as your buttons.
ie: button "btn1" goes to frame label "btn1" etc...

frame1 on the main timeline:
stop();

buttons.addEventListener(MouseEvent.CLICK, btnClick);
var btnName = "";
function btnClick(event:MouseEvent):void
{
btnName = event.target.name;
gotoAndPlay(btnName);
}

FLA is attached.

terraform
10-10-2008, 05:02 PM
that did the trick
thanks so much .
and I figured I was making things too complicated.
again thanks.

BolivianCat
12-25-2009, 02:35 PM
What if I want the buttons to navigate within the movieclip, and the buttons are in the same movieclip?

snickelfritz
12-25-2009, 03:09 PM
Don't do dat.