PDA

View Full Version : Animated MC play button help


TeDD
01-12-2009, 12:13 PM
Okay so I'm new at AS and reading tutorials and stuff and now I've run into a problem and I'm clueless, any help would be greatly appreciated.

It's a preloader, I had it working fine when I used a normal button but now I want to make it a movie clip button with animated rollover/rollout states. Now it's not working so good, well not working at all.
It seems the stop actions are not functioning at all...

here's my code:
PS: Please remember I'm completely new at coding

stop();

playButton_mc.buttonMode = true;

playBtn.addEventListener(MouseEvent.ROLL_OVER, playBtnOver)
playBtn.addEventListener(MouseEvent.ROLL_OUT, playBtnOut)
playBtn.addEventListener(MouseEvent.CLICK, clickFunction);

function onplayBtnOver(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("over");

function onplayBtnOut(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("out");

function clickFunction(evt:MouseEvent):void {
gotoAndPlay(30);
}




Heres a picture of what I got dunno if it's going to help.

danjp
01-12-2009, 12:42 PM
Check your function names and also the name of your button

playButton_mc / playBtn

playBtnOver / onplayBtnOver

These don't match. The function name should match exactly the name you add with the listener.

playBtn.addEventListener(MouseEvent.ROLL_OVER, onplayBtnOver)

TeDD
01-12-2009, 12:49 PM
Okay so heres what I got now, I don't know if the buttons working or not because it's just looping, it's ignoring the stop actions :S

stop();

playBtn.buttonMode = true;

playBtn.addEventListener(MouseEvent.ROLL_OVER, playBtnOver)
playBtn.addEventListener(MouseEvent.ROLL_OUT, playBtnOut)
playBtn.addEventListener(MouseEvent.CLICK, clickFunction);

function playBtnOver(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("over");

function playBtnOut(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("out");

function clickFunction(evt:MouseEvent):void {
gotoAndPlay(30);
}

danjp
01-12-2009, 12:50 PM
post your FLA file and I'll have a quick look. Probably be faster this way

TeDD
01-12-2009, 12:58 PM
Okay here it is:

danjp
01-12-2009, 01:05 PM
stop();

playBtn.buttonMode = true;

playBtn.addEventListener(MouseEvent.ROLL_OVER, playBtnOver)
playBtn.addEventListener(MouseEvent.ROLL_OUT, playBtnOut)
playBtn.addEventListener(MouseEvent.CLICK, clickFunction);

function playBtnOver(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("over");
}
function playBtnOut(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("out");
}
function clickFunction(evt:MouseEvent):void
{
gotoAndPlay(30);
}


You should read the compiler errors message - it says you're missing 2 right braces.
I've just put these in and it works fine.

Cheers

TeDD
01-12-2009, 01:27 PM
Thats brilliant thanks man, this is great!
I really appreciate your help dude, Thanks

I've also found another way with using MCs inside a normal button heres the .fla if you wanna check it out

danjp
01-12-2009, 01:28 PM
no problem

good luck with the site

cheers