Log in

View Full Version : Script interferences



AnthonyGatto
11-14-2008, 03:02 PM
Can someone please tell me, why this script causes my movie to go haywire when I add something to the stage such as a scroller(even a UIScrollbar):

//--- Tutorial project file provided courtesy of SchoolofFlash.com ---//

aboutBmc.buttonMode = true;
resumeBmc.buttonMode = true;
pressBmc.buttonMode = true;
fansBmc.buttonMode = true;
contactBmc.buttonMode = true;
homeBmc.buttonMode = true;
aboutBmc.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
aboutBmc.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
resumeBmc.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
resumeBmc.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
pressBmc.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
pressBmc.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
fansBmc.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
fansBmc.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
contactBmc.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
contactBmc.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
homeBmc.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
homeBmc.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);


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

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


I am using this script on some buttons to give them a rollover/rollout effect. Like I mentioned, when I add a scrollbar to the stage and play the movie, the buttons keep looping the effect(ignoring all the the "stop" actions)and the scroll bar blinks erratically. Thanks for your help.

Anthony

P.S. I also am not sure how to give the buttons a directive such as getUrl since I am trying this movieclip as button idea. First time using AS3.

BLiZZaRD
11-15-2008, 12:37 AM
button_name.onRollover = function() {
this.gotoAndPlay("over");
}

button_name.onRollOut = function() {
this.gotoAndStop("out");
}

button_name.onRelease = function() {
getURL("http://sitename.com", "_self");
}



This will give the buttons their rollover and rollout effects as well as get the Url when pressed and released.

Shouldn't affect anything else you do on the stage.

If you need more, please define "haywire" or provide the .fla ;)

AnthonyGatto
11-15-2008, 02:41 PM
Thanks for your help, I'll give it a try today.

AG

Medyman
11-15-2008, 07:35 PM
button_name.onRollover = function() {
this.gotoAndPlay("over");
}

button_name.onRollOut = function() {
this.gotoAndStop("out");
}

button_name.onRelease = function() {
getURL("http://sitename.com", "_self");
}



This will give the buttons their rollover and rollout effects as well as get the Url when pressed and released.

Shouldn't affect anything else you do on the stage.

If you need more, please define "haywire" or provide the .fla ;)

@Blizz...
Once again, you're very right ...for AS2. The OP is using AS3.

@Anthony...
As Blizzard says, please define "haywire". Are you getting any errors? If possible, zip up your fla and post it here.

BLiZZaRD
11-15-2008, 07:47 PM
@Blizz...
Once again, you're very right ...for AS2. The OP is using AS3.


Yes, and once again proving AS2 RULZ!!! N00b! :p (feeling 3rd grader-ish today, don't mind me)

Also should have CS4MC when I get home! Can't wait to check mail! WOOT! :rolleyes:

Medyman
11-17-2008, 01:51 PM
Also should have CS4MC when I get home! Can't wait to check mail! WOOT!

Are you thinking about switching to AS3?

BLiZZaRD
11-18-2008, 01:34 PM
Switching? BAH! You frighten me! No, but I still have Flash 4 and 5 Installed on my machine, so might as well have 7, 8, 9 and 10 too!