Solved

Actionscript 2.0 animating with onEnterFrame

Posted on 2008-10-25
2
3,820 Views
Last Modified: 2013-11-11
The following function is called when a button is released:
function upThumbs(){
      dx  = 0
      lowerLeft = thumbnail_mc._y + thumbnail_mc._height
      trace("Lower Left " + lowerLeft);
      if (lowerLeft > 480){
            this.onEnterFrame = function(){
                  dx += 10;
                  if (dx < 480){
                        thumbnail_mc._y -= 10;
                  };
            }
            
      };
}

i wanted to make sure that the movieClip would animate and move up until the lower left corner reached above the 480.  If lowerLeft is less than 480, i don't want the "this.onEnterFrame" code to work.
But it still does!  After clicking the button once, the lowerLeft corner is 320.  The code should not run again.  I'm stumped by this.  I'm not sure why it's not working.

Any help would be appreciated!!!

0
Comment
Question by:steverguy
2 Comments
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 500 total points
ID: 22805906
try following update code, it should work for you:


function upThumbs() {

	this.onEnterFrame = function() {

		lowerLeft = thumbnail_mc._y+thumbnail_mc._height;

		trace("Lower Left "+lowerLeft);

		if (lowerLeft>480) {

			thumbnail_mc._y -= 10;

		} else {

			delete this.onEnterFrame;

		}

	};

}

Open in new window

0
 
LVL 1

Author Comment

by:steverguy
ID: 22805953
Thank you so much!  I am so rusty at ActionScript, i would've never thought of deleteing the onEnterFrame.

I appreciate your help!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Does Flash have a Firefox problem? 5 307
Action Script commands 4 303
free photo watermark software 5 65
Adobe Indesign CS6 4 78
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to record live broadcast.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now