The web site for Flash ActionScript 3.0 game developers

 
         
   

Ask Gary: Repositioning Word Search

hi Gary,

enjoying the book, and probably ahead of myself BUT, how can I change
where the wordsearch grid and wordlist appear on the stage if I change the
size of the stage?

I've made the stage larger, and I would like to put the grid and wordlist
in the center - how do I change the X/Y?

thanks...
skillspider

There are many ways to do this. One would be to change some constants in the code. If you look at the start of the script, you will see an offset for the letter grid.

static const offset:Point = new Point(15,15);

You can simply change this to 115,115 to move the grid to the right 100 pixels and down 100 pixels.
Similarly, you can move the word list over by changing this line:

newWord.x = 400;

What I would do first, is to make it dependent on the same offset constant. So change it to this:

newWord.x = offset.x + 385;

Now it will always be to the right of the letter grid. All you need to do is change the offset constant to move both elements.
Another way to do this would be to simply move the gameDprite. Every game element is in the gameSprite, which is at position 0,0 by default. So moving it to 100,100 will have the same effect as the other changes. Here is that code inserted into the startWordSearch function.

// set up the sprites
gameSprite = new Sprite();
gameSprite.x = 100;
gameSprite.y = 100;
addChild(gameSprite);


Copyright Gary Rosenzweig