Solved

Actionscript 2.0 animating with onEnterFrame

Posted on 2008-10-25
2
3,867 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

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…
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,…
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.

623 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