Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I've been working on a game following a tutorial on the internet, the game is an avoider where you have the Avatar, that has to avoid the objects that fall.

The way it is made is: I have a DocumentClass which addChild's the screen you should be seeing and removeChild's the screen that you were.

For example: first it loads the menuScreen, then when you press play unloads menu and loads playscreen. When you die it loads the gameoverScreen and loads the playscreen.

And from the gameOverScreen you can press the SHOP button to go to the shop. From here on I'm on my own and not following any tutorials.

The shop has a button that is supposed to alter the Avatar's X and Y scale to 0.5, but the problem is: how do I make that work?

I tried creating a sharedObject.data.avatarSize, on the store's size button the code would be something like:

sharedObject.data.avatarSize *= 0.5; 

And on the AvoiderGame.as, which is the most of the actual game, on the part where the avatar is created I tried putting this after it's creation:

scaleX.avatar = sharedObject.data.avatarSize;
scaleY.avatar = sharedObject.data.avatarSize;

This did not work since it gives me the error 1009 saying can't access something that is null. I tried this before "using" the sharedObject:

if( sharedObject.data.avatarSize == null )
{
    sharedObject.data.avatarSize = 1;
}

But it did not work...

So now I'm not sure on what to do. I know we should reduce global variables as much as we can but how do I do it?

--EDIT--

Also, if it helps, I'm using Flash CS5 and working with AS3.0 and if you don't know about flash, you can also tell me how you would do it on any other language and I would try to convert it to flash.

share|improve this question

closed as too localized by Tetrad Oct 19 '12 at 16:50

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Well I'm not to familiar with flash, but it seems like your ScaleX or ScaleY struct/class was never initialized. If your avatar is just a sprite it should be as easy as changing the sizes speicified in your draw code to the (image width * avatar size, image height * avatar size) –  Benjamin Danger Johnson Oct 18 '12 at 17:46
    
Actually the scaleX and scaleY are actually flash functions that affect the X and Y scale respectively. But the real problem is the sharedObject I'm making is making the program tell me it is null, if I remove the lines of that IF statement it doesn't give me the error. –  Madcowe Oct 18 '12 at 18:23

1 Answer 1

up vote 0 down vote accepted

Solved it!

I had to do a lot of work for it to work though, but it seems to have been mostly a distraction on my part.

Had to create the sharedObject var on the .as files it was used in, which I had already done, but I also had to associate them with the save file where they were, of course!

Then after that the code didn't really give me much trouble, thanks though, I only managed with some tips and tricks from here.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.