Visual Chat (WIP)
Introduction
This is a work-in-progress, just the client-side part of a MMO*. The to-do list includes artwork, menu functionality (the only menu item that works is Help -> Credits), obstacles, display of other players, preloader and sign-in, and all the server-side programming. You might want to read my isometric tutorial for the basics of keyboard navigation and character animation.
Work-in-progress demo
Explanation and code
Since the script is kind of long (420+ lines), I'll cut it up into sections and comment on each piece, then have a zipped archive for download at the end.
This is all basic scripting. If you have a font that you don't use, or use only in actionscript, SWFC won't compile it into the .swf. You can work around this by making a text box with the font you need, but never using it.
The gradient gives a little bit of a rounded look to the chat button. By default, gradients run from left to right, so it's rotated 270 degrees. The chat box is in its own movieclip (called a sprite in SWFC) so that movieclip-only operations can be performed on it later.
These are some elements for using multiple times in the "movie". I don't think these are true "prototypes" according to the normal Flash/Actionscript definition. The empty sprite (movieclip) is for replacing existing movieclips that need to be removed. (An alternative would be moving them off the visible part of the stage). The dialog box is a fixed size right now, it would be more versatile if it was scalable. I'll probably change this in my project so that the dialog box sprite is assembled when it's needed using Actionscript.
This is the upper-left-hand "World" menu. The method of using on_move_out for turning off the menu doesn't work really well, especially when the mouse is moving fast or the user has a graphics tablet and "jumps" the cursor off the menu. To solve it, you could use a timer to turn it off if it's not being used, or a mouse-catcher movieclip, or maybe some kind of event listener that watches mouse position.
These are the other menus, basically the same as the World menu. The last button in the help menu (helpmenubutton5) is the only one that does anything other than close the menu. The _root.dialogopen() didn't work if I put it after the _root.menuoff(), maybe because Flash stops execution of any Actionscript attached to a movieclip once it's been removed from the stage?
The worldbox is a backdrop for when the under-foot map is not visible, it's optional. The characterbox isn't being used, it's just there for debugging purposes and a leftover from before I drew the character.
Positioning of everything on the stage. If you use a different font, you'll need to tweak everywhere that it's positioned since they all vary in glyph size and positioning.
For some reason, the chatdisplay is initialized with something about the level and name of the object, so I set it to an empty string. You could put a start-up message here instead. Since it will end up in an html edittext box, the left and right angle brackets are replaced. The chattextfocused global variable is used to make sure that arrow keys don't move the cursor in the chat box when it's not active.
If you try to use _root.dialogsprite.dialogtitle=title; instead of _root.dialog_item.dialogtitle; it won't do anything, you have to use the movieclip name declared in the createEmptyMovieClip();.
Most of this is explained in my isometric tutorial, but the background is being moved instead of the character. (When the character is animated, it will just walk in place on the stage). I'll probably use gotoAndPlay() instead of gotoAndStop() to animate the walk cycle.
Here's a link to the zipped archive with all the external files used. The font is Verina (based on Bitstream Vera) and has a GPL license. I used the development version of SWFTools to compile the example, but 0.8.1 should work. The file in the zip is based on being in a folder named "social" under the swftools installation folder, but you can change that by modifying the paths to the file resources at the top of the .sc script.
If you have any comments, corrections, compliments, insults, etc, etc, Contact me or use the content addition form.
www.SWFTools.uni.cc