A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: help with easing

  1. #1
    Senior Member skdzines's Avatar
    Join Date
    Sep 2003
    Posts
    301

    help with easing

    Can anyone tell me how I can ease an object in/out with actionscript on an object that actually uses a tween animation on the timeline? I know I can set the easing in the properties but I don't want to do it that way. Basically I have a scale that measures the percentage of donations given. The scale moves to the right or left and at a slight angle upward/downward based off of the percentage calculated. It compares the current frame to the percentage and uses the nextframe/prevframe functions to move back/forward. There are 100 frames in the animation (1 frame per percent). I don't like the quick stop once it gets to the frame that equals the percent and would like it to ease in. I just don't know if I can do this with my current set up.

    Thanks in advance

    Below is the AS:

    PHP Code:
    /** set up xml object **/
    var my_xml = new XML();
    my_xml.load("http://localhost:2730/CampaignTicker/getDataService.asmx/getCampaignData");
    my_xml.ignoreWhite true;
    my_xml.onLoad = function(success){
        if (
    success){
            
    //trace(this);
            
    var rootNode this.firstChild.childNodes;
            var 
    goal rootNode[1].childNodes.toString();
            var 
    donations rootNode[0].childNodes.toString();
            
    _global.org_donations donations;
            
    init(goaldonations);
        }else{
            
    trace("error loading xml");
            
    testText.text "error loading xml";
        }
    }
    /** load intitial data **/
    function init(goaldonations){
        
        
    //trace("goal: " + goal);
        //trace("donations: " + donations);

        
    if(donations == ""){
            var 
    percentage 0;
        }else{
            var 
    percentage Math.floor(donations/goal*100);
        }
        
    //trace("percentage: " + percentage);
        
    if(percentage 100){
            
    percentage 100;    
        }else{
            
    percentage percentage;    
        }

        
    _root.onEnterFrame = function(){
            
            
    _root.goal_amount.Text Math.currencyFormat(goal);
            
            if(
    _root._currentframe <= percentage){
                
    _root.nextFrame();
                
    _root.magnifyingGlass.percentDisplay.Text = (_root._currentframe "%");
                
    //trace("Current frame: " +_root._currentframe);
                
    if(_root._currentframe == percentage || percentage == 1){
                    
    _root.raisedToDate.Text "Raised to date:";
                    
    _root.totalRaised.Text Math.currencyFormat(donations);
                }
                
            }else{
                if(
    percentage == 0){
                    
    _root.magnifyingGlass.percentDisplay.Text = ("0%");
                    
    _root.raisedToDate.Text "Raised to date:";
                    
    _root.totalRaised.TextMath.currencyFormat(donations);
                }
                
    delete this.onEnterFrame;
            }
        }
    }

    /** intialize reload interval **/
    setInterval(reload5000_global.donations);

    /** test for changed data **/
    function reload(org_donations){
        
        var 
    my_xml = new XML();
        
    my_xml.load("http://localhost:2730/CampaignTicker/getDataService.asmx/getCampaignData");
        
    my_xml.ignoreWhite true;
        
    my_xml.onLoad = function(success){
            if (
    success){
                
    //trace(this);
                
    var rootNode this.firstChild.childNodes;
                var 
    goal rootNode[1].childNodes.toString();
                var 
    new_donations rootNode[0].childNodes.toString();
                if(
    _global.org_donations != new_donations && new_donations != ""){
                    
    reloadDonations(goalnew_donations);
                }else if(
    new_donations == ""){
                    
    reloadDonations(goal0);
                }
            }else{
                
    trace("error loading xml");
                
    testText.text "error loading xml";
            }
        }
    }

    /** if data has change, reload it **/
    function reloadDonations(goalnew_donations){
        
    //trace("reloaded");
        
        
    if(new_donations == ""){
            var 
    new_percentage 0;
        }else{
            var 
    new_percentage Math.floor(new_donations/goal*100);
        }
        
        if(
    new_percentage 100){
            
    new_percentage 100;    
        }else{
            
    new_percentage new_percentage;    
        }
        
        
    //trace("percentage: " + new_percentage);
        //trace("new donations: " + new_donations);
        //trace("goal: " + goal);
        
        
        
    _root.onEnterFrame = function(){
            
            if((
    _root._currentframe <= new_percentage)  && (new_donations _global.org_donations)){
                
    _root.nextFrame();
                
    _root.magnifyingGlass.percentDisplay.Text = (_root._currentframe "%");
                
    //trace("Current frame: " +_root._currentframe);
                
    if(_root._currentframe == new_percentage || new_percentage == 1){
                    
    _root.raisedToDate.Text "Raised to date:";
                    
    _root.totalRaised.Text Math.currencyFormat(new_donations);
                }
            }else if((
    _root._currentframe >= new_percentage) && (new_donations _global.org_donations)){
                
    _root.prevFrame();
                
    _root.magnifyingGlass.percentDisplay.Text = (_root._currentframe "%");
                if(
    _root._currentframe == new_percentage || new_percentage == 1){
                    
    _root.raisedToDate.Text "Raised to date:";
                    
    _root.totalRaised.Text Math.currencyFormat(new_donations);
                }
            }else{
                
    /*if(new_percentage == 0){
                    _root.magnifyingGlass.percentDisplay.Text = ("0%");
                    _root.raisedToDate.Text = "Raised to date:";
                    _root.totalRaised.Text= Math.currencyFormat(_global.new_donations);
                }*/
                
    delete this.onEnterFrame;
                
    _global.org_donations new_donations;
            }
        }


  2. #2
    Senior Member
    Join Date
    Oct 2004
    Posts
    2,049
    you can use the "Tween Class" I have an example in my footer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center