Solved

Actionscript 2.0 animating with onEnterFrame

Posted on 2008-10-25
2
3,862 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
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…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

734 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