Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 3rd, 2012, 07:07 AM
stillwell stillwell is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 60 stillwell User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 h 50 m 14 sec
Reputation Power: 6
Problem with repeat words from array

Hi, I'm making a small wordpuzzle game, and I have trouble figuring out how to make the game discard the words it has already given to the player.

I load in the array from an external txt file, and it works just fine. However, it is chosen at random from the list, which means that words get repeated sometimes.

So I'm looking for help on how to make the words that has already been used unselectable.
Code:
function wordsLoaded(event:Event):void
{
	var wordString:String = wordLoader.data;
	var wordArray:Array = wordString.split('\r\n');
	
	lineNumber = pickRandomLine(wordArray);
	
	var oldString:String = wordArray[lineNumber];
	
	word = oldString;
	wordScore = word.length;
	
	var newString:String = randomizeWord(oldString);

		while(oldString == newString)
		{
			newString = randomizeWord(oldString);
		}

	jumble_txt.text = String(newString);
}

function pickRandomLine(lenght:Array):Number
{
	var linePick:Number = Math.round((lenght.length -1) * Math.random());
	
	return linePick;
}


Any help and/or ideas are much appreciated.

Last edited by stillwell : November 3rd, 2012 at 07:41 AM.

Reply With Quote
  #2  
Old November 4th, 2012, 12:31 PM
stillwell stillwell is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 60 stillwell User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 h 50 m 14 sec
Reputation Power: 6
I figure that arrays is the way to go, but I just can't figure out how to do the check.

I added this array, which holds all the line numbers that needs to be excluded.
Code:
function pickRandomLine(lenght:Array):Number
{
	var linePick:Number = Math.round((lenght.length -1) * Math.random());
	
	//Save lineNumber for exclusion from word list
	exclusionArray[exclusionArray.length] = linePick;
	
	return linePick;
}


Any help is much appreciated.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > Promblem with repeat words from array

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap