Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating random words using movie clips?

Status
Not open for further replies.

pmoorey

Technical User
Mar 19, 2007
144
GB
Hi

I have been making a memory game, where words are shown to the user. Once they have memorised the words they go to the next screen where the words that they have memorised are shown. They then have to drag each word into a "correct" place and a "wrong" place. I now want to edit it so that I can use two arrays one for correct words and one for wrong words. I want to generate random words from each of these arrays. I have sort of worked out how this is possible to do but using dynamic text, but am I correct in thinking that the whole dragging the words thing is not possible with dynamic text. (I may be wrong though, I am quite new to flash). Are you able to do this with movie clips, or can anyone advise me on how it would be possible to do this?

Thanks


Peter
CCNA, Cisco Qualified Specialist
 
This is what I have done so far, I have commented some parts out just to make things smaller to make it easier when I was testing it out.

Code:
var position:Array = [{_x:100, _y:100}];
					  //{_x:200, _y:200}, {_x:300, _y:300}];

var correctArray:Array = ["bandMC", "bendMC", "brandMC"];
						  //"endMC", "grandMC", "handMC", "mendMC", "sandMC", "sendMC", "standMC", "behindMC", "blindMC", "findMC", "foundMC", "friendMC", "grindMC", "groundMC", "houndMC", "husbandMC", "islandMC", "kindMC", "landMC", "lendMC", "mindMC", "offendMC", "pondMC", "poundMC", "rewindMC", "roundMC", "secondMC", "soundMC", "strandMC", "tendMC", "thousandMC", "weekendMC", "woundMC", "surroundMC", "respondMC"];

var n:Number = correctArray.length;
while (n) {
	var k:Number = Math.floor(Math.random()*n);
	--n;
	var tmp:Object = correctArray[n];
	correctArray[n] = correctArray[k];
	correctArray[k] = tmp;
}
trace("correctArray: " + correctArray);


var correctCount:Number = 3;

var m:Number = correctCount;
var correctMCList:Array = new Array(m);
while (m) {
	--m;
	correctMCList[m] = correctArray[m];
}
trace("correctMCList: " + correctMCList);

startButton.onRelease = function() {
	startButton._visible = false;
	nextButton._visible = true;
	instructions._visible = false;
	instructions2._visible = true;
	for (var i:Number = 0; i<correctCount; i++) {
	   _root.attachMovie(correctMCList[i],correctMCList[i],_root.getNextHighestDepth(), positions[i]);
        trace(correctMCList[i]+": "+_root[correctMCList[i]]);
    }
};

Peter
CCNA, Cisco Qualified Specialist
 
oops sorry never noticed that, I usually copy and paste so that doesn't happen.

thank you! :)

Peter
CCNA, Cisco Qualified Specialist
 
Is there a way to generate movieclips rather than just making lots of them. For example is it possible to have an instance of a movieclip that is made up of a dynamic text box then have an array of strings that you want in the text box. When you press a button it will choose a random string to put into the movieclip.

I was just wondering as I have made each seperate movieclip and attatched AS to each of them, is there a better way of doing this?

Thanks


Peter
CCNA, Cisco Qualified Specialist
 
Cool, I havn't tried to do it that way before, do you know of any online tutorials that will help me with this?

Thanks

Peter
CCNA, Cisco Qualified Specialist
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top