Wednesday, April 1, 2009

Achieve!

Okay, if you want an achievement for reaching frame ten I would code it like this. (Might not be the best looking, but it works!) First you need an object ONLY on said frame. Then you need to put this code in said object.

 _root.ReachedFrame10AChievement = 1; 


ReachedFrame10AChievement is just a variable we will use to know whether or not the achievement has been achieved.

Now, create an achievement page, and put an achievement object on it (Make sure it's a MovieClip!). Now make sure it has two frames. The first will be the un-achieved, and second will be the achieved.

Put this code in your achievement MovieClip

 onClipEvent (load) {
if (_root.ReachedFrame10AChievement == 1) {
gotoAndStop(2);
}
}


That will direct your achievement MovieClip to go to it's "achievement" frame.

Look out for if you have to go back to your menu to get to your achievement page, and that's where you are declaring your vars, and you redeclare ReachedFrame10AChievement to 0. it will erase the achievement.

The way to avoid this is to save the var when you achieve it, and then make sure you load it up again on the achievement page.

No comments: