# Affect movieclip scale from a .as doc to another [closed]

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.

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.

• 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) 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. Oct 18 '12 at 18:23