Stick Page Forums Archive

actionscript

Started by: sticky505 | Replies: 12 | Views: 1,242 | Closed

sticky505

Posts: 34
Joined: Sep 2008
Rep: 10

View Profile
Feb 1, 2009 5:24 PM #350074
Is there any way of deleting an actionscript on the frame or on a movieclip.

eg: if i have

onEnterFrame = function () {
}

Is there a way to delete the above?

Thanks..
Chunky
Banned

Posts: 4,311
Joined: May 2007
Rep: 10

View Profile
Feb 1, 2009 5:26 PM #350076
backspace ?
Kieran.
2

Posts: 3,358
Joined: Jan 2009
Rep: 10

View Profile
Feb 1, 2009 5:42 PM #350085
well you highlight it by dragging your mouse over it very slowly until all the text is highlighted in a black colour...... you then carefully, take your hand off the mouse, and whilst being careful to not press any other keys, you put you finger on the delete this button (here) and slowly... and gently press it down until it touches the back of your keyboard...

The text should have magically disappeared and you think

*HoW DID I DO THAT?*
Lixu

Posts: 3,859
Joined: Aug 2007
Rep: 10

View Profile
Feb 1, 2009 6:27 PM #350114
Quote from extremekd
well you highlight it by dragging your mouse over it very slowly until all the text is highlighted in a black colour...... you then carefully, take your hand off the mouse, and whilst being careful to not press any other keys, you put you finger on the delete this button (here) and slowly... and gently press it down until it touches the back of your keyboard...

The text should have magically disappeared and you think

*HoW DID I DO THAT?*

You sir, are a genious!
MoD
Banned

Posts: 4,492
Joined: May 2008
Rep: 10

View Profile
Feb 1, 2009 6:30 PM #350116
Backspace


Did he really? Holy shit Scarecrow.
Lixu

Posts: 3,859
Joined: Aug 2007
Rep: 10

View Profile
Feb 1, 2009 6:38 PM #350125
Quote from MoD
Delete windows system 32.

It WILL delete it. And various other vital things.

You know Scarecrow got banned for saying that?
darkcampainger
2

Posts: 159
Joined: Aug 2006
Rep: 10

View Profile
Feb 1, 2009 7:06 PM #350147
Setting it to null:
onEnterFrame = null;

Should remove it.
Kieran.
2

Posts: 3,358
Joined: Jan 2009
Rep: 10

View Profile
Feb 1, 2009 10:00 PM #350256
Quote from Lixu
You sir, are a genious!


why thank you... I have a PHD in that topic.....
Flood
2

Posts: 3,326
Joined: Dec 2008
Rep: 10

View Profile
Feb 1, 2009 10:03 PM #350260
Quote from darkcampainger
Setting it to null:
onEnterFrame = null;

Should remove it.


You should make a thread for asking you AS questions.

Seriously.
Scarecrow
2

Posts: 9,168
Joined: Oct 2005
Rep: 10

View Profile
Feb 6, 2009 8:44 AM #352921
Quote from Lixu
You know Scarecrow got banned for saying that?


true story


this is why I was so pissed off
sticky505

Posts: 34
Joined: Sep 2008
Rep: 10

View Profile
Feb 12, 2009 10:56 PM #356343
Quote from darkcampainger
Setting it to null:
onEnterFrame = null;

Should remove it.


so does this work on any type of actions or only on handlers..would it work on buttons and movieclips?..
eg
on (keyPress "") {
};

And..
onClipEvent (*anything*) {
};


if so, where would I put the script *onEnterFrame = null;*...and if it is a button would it be on keyPress "" = null;?
would it work for buttons and/or movieclips?
please show me an example of you using *onEnterFrame = null;* so I understand a little more.
thanks.
darkcampainger
2

Posts: 159
Joined: Aug 2006
Rep: 10

View Profile
Feb 13, 2009 11:34 PM #356858
You can only use it to remove anonymous functions. Such as these:
FunctionName = function():String {return "lawl";}
onEnterFrame = function() {}
onMouseDown = function() {}


Anonymous functions are unnamed, and referenced with variables instead. The variable "FunctionName" above is a reference to the unnamed function that returns "lawl":

FunctionName = function():String {return "lawl";}
The red section is the variable referencing the function. The blue is the anonymous function itself.

Since the function is unnamed, it cannot be accessed without a variable pointing to it. Because of this, simply changing the variable's value will make the function inaccessible. In the case of using anonymous functions with event handlers, this means they'll stop being triggered by the event.

In contrast, a named function can stand alone, but is not as easily overridden:
function functionName(parameters) {
// function block
}


The "on()" and "onClipEvent()" event handlers act like named functions, and cannot be overridden (afaik).


Here's an example of defining, and then removing anonymous event handlers:
//Code on Main Timeline, Frame 1
var runs:Number = 0;
var clicks:Number = 0;
onEnterFrame = function() {
trace("onEnterFrame is running! It has run "+(++runs)+" time(s)!");
if(runs>=20) {onEnterFrame = null;}
}

//The above function runs 20 times, and then is removed.

onMouseDown = function() {
trace("You clicked! You have clicked "+(++clicks)+"/10 time(s)!");
if(clicks>=10) {onMouseDown = null;}
}

//The above function is run for 10 clicks, and then is removed


However, that isn't to say you can't accomplish something similar with the other handlers:

var limit:Number = 10;
on (keyPress "") {
if(limit>0) {
limit--;
trace("You hit space! You can do it "+limit+" more time(s)!");
}
else {trace("You hit space! But... it won't do anything.");}
};
sticky505

Posts: 34
Joined: Sep 2008
Rep: 10

View Profile
Feb 14, 2009 11:43 PM #357545
thanks darkcampainger
Website Version: 1.0.4
© 2025 Max Games. All rights reserved.