PDA

View Full Version : AS3 equivilant of Button.prototype.onRollOver


gburks
08-11-2006, 04:31 AM
In AS2, you could write functions that fired everytime any button had certain events like onRollOver occur by using its prototype:
Button.prototype.onRollOver = function() {
// some code here
}

In AS3, there is no onRollOver funtion. I played around with adding event listeners to the SimpleButton prototype, but could not successfully recreate this functionality.

Any way to do this in ActionScript 3.0?

Tink
08-11-2006, 10:02 AM
package tink.display
{

import flash.events.MouseEvent;
import flash.display.SimpleButton;

public class TinkSimpleButton
{

public function TinkSimpleButton()
{
super();

initialize();
}

private function initialize():void
{
addEventListener( MouseEvent.MOUSE_OVER, onMouseOver )
}

private function onMouseOver( event:MouseEvent ):void
{
// some code here
}

}

}

senocular
08-11-2006, 03:04 PM
There is no way to recreate Button.prototype.onRollOver in AS3. You would instead just have to do what Tink has as an example and use those instances in place of any actual button instances you use thereby allowing every one of those instances to have your over handler implemented

gburks
08-17-2006, 09:49 PM
Is there any way, using the Flash 9 IDE, to tell buttons that are on the stage that they should be this custom button class rather than just a SimpleButton?

senocular
08-17-2006, 09:50 PM
You would have to associate them with classes from within the library

stavrianos13
07-31-2008, 12:14 PM
Hello everyone
I am in trouble,please help me

From a tutorial i saw:

on(rollOver){
contactMenu.play();
}

This code is in AS2
I use AS3 and i received the error message.
"1087: Syntax error: extra characters found after end of program."It doesnt work in AS3!!!


What i must change in AS3?
I am going to create a drop down menu..Can anyone help me please?

Thank you