If you're anything like me, you use the Flash timeline to control your application states. This is a fairly common approach, but what if you want to strictly control the states and their interaction with each other? When viwing a swf file, you can right click and select "Play." This advances the playhead, and it plays until it encounters a stop() actionscript command. The "Play" action will cause the movie to advance to a new application state, which in most cases is an undesired user action.
A quick way to prevent this from interfering with the way your application works is to structure your timeline something like this: ![]()
To download the .fla file for this example, click here.
As you can see, I simply added a new "error" application state, and added another keyframe to each application state. On the keyframe, there is one line of actionscript telling the movie to stop at the error state.
This prevents a "malicious" or "just-experimenting" user from having more control over your application than you want them to by rigidly locking them into application states. It may not be the best solution around, but it's been working for me.
Ideally, you would like to force the user back to the state they just came from and prevent the "Play" action from happening at all. This can be accomplished by stopping at "_root._currentframe - 1", rather than the "error" state. The possible downside to this is code being executed again on the application state frame producing unwanted results. If you decide to use this approach instead, make sure you're careful when redirecting to the state they left so nothing gets executed "accidently."

1 Comment
why dont u just lock off the menu instead.. all the menu stuff is useless anyways
Posted by: punkture | February 27, 2004 2:52 PM