ActionScript 2.0 :: Stop An OnEnterFrame Function?
Mar 6, 2005How can one stop an onEnterFrame function?
View 5 RepliesHow can one stop an onEnterFrame function?
View 5 RepliesonEnterFrame=null, onEnterFrame=undefined & delete onEnterFrame....
Which one to use??? What are the performance considerations. If all my movieclips on-stage are running a MovieClip.prototype.onEnterFrame = function() {run initial stuff before setting onEnterFrame=null/undefined... }, will there be performance hits? It's sad that delete onEnterFrame doesn't work unless I delete the prototype enterFrame as well, which would make the clips reinitailise itself again once you declare the enterFrame prototype again (i need to do this since there's more movieclips that end up appearing on-stage, and they need to automatically initialises themselves the moment they appear).
[Code]...
my prblem is my mc cant stop after hiting the mc hoe to stop ms after hitingI used this code to stop this Mc and its work Butthe mc hit only one time 2nd time its doesn't touch the mouse
if(this.hitTest(block)==true)
{
//this._x= this._x+60;
[code]....
I have a goofy issue going on with a drag/drop scroller. When i stop dragging the following onEnterFrame will not clear/stop unless you click on the movieclip again, then it clears.
Can one of you coder minded people see anything wrong with this? It works great, but i need it to clear as it's taking up that precious memory [code]...
I'm a newbie to the forum and AS3 and already searched through previous posts for the answer but couldn't find quite the right solution. I've got a simple animation, at the end of which I want to open a different URL. You can see my AS3 below (a mish mash of solutions I've found from all over). I've got it working such that the animation finishes playing and launches a browser window with the new URL, however it seems to be ignoring my "_self" statement and I can't stop the onEnterFrame from looping.
[Code]...
I'm programming a simple game for school, and now I get the following error: TypeError: Error #1009: Cannot access a property or method of a null object reference.at actionscript::EnemyFighter/onEnteringFrame()
I think this is because the object that calls this function does not exist anymore (it is removed from the stage). However, I did add an event listener for this and let it remove the ENTER_FRAME event listener. Therefore, this function should not be called anymore...
I tried to give the class a variable 'exists', then setting this to 'false' in the function that is called when the object is removed from stage. Also, this onEnteringFrame function first checks whether this 'exists' variable is true before executing any code... This also didn't solve my problem...
So in the end, it seems like the ENTER_FRAME is always called before the REMOVED_FROM_STAGE event. Is there anyway to turn this around?
[Code]...
I'm creating a complex site, with lots of calculations, while I have to keep it as light as possible. I don't want to have 50 .onEnterFrame's running simultaneously, so, how do I stop them? See example: Let's say I want a simple movement, invoked by some reason:
Code:
mcChild.onEnterFrame = function(){
if(mcChild._x < mcParent._width){
mcChild._x += 5;
}}
Now I want to stop the .onEnterFrame check, because it reached the if = false - How??
I have a movie clip on the main timeline with an instance name odometer_mc. nested in that mc there are seven movie clips, two are named m100_mc, and km1_mc. I want to get km1_mc to play when m100_mc gets to frame 20.
View 4 RepliesI used kirupas tutorial 'Complex Button RollOver/Rollout Effects' to make a menu that slides down when you roll over it. I have buttons inside that menu_mc - but they dont work.
My question is - does the on enter frame function prevent buttons from working?
Here is the code that is inside my menu_mc:
stop();
this.onEnterFrame = function(){
if(rewind == true){
prevFrame();
[Code].....
as2 this works but in as3 it no work how do you do this in as3
this.onEnterFrame = function() { if(Key.isDown(Key.UP)) { square._y -= speed; }
I need to get the width of mc and pass it to a global variable that i can use.
Heres the code sample.
ActionScript Code:
xCor = -3;// this value is actually in the xml so it depends whether its negative or positve
var dragitem:MovieClip = _root.createEmptyMovieClip("new_item"+dragItemTracker,
[Code]....
I'm not getting errors but my program wont call my function.
Code:
this.onEnterFrame = function() {
if(wm == 10)[code].....
I want to change to my end game screen when my value of variable wm gets to 10. Sorry I cant figure out whats wrong with the if statement. It doesnt work outside a function either.
i want to call a funtion once within a onEnterFrame, butthe problem is that the onEnterFrame needs to go on and execute the function only once...(if its between the desired x positions (see script below))
my code
Code:
onClipEvent(enterFrame)
{
if(this._x < -150 && this._x > -1600)
[Code].....
How can I make a function go on without an onEnterFrame?
View 3 RepliesGot a piece of code that moves a line of text I'm calling "eeScroller". I'm using this method because timeline and as tweens make the movement herky jerky (when the movement is slow).
What I want to do is reset the _x of eeScroller to 0.9 once it reaches the _x of -889.3
Here's what I got so far:
Code:
function movething() {
_root.eeScroller.onEnterFrame = function() {
if (_root.eeScroller._x>=-889.3) {
[Code].....
how to implement onMotionFinished if that's even the way to do it...
A function has to "run"(execute) inside the onEnterFrame event method but the function does not seem to run when called.
Example:
_root.onEnterFrame()=function(){
if(something==true){
performFunction();
[Code]....
cerbatana is the instance of my button.. I need that when I hold left key... the "moverizq" function starts.. so I create a new function.. where I have the condition for Key.is Down and then I call the function with onEnterFrame..
function moverizq() {
cerbatana._x = cerbatana._x-5;
}
function moverder() {
[Code]....
I need to use an onEnterFrame event to call a function just once. Here's the code:
my_object.onEnterFrame = function() {
if (this._y == 100) {
my_function();
}
};
So say i drag "my_object" to a y-coordinate of 100, how do i make it so it only calls the function once. Then if i drag the object away from y=100, and then back to y=100, i want it to call the function again.
I'm using the onEnterFrame event b/c i need it to constantly look for the object to be at y=100, maybe except when its actually at 100.
I've been trying to work this out.
Code:
function ghostGoUpDown(currentGhost) {
//do stuff
} benet.onEnterFrame = function() {
//do stuff
if(maze_mc.hitTest(this._x-16,this._y,true)) {
[Code].....
How can I change it so that the ghostGoUpDown is only run once each frame the hit test is true?
The function is called on release of a movieclip. I'm making a drag a drop navigation and there are two content windows .. "h1" and "h3".
I don't think there's anything(much) wrong with my code itself, I'm just having trouble with calling anything within h_ins.onEnterFrame. Is there a fundamental issue that I'm not aware of? Below are all the details if you're interested.
[Code]....
Just wondering what the effects are of putting a function on an onEnterFrame function.
when you call the function what will it do differently? if anything. And is it a bad thing? will it cause bugs?
In the main timeline I have this onEnterFrame function. I also have this movieclip and in it's own timeline stops at frame one. When this movieclip is rolled over it plays and then stops at frame 9. I'm trying to make an if statement in the onEnterFrame function that says when that one movieclip is on frame 9, delete the onEnterFrame function.
I tried to do this code, but so far all I have is
if (movieclip._currentlabel = "framenine") {
delete this.onEnterFrame;
}
Users are also given a set of thumbnails for extra feedback and navigation (here's what I currently have: As you can see, I have a button on my main stage named "portfolio". It has a simple "on (release)" function that goes to frame 2 (frame 2 is when my artwork portfolio displays).I have some code placed on frame 2, in a separate "actions" layer(very simple stuff):
stop();
onEnterFrame=function() {
_root.thumb_movie.gotoAndPlay("book");
[code]......
When assigning a function to onEnterFrame, for ex. onEnterFrame = someFunction, you do not include the brackets or the script will not run properly. my question is then, how can you assign a function to onEnterFrame while specifying parameters for that function? I tried onEnterFrame = someFunction(param1), but the function will only execute once.
View 3 Repliesi'm very new to Flash (although have plenty of experience in Java, C++, PHP, etc). For a University assignment, I am creating a World Cup Guide and i'm creating a countdown to the tournament. I've followed a tutorial and modified it slightly but i'm receiving an error message. The error message is:
[Code]....
I'm making a game, and it has an onEnterFrame which checks each players status (hp and turn), and decides what to do based on that. Looks like this:
Code:
_root.onEnterFrame = function(){
if(enemy.HP>0){
if(hero.HP>0){
if(hero.turn==0) {
[code]....
So this works fine when it's the players turn. But when it's the enemy's turn, the enemy simply attacks a bunch till hero.HP<0 and enemy wins. I am certain this is because it's checking each frame to see if it's the enemies turn and then it executes the hitting code before the turn is changed (which must mean this is freakin fast, so cool, but not good for me here!).I tried simply making a function to call at the end of the attack, with a function that happens only on first turn to let the player initiate, but when then the hero makes no attack, enemy attacks and there is a recursion error and it shuts down.
So, I'm a beginning to intermediate Flash and AS guy grappling with some programming concepts.I find that when I create my own functions from scratch, especially to define a generic function to different movie clips, in this case to their onEnterFrame functions, I get unexpected results.The bottom is some code from a new simple website I'm trying to code. My problem is that I can't get the function working in a generic way. I know I may be taking the completely wrong approach and totally missing something, but I am continuously coming up with problems (seems to be a misunderstading of scope at a deeper level, not simple variable timeline scope, but inherant scope within functions, etc..).So, I will just copy paste the code here and try and comment as much as possible. For claritie's sake I will remove button codes except option1 and option2.
//initialization of a few global and one timeline variable. These should
//be self explanatory in the code so I wont go into to much detail
//my probs arent in the detail but in the overall relationship of the
[code].....
If I need to assign the function fMy_Function to my_MC.onEnterFrame
Then it's fine to write :
myMC.onEnterFrame = fMy_Function;
but how to pass a parameter to fMy_Function ?
N.B. I don't want to use =function(){ fMy_Function(parameter1, parameter2); }
I'm trying to delay a function which then sets the onEnterFrame of a clip The colde I am trying will not work
[code]...
There is a function that I use all the time written in AS2 with buttons and rollovers to create a smooth animation in and out that doesn't relly on gotoAndPlay or gotoAndStop methods (as I have found them to be quite buggy. The AS2 code follows. I have started to write the same function in AS3, but keep getting errors when attempting to create a nested even listener for the onEnterFrame function that will drive the animation forward. How can I rewrite the AS2 function to work the same way in AS3.This is the AS2 Code
Code:
btnBox.onRollOver = function()
{
[code]....