A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: swapping array elements

Threaded View

  1. #1
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244

    swapping array elements

    Decided not to continue this in the bitmap thread.....Still working occasionally on the video poker thing . Decided that having another array for the hand complicated some things and wasn't the way to go.....

    I have a shuffled array of 52 movie clips each with a card graphic on it, a suit value and a value. I'm going to treat the first 5 cards as always being the "hand" so what I'm now trying to do is make a swap function but I'm not doing something right and cannot seem to make it work.....
    code:

    swap=function(i,j){

    i=j
    j=temp
    }
    //swap(test[0],test[1])
    test=new Array(1,2,3,4)
    txt1.text=test[0]
    txt2.text=test[1]



    didn't work nor did
    code:

    Array.prototype.swap=function(i,j){
    var temp=this[i]
    this[i]=this[j]
    this[j]=temp
    }
    deck.swap(x,cardsDrawn)

    Last edited by blanius; 12-13-2006 at 12:30 AM.

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