A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Drag problems

  1. #1
    Junior Member
    Join Date
    Apr 2006
    Posts
    2

    Drag problems

    Hi
    I'm new to this forum, but i really need some help with something coz I'm new to Flash as well ... I'm working on Flash-mysql based chess game, and i have some problems with draging some of my chess pieces. When i drag a piece to where some other piece is allready placed, a problem occures. The piece which i've been wanting to move, keeps moving along with my mouse cursor although my mouse button isn't clicked!! same thing happends when i leave a piece on the border of the swf movie. this is really annoying
    here's the actionscript attached to the white pawn:
    code:

    on(press)
    {
    x_0 = getProperty(this, _x);
    y_0 = getProperty(this, _y);
    x_field_0 = Math.round(x_0/50);
    y_field_0 = Math.round(y_0/50);
    this.startDrag();
    }
    on(release)
    {
    this.stopDrag();
    x = getProperty(this, _x);
    y = getProperty(this, _y);
    x_field = Math.round(x/50);
    y_field = Math.round(y/50);
    //movement
    movement_x = x_polje - x_polje_0;
    movement_y = y_polje - y_polje_0;
    //permission
    if (movement_x == 0 && movement_y == -1 && y_field_0 > 0 )
    {
    permission_pawn_white = 1;
    }
    else if (movement_x == 0 && movement_y == -2 && y_field_0 == 6 )
    {
    permission_pawn_white = 1;
    }
    else
    {
    permission_pawn_white = 0;
    }
    if ( x_field >= 0 && y_field >= 0 && x_field <= 7 && y_field <= 7 && permission_pawn_white == 1)
    {
    //this part of the code is used to center the pieces in the center of a field
    this._x = x_field*50;
    this._y = y_field*50;
    }
    else
    {
    this._x = x_0;
    this._y = y_0;
    }
    }


    another thing i don't get is that the first problem i was talking about doesent show up with every piece.
    for example, black pawns can easily be placed over any white piece which isn't the case with white pawns, although the code is basicly the same! there are just some differences like movement_y = 1 instead of -1...
    I've lost my nervs with this one
    please, help

  2. #2
    Junior Member
    Join Date
    Apr 2006
    Posts
    2
    no answers

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