07-13-2009, 03:35 PM
|
#11
|
|
Flash...Hippo?
Join Date: Jul 2009
Location: Canada
Posts: 322
|
Wow, I didn't expect you to do it all! =) All my thanks goes to you! There is only a tiny problem- when I run it, some of the buttons are below the stage, no matter how big I make it. For example, 'p' of shop is missing, and looking at your array, so is the random letter underneath.
To anyone who is going to Google this, to use the above code, all you need to do is drag a button component (Windows>Component) to the stage and delete it.
__________________
PM me since I frequently forget some threads I replied to! =)
|
|
|
07-13-2009, 05:47 PM
|
#12
|
|
Senior Member
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,682
|
This is probably because I set buttonSize:int = stage.stageWidth / wordSearch.length, wich means it will make the buttons fit evenly across the width of the stage (however many buttons are in a row), and because it makes them square if the stage height is not as tall as it is wide, they'll be off the page. You can just change buttonSize to make it fit however you want, though.
|
|
|
07-13-2009, 06:21 PM
|
#13
|
|
Flash...Hippo?
Join Date: Jul 2009
Location: Canada
Posts: 322
|
Worked perfectly. Thank you so much! Case closed!
__________________
PM me since I frequently forget some threads I replied to! =)
|
|
|
07-13-2009, 09:26 PM
|
#14
|
|
Senior Member
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,682
|
Cool, have fun.
|
|
|
02-14-2010, 04:55 PM
|
#15
|
|
Registered User
Join Date: Feb 2010
Posts: 34
|
sorry to resurrect the thread but I'm trying to find out away to position the grid within the file instead of just in the top left.
I'm new to action script and I tried adding wordSearch.x = 100 but it just makes the grid disappear and all the other things I tried had no effect.
Thanks in advance,
|
|
|
02-14-2010, 05:39 PM
|
#16
|
|
Senior Member
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,682
|
wordSearch is an array so it has no dispaly properties like x, y.
The easiest way to do what you want would be to put all the buttons in a container and position that:
ActionScript Code:
var container:Sprite = new Sprite();
addChild(sprite);
container.x = 25;
container.y = 50;
// change this:
//addChild(btn);
// to this:
container.addChild(b);
|
|
|
05-20-2010, 07:24 PM
|
#17
|
|
Registered User
Join Date: May 2010
Posts: 5
|
score into php?
Hi,
could someone help me with counting the score in WordSearch and sending it to php? I am trying it since a while and it drives me crazy, I just cant figure out what's wrong... So here is what I tried:
at the beginning of the code:
var words;
lvOut = new LoadVars();
then I follow the code given here earlier, until I reach this:
// remove the solution so that there are no repeats
solutions.splice(i,1);
after this, I inserted the followings:
words = solutions.length;
//assign user-input value to lv property called words
lvOut.words = words.text;
//send to a blank window
lvOut.send("C:\xampp\htdocs\WS\php\words.php","_bl ank","POST");
and then it continues as in the original code:
break;
}
}
I thought this gives me how many words are NOT found yet, so I can see it counting down until someone gives up/solves the whole game. But it does not work... It reports compiling error: Access of undefined property lvOut
Can anyone help me please?
|
|
|
04-18-2012, 08:48 AM
|
#18
|
|
Registered User
Join Date: Apr 2012
Posts: 1
|
Random word search
Hi everyone!
I saw the codes below. It is brilliant.
Now I am trying to make a word search which creates its own word randomly and placed it randomly.
I've done part of it but there is a problem when two words cover one each other, I tried to fix it by changing the word's position so that it can avoid covering each other but it didn't work. What should I do?
ActionScript Code:
var i:uint = 0;var j:uint = 0;var k:uint = 0;
var posX:uint = 0;var posY:uint = 0;
var error:int = 0;
const buttonSize:int = 50;
const LINE_WIDTH:int = 35;
var btnArr:Array = [];
// Array that records where the covered words are
var errorLocate:Array = [];
// Coordination of button
var coorArr:Array = [0,1,2,3,4,5,6,7,8,9,10];
// Array of directions the word can place
var canCover:Array = [true,true,true,true,true,true,true,true];
// Directions
const directionArr:Array = [0,1,1,1,1,0,1,-1,0,-1,-1,-1,-1,0,-1,1];
// Directions that the words can be placed
var directFinArr:Array = new Array();
for(i = 0; i < 11; i++){
directFinArr[i] = [];
for(j = 0; j < 8; j++)
directFinArr[i].push(-1);
}
// If the button has a word on it
var haveWord:Array = new Array();
for(i = 0; i < 11; i++){
haveWord[i] = [];
for(j = 0; j < 11; j++)
haveWord[i].push(false);
}
var solutions:Array = new Array();
for(i = 0; i < 11; i++){
solutions[i] = [];
for(j = 0; j < 2; j++){
solutions[i][j] = [];
for(k = 0; k < 2; k++)
solutions[i][j].push(-1);
}
}
const letters:Array = [ 'A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z' ];
// words i planned to use
var words:Array = [ "RED","GREEN","BLUE","YELLOW","PINK","ORANGE","WHITE","BLACK","BROWN","GREY",
"GRANDFATHER","GRANDMOTHER","FATHER","MOTHER","SISTER","BROTHER","UNCLE", "AUNT","DAUGHTER","SON",
"APPLE","BANANA","LEMON","PEAR","ORANGE","GRAPE","WATERMELON","MELON","PUMPKIN","STRAWBERRY",
"DRESS","HAT","SHOES","SHIRT","GLOVES","SCARF","JACKET","PANTS","SOCKS","TIE",
"CLOUDS","FLOWER","MOON","MOUNTAIN","RAIN","RAINBOW","RIVER","SKY","TREE","STAR",
"CROCODILE","CAT","CHICKEN","COW","DOG","DONKEY","EAGLE","HORSE","MONKEY","RABBIT"];
words = shuffle(words);
setbtn();
setwordpos();
setletter();
// get one of the contents of one array
function getRandomFromArray(arr:Array){
var randomIndex:uint = Math.floor(Math.random() * arr.length);
return arr[randomIndex];
}
// get one random number from low to high
function randomNumber(low:Number=0, high:Number=1):Number{
return Math.floor(Math.random() * (1+high-low)) + low;
}
// shuffle the contents of one array
function shuffle(arr:Array):Array{
var arr2:Array = [];
while(arr.length > 0){
arr2.push(arr.splice(Math.round(Math.random() * (arr.length - 1)), 1)[0]);
}
return arr2;
}
// decide the word position and place the words
function setwordpos():void{
var rnd1:int;
var rnd2:int;
var rndx:int;
var rndy:int;
for(i = 0; i < 8; i++){
error = 0;
do{
coorArr = [0,1,2,3,4,5,6,7,8,9,10];
canCover = [true,true,true,true,true,true,true,true];
directFinArr[i] = [-1,-1,-1,-1,-1,-1,-1,-1];
// sense the possible location the word can place
if(words[i].length>6){
for(j = 0; j < 11; j++)
if(!(j >= words[i].length-1 || j <= 11-words[i].length))
coorArr[j] = null;
coorArr.sort();
coorArr.length = (12-words[i].length)*2
}
rnd1 = getRandomFromArray(coorArr);
rnd2 = getRandomFromArray(coorArr);
// first check : out of border
for(j = 0; j < 8; j++){
rndx = directionArr[j*2];
rndy = directionArr[j*2+1];
if(rnd1+rndx*(words[i].length-1)>10||rnd1+rndx*(words[i].length-1)<0||
rnd2+rndy*(words[i].length-1)>10||rnd2+rndy*(words[i].length-1)<0){
canCover[j] = false;
}
}
// second check : have cover words
for(j = 0; j < 8; j++){
rndx = directionArr[j*2];
rndy = directionArr[j*2+1];
if(canCover[j])
for(k = 1; k < words[i].length; k++)
if(haveWord[rnd1+rndx*k][rnd2+rndy*k])
canCover[j] = false;
}
// choose directionss
for(j = 0; j < 8; j++)
if(canCover[j])
directFinArr[i].push(j);
directFinArr[i].splice(0,8);
trace(i+":"+rndx+","+rndy);
rndx = directionArr[getRandomFromArray(directFinArr[i])*2];
rndy = directionArr[getRandomFromArray(directFinArr[i])*2+1];
error++;
if(error>=200){
i--;
words.splice(i,1);
errorLocate.push(i);
break;
}
}while(directFinArr[i].length == 0);
if(directFinArr[i].length != 0){
solutions[i][0][1] = rnd1;
solutions[i][0][0] = rnd2;
solutions[i][1][1] = rnd1+rndx*(words[i].length-1);
solutions[i][1][0] = rnd2+rndy*(words[i].length-1);
for(j = 0; j < words[i].length; j++){
haveWord[rnd1+rndx*j][rnd2+rndy*j] = true;
btnArr[(rnd1+rndx*j)*11+rnd2+rndy*j].label = words[i].charAt(j);
}
error = 0;
trace(solutions[i]);
}
}
}
function setbtn():void{
var counter:int = 0;
i = 0;
while(posY < 500){
posX = 10;
j = 0;
posY = i * buttonSize;
while(posX < 500){
posX = j * buttonSize;
var b:Button = new Button();
b.setSize(buttonSize, buttonSize);
b.move(posX, posY);
b.setStyle("textFormat", myTf);
b.label = "";
btnArr.push(b);
addChild(b);
j++;
}
i++;
}
}
// place other letters
function setletter():void{
for(i = 0; i < 11; i++)
for(j = 0; j < 11; j++)
if(!haveWord[i][j])
btnArr[i*11+j].label = getRandomFromArray(letters);
}
// transform the labels of the button to array wordSearch
var wordSearch:Array = new Array();
for(i = 0; i < 11; i++){
wordSearch[i] = [];
for(j = 0; j < 11; j++){
wordSearch[i][j] = btnArr[i*11+j].label;
}
}
Last edited by rogercheng; 04-18-2012 at 08:59 AM.
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 05:53 PM.
///
|
|