PDA

View Full Version : Please Help!!!



s0undsystem
June 23rd, 2008, 02:04 PM
hey guys.

Please help me; I cannot figure out how to do this in Actionscript 3.0:

Using movie clip buttons, how do you get the button to stay in the "mouse over" state after it has been clicked? I do not want the button to do anything at all after it is clicked.

I found this online and it works perfectly for actionscript 2.0 but i need it in 3.0. anyone know how to do this in 3.0?



MovieClip.prototype.checkMe = function() {
if (this._currentframe == 2) {
this.btn.enabled = true;
this.gotoAndStop(1);
}
};
btn_mc1.btn.onRelease = function() {
btn_mc1.btn.enabled = false;
btn_mc2.checkMe();
btn_mc3.checkMe();
};
btn_mc2.btn.onRelease = function() {
btn_mc2.btn.enabled = false;
btn_mc1.checkMe();
btn_mc3.checkMe();
};
btn_mc3.btn.onRelease = function() {
btn_mc3.btn.enabled = false;
btn_mc2.checkMe();
btn_mc1.checkMe();
};

Please help and THANK YOU

nikefido
June 23rd, 2008, 02:44 PM
this is not AS3

s0undsystem
June 23rd, 2008, 02:50 PM
i know the code is not in AS3. I need to know how to do this in AS3. this code does what i want in AS2 but i want it in AS3 and i cannot figure out how to do it.

thanks for the comment.

redline024
June 23rd, 2008, 03:17 PM
if (this._currentframe == 2) {

take the _ off current frame, thats the as2 way of doing, as3 doesnt use underscores like that:

if (this.currentframe == 2) {

nikefido
June 23rd, 2008, 03:24 PM
there are a few things to know.
Once you have a button or movieclip acting as a button, you need to make it "listen" for a mouse click on it (or any mouse event, such as roll over, roll out, etc).


so, for example:
ActionScript Code:

btn.addEventListener(MouseEvent.CLICK, onClick);

function onClick(e:MouseEvent):void {
//do something - i'm not sure if "enabled" and "disabled" is part of as3 any longer
trace(e.target); //traces the btn clicked - you can access it's properties/mthods via e.target
}

redline024
June 23rd, 2008, 03:26 PM
sorry, didnt really read it all. I don't know what all you need to know, but first you need to add event listeners:

instanceNameOfButton.addEventListener(MouseEvent.C LICK, nameOfFunction);

Then write your button click function like this:

function nameOfFunction(e:MouseEvent):void {
//disable the button
instanceNameOfButton.enabled = false;
//then put whatever else you want to happen when the button is clicked
}