Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 682873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:38:41+00:00 2026-05-14T01:38:41+00:00

How do I reset my numbers after they count? I want something like an

  • 0

How do I reset my numbers after they count? I want something like an onComplete function.

DESCRIPTION
My animation advances 120 pixels from it’s current position, then flys off the stage.
It was looping, and would yoyo to the bottom before advancing. I don’t want my numbers
yoyoing or flying off the stage. My numbers must move 120 pixels forward each count, then
return.

alt text http://www.ashcraftband.com/myspace/videodnd/tweener___.jpg

NumbersView.as ‘the code works, but in a messed up way as described’

package   
{ 
    import flash.display.DisplayObject; 
    import flash.display.MovieClip; 
    import flash.utils.Dictionary; 
    import flash.events.Event; 
    import caurina.transitions.Tweener; 

    public class NumbersView extends MovieClip 
    { 
        private var _listItems:Array; 
        private var previousNums:Array; 
        private const numHeight:int = 120; 

        public function NumbersView()  
        { 
            _listItems = new Array(); 
            previousNums = new Array(); 
   //Tweener.init();

            var item:NumberImage; 
            for (var i:Number = 0; i < 9; i++) { 
                item = new NumberImage(); 
                addChild(item); 
                item.x = i * item.width; 
                _listItems.push(item); 
            } 
        } 

        public function setTime($number:String):void { 
            var nums:Array = $number.split(""); 
            //trace("$number = " + $number);
            for (var i:Number = 0; i < nums.length; i++) { 
                if (nums[i] == previousNums[i]) continue; 
                Tweener.removeTweens(_listItems[i]);    

                //newY:int = -numHeight;
    var newY:int = int(nums[i]) * -numHeight;
    trace("newY = " + newY);
                trace("currY = " + _listItems[i].y);

    /*----------------------PROBLEM AREA, RIGHT HERE------------------------*/
                //if (_listItems[i].y < 0) _listItems[i].y = numHeight;//
                //Tweener.addTween(_listItems[i], { y:newY, time:3 } );//
    Tweener.addTween(_listItems[i], { y:_listItems[i].y+newY, time:3 } );//
            } 
            previousNums = nums; 
        } 
    } 
} 

Tweener Example
http://hosted.zeh.com.br/tweener/docs/en-us/parameters/onComplete.html

**oopse!
//crap code was’ s note not to use it’, not a comment against anyone’s code


DOCUMENT CLASS
Publish Settings/Flash/Settings ‘Advanced ActionScript 3.0 Settings’/Document class:NumbersView

CLASS Symbol 70×1080, numbers 70×120
Library/’right-click’ Properties/Class:NumberImage

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:38:42+00:00Added an answer on May 14, 2026 at 1:38 am

    It took me a little while to figure out what you’re really trying to get as an end result, but I think I figured it out. I split this functionality into 2 classes. The NumbersView class is still the document class, but I also made a NumberImage class that you can attach to your 0-9 numbers movieclip in your library. Here’s the code:

    //NumbersView.as - Your Document Class
    package {
    
        import flash.display.MovieClip;
    
        public class NumbersView extends MovieClip {
    
            private var _listItems:Array; 
            private const numHeight:int = 120; 
    
            public function NumbersView()  
            { 
                _listItems = new Array();
    
                var item:NumberImage; 
                for (var i:Number = 0; i < 9; i++) { 
                    item = new NumberImage(); 
                    addChild(item); 
                    item.x = i * item.width; 
                    _listItems.push(item); 
                }
    
                setTime('123456789');
    
            }
    
            public function setTime($number:String):void { 
                var nums:Array = $number.split(""); 
                trace(nums);
    
                for (var i:Number = 0; i < nums.length; i++) { 
    
                    _listItems[i].start( int(nums[i]) );
    
                } 
    
            } 
    
    
        }
    }
    

    The next class is the NumberImage.as class that you can hook up to your movieclip by right-clicking the item in the library, “Properties…”, Check “Export for ActionScript”, and put in NumberImage for the Class name.

    //NumberImage.as - Linked to the NumberImage movieclip in the Library    
    package {
    
        import flash.display.MovieClip;
        import caurina.transitions.Tweener;
    
        public class NumberImage extends MovieClip {
    
            public var count:int;
    
            public function NumberImage() {
                count = 0;
            }
    
            public function start( num:int = 0 ):void {
                this.y = -120*num;
                count = num;
                moveNumbers();
            }
    
            public function moveNumbers():void {
                count++;
                if(count % 10 == 0) {
                    Tweener.addTween( this, {y: this.y + 1080, time:1, onComplete:moveNumbers});
                } else {
                    Tweener.addTween( this, {y: this.y - 120, time:1, onComplete:moveNumbers});
                }
            }
    
        }
    }
    

    Hopefully this makes more sense and it’s easier to decipher now that the functionality of the NumberImage objects are handled by themselves rather than by their containing class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using YUI reset/base, after the reset it sets the ul and li
I would like to completely reset the scroll position of a UITableView, so that
How do I go about implementing a secure password reset function without sending the
I'd like something like this: each[i_, {1,2,3}, Print[i] ] Or, more generally, to destructure
I want to generate unique and random numbers or IDs which I can use
Is it possible to reset the alternate buffer in a vim session to what
I can reset FPU's CTRL registers with this: http://support.microsoft.com/kb/326219 But how can I save
How would I reset the primary key counter on a sql table and update
This line in YUI's Reset CSS is causing trouble for me: address,caption,cite,code,dfn,em,strong,th,var { font-style:
Is there a way clear or reset the outputcache for an entire website without

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.