A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Random Movieclip?

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    6

    Exclamation Random Movieclip?

    As I can show on flash movieclip Ramdon?
    I have 50 movie clip each have a value defined for me.
    I want to show flash movieclip 12, but not repeated.
    An example would be a game of cards each card is unique and can not be repeated.

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    It would be nice if you put some files for to see that you can actually do something other than demanding answers to questions that you have made no effort towards.

    Similar to the last question I answered for you, only this time you might need to make an array of the cards and then swap the value of this for its proper card to display it as a picture card!!!.
    PHP Code:
    var clipArray:Array = new Array();

    for (var 
    i:int 050i++)
    {
        var 
    movieClip:Object = {value:Number(1)};
        
    clipArray.push(movieClip);
    }

    function 
    getCards(arr:Array,k:int):void
    {
        var 
    randNum:int;
        var 
    theTemp:Array = arr.concat();
        var 
    theHand:Array = new Array();

        for (var 
    j:int 0kj++)
        {
            if (
    theTemp.length == 0)
            {
                break;
            }
            
    randNum Math.floor(theTemp.length Math.random());
            
    theHand.push(theTemp.splice(randNum,1)[0]);
            
    // *** Below optional, for sorting high to low
            //theHand.sortOn(['value'], [Array.DESCENDING | Array.NUMERIC]);
        
    }
        for (var 
    s:int 0theHand.lengths++)
        {
            var 
    t:Number 1;
            
    trace("Card: " " - " theHand[s].value);
        }
    }

    getCards(clipArray,12); 
    example, convert the value of the outcome against its associative card array

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