Hey.
Im brand new to AS3.0 and giving the whole classes thing a go…
Trying to detect when a button is being pressed using this class, this is giving me an error.
The problem is im not sure how to reach the button from within the class…
[AS]
// on main timeline
var buttons:buttonEvents = new buttonEvents();
// in the class
package{
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.Sprite;
public class buttonEvents extends Sprite{
But_login.addEventListener(MouseEvent.CLICK, attemptToLogin);
}
function attemptToLogin(event:MouseEvent):void {
trace(“button clicked”);
}
}
[/AS]
this results in
1120: Access of undefined property But_login.
Which im pretty sure of is because the button ‘But_login’ only exists on the main timeline and not in my class… so how do i reach it?
Thanks!
P.S. it is called ‘But_login’ on the main timeline, i am very sure.