SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Move a mc and back.

    Hi.
    I managed this simple code:
    PHP Code:
    var SPEED:Number 5;
    var 
    center:Number=  Stage.width/2;
    var  
    rightLimit:Number Stage.width-ball_mc._width/2;
    ball_mc._xcenter;
    ball_mc.onEnterFrame = function(){
        
    this._x += SPEED;
        if (
    this._x>rightLimit) {
                
    this._x rightLimit;
        }

    now I'm wondering how can I move smoothly
    the ball_mc to the start point and so on .........


    Bye.

  2. #2
    SitePoint Guru [Paul Ferrie]'s Avatar
    Join Date
    Oct 2007
    Location
    Glasgow, Scotland, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should check out the greensock tween class.

    Hope it helps
    .:To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Glasgow Flasher
    bringmadeleinehome.com

  3. #3
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by [Paul Ferrie] View Post
    You should check out the greensock tween class.

    Hope it helps
    Thanks for the link but I'm just looking for
    simple code to understand the logic behind it.

  4. #4
    SitePoint Guru [Paul Ferrie]'s Avatar
    Join Date
    Oct 2007
    Location
    Glasgow, Scotland, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    .:To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Glasgow Flasher
    bringmadeleinehome.com

  5. #5
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by [Paul Ferrie] View Post
    Thanks for the link again interesting stuff really
    But at the moment (I'm taking my first steps in AS)
    I like finding my way :

    This is my not very smart way (but it works)

    PHP Code:
    var mySwitch:Boolean false;
    var 
    SPEED:Number 5;
    var 
    center:Number Stage.width/2;
    var 
    rightLimit:Number Stage.width-ball_mc._width/2;
    ball_mc._x center;
    ball_mc.onEnterFrame = function() {
        if (
    this._x>rightLimit) {
            
    mySwitch true;
            
    this._x rightLimit;
        }
        if (
    this._x<center) {
            
    mySwitch false;
            
    this._x center;
        }
        if (
    mySwitch) {
            
    this._x -= SPEED;
        } else {
            
    this._x += SPEED;
        }
    }; 
    Bye.


Bookmarks

Posting Permissions

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