Creating Your Own Panels
Flash comes with a lot of panels, but you might not need or want every one. No worriesyou can create your own panels, which isn't really new, but now you can use the MMExecute() function, which will execute any JSFL command within the authoring environment. When the Flash file (.swf) has been created, you can drop it in the WindowSWF directory in the Flash 8 directory and restart the Flash authoring environment. Then you can find it under Windows, Other Panels in the menu bar.The basic layout of the MMExecute() method is as follows:
The difficult aspect of using the MMExecute() method is that the command must be passed as a string, but the dynamic content cannot. For instance, if you were to send the current date and time to the Output panel, it would look something like this:
MMExecute(command);
Notice the abundance of quotation marks to make it work right, just something to keep in mind when using the MMExecute() function.Now that you have seen the basic usage of the function we are going to use to create our first panel, let's get started.
MMExecute("fl.trace('" + new Date() + "');");
1. | Create a new Flash document. |
2. | Set its dimensions to 200x100. |
3. | Drag three components onto the stage and place them as follows:
Your stage should now look like Figure 27.11. Figure 27.11. Use components to quickly create custom panels.[View full size image] ![]() |
4. | Create a new layer called actions . |
5. | Open the Actions panel in the first frame of the Actions layer and place this code in:The preceding code first creates an event listener object. Then it creates an event callback method for that object that checks where the string from the TextInput component is supposed to goeither to the Output panel or to an alert message. Then finally we add the event listener to the Button component. |
6. | Now save the file as Send Out.fla and test the movie. |
7. | Copy the .swf file created to the WindowSWF directory of the Flash 8 first-run directory and restart Flash. |
8. | When Flash has been restarted, choose Window, Other Panels, Send Out. Now you have the capability to send messages to the Output panel as well as in the form of alert messages, as in Figure 27.12.Figure 27.12. You can see that the panel created can send messages both to the Output panel and as an alert message.![]() |
This example does not have the most practical uses, but it does show what is possible by combining Flash developing, JSFL, and the MMExecute() function. As you become more comfortable with JSFL, you will begin to create many of your own panels.But panels are not the end of customizing the authoring environment of Flash. You can also create your own tools with JSFL and place them in the toolbar.