dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: moving ball

  1. #1
    Senior Member
    Join Date
    Mar 2003
    Posts
    141

    moving ball

    I am trying to get a ball to move up and done by using this script"

    var endY = 100;
    var stepY = 10;

    Ball.onEnterFrame = function() {
    //If less than 100
    if (this._y<=endY) {
    //add 10
    this._y = this._y + stepY;
    if (this._y=endY) {
    stepY = -10;
    }
    }
    };

    I am new to this form of actionscript and I don't understand what is wrong with it?

    Can anyone help?

    Jay

  2. #2
    Senior Member olias32's Avatar
    Join Date
    Jan 2003
    Location
    Romania
    Posts
    126
    the sign "=" (equals) means assignement (x=2 means x takes the value 2)

    if using with the if statemet, in order to compare, you must use "==" double equal (otherwise, even in the if statement, its assignement)

    so your code need just one change

    Code:
    if (this._y == endY) {

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