Welcome to Dream.In.Code
Getting Help is Easy!

Join 109,524 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,143 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



script for randomization

 
Reply to this topicStart new topic

script for randomization

ruqsanakhan
post 28 May, 2008 - 04:44 AM
Post #1


New D.I.C Head

*
Joined: 28 May, 2008
Posts: 4

I am designing a game in flash named to find the odd man out...
i need a help in the scriptig part...
i have 4 movieclips which contains 4 different objects
when ever i refresh the page among the 4 movieclips a movie clip should be selected randomly
and the objects in that movie clip should also be selected randomly

suppose i have a movieclips named as fruits, animals etc
and the movieclip fruits contains 4 different objects viz apple, mango, banana, icecream
i want that when ever the page gets refreshed any of the two moviclips one should be selected randomly and the objects inside it should also be selected randomly..........

anyone please help me withthis comcept
User is offlineProfile CardPM

Go to the top of the page


red01
post 4 Jun, 2008 - 02:32 PM
Post #2


D.I.C Head

Group Icon
Joined: 8 May, 2006
Posts: 173



Dream Kudos: 25
My Contributions


do you have some code.....

also are you using AS2 or AS3
User is offlineProfile CardPM

Go to the top of the page

ruqsanakhan
post 4 Jun, 2008 - 09:44 PM
Post #3


New D.I.C Head

*
Joined: 28 May, 2008
Posts: 4

well im using the as2 for my scripting purpose

yes i have got some code.. butits not working...
CODE
// NON REPAETING OF RANDOM NUMBERS (SETS)
var Found = false;
var Current = new Array();
var MaxValue = 36;
// total number of sets
var NumUnique = 1;
// specifies the number of unique numbers required
var Count = 0;
var Current = new Array(NumUnique);
GetUnique();
//+","+Current[1]+", and"+Current[2]+", and "+Current[3]
function GetUnique() {
    trace("GetUnique");
    trace("NumUnique" +NumUnique);
    /*Count++;
    trace("Count"+Count);
    //trace("the unique number are:"+Current[0]);
    */
    for (i=0; i<MaxValue; i++) {
        trace("i "+i);
        Found = false;
        var rndValue = get_random();
        var j = 0;
        for (j=0; j<Current.length; j++) {
            if (Current[j] != rndValue) {
                Found = true;
                break;
            }
        }
        if (Found != true) {
            //Count--;
            Current[Count] = rndValue;
            count++;
        } else {
            //Current[Count] = rndValue;
        }
        }
    _root.sets.gotoAndStop(Count);
        //trace(Current[Count]);
}
function get_random() {
    trace("get_rdm");
    var ranNum = Math.round(Math.random()*MaxValue);
    return ranNum;
}


User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/7/08 08:10PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month