A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Need help with cylinder animation [AS2]

  1. #1
    Senior Member
    Join Date
    Jan 2001
    Location
    Barcelona
    Posts
    129

    Cow Icon Need help with cylinder animation [AS2]

    Hello,

    I tried with AS2 to animate the movement of a cylinder going non stop up and down and with possibility to change speed. I managed the sliding down and the acceleration of the cylinder but it does not recognize the limit where it has to stop and make the movement backwards to starting position.

    Please help me out, I'm not very expert in programing and I'm not able to recognize what the problem is.

    Here the code applied directly to the MC:
    Code:
    onClipEvent (load) {
    	// Initial position
    	this._y = 50;
    	// Starting Speed
    	var _velocidad = 10;
    	// Acceleration
    	var _accelera = 5;
    
    }
    onClipEvent (enterFrame) {
    	// Speedup
    	this._velocidad = Math.round((this._velocidad+this._accelera)*100)/100;
    	if (this._y>=50) {
    		this._y += this._velocidad;
    	} else if (this._y<=500) {
    		this._y -= this._velocidad;
    	}
    }
    Thanks

  2. #2
    shavingcream incarnate gukinator's Avatar
    Join Date
    Jul 2008
    Location
    Santa Cruz
    Posts
    147
    try this
    PHP Code:
    velocity 5;
    acceleration 1;
    direction 1;
    Constant velocity;
    onEnterFrame = function(){
        
    velocity+=acceleration;
        if(
    direction == 1cylander._y-=velocity;
        if(
    direction == 2cylander._y+=velocity;
        if(
    cylander._y<=0){
            
    direction 2;
            
    velocity Constant;
        }
        if(
    cylander._y>=300){
            
    direction 1;
            
    velocity Constant;
        }

    this code is for the frame and i gave your cylander an instance name of "cylander"
    tell me if you want me to change it to movie clip script

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