Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Actionscript 2.0 animating with onEnterFrame

Posted on 2008-10-25
2
Medium Priority
?
3,896 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

824 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