|
{mdm}Script 1.0 Advanced Usage |
|
NOTE: FSCommand Usage is now deprecated. It is still available in Zinc™ v2.5 to provide backwards compatibility but should not be exclusively used for new projects. This chapter is included as a point of reference on FSCommand Implementation. All new Zinc™ v2.5 Projects should be scripted with {mdm}Script™ 2.0.
Advanced {mdm}Script™ 1.0 Usage (Callbacks)
{mdm}Script™ also incorporates a unique callback system which allows commands with return variables to trigger simple or complex functions. Below is a simple example of how to use a callback function:
Step 1
Create a New File in Adobe Flash MX or MX 2004 and select the First Frame of your Movie. Expand the Action Window and enter the following code:
mdminit();
function myCallBackFunction(myValue){
mdm.prompt(myValue);
}
Create a button on the main timeline and add the following code to it:
on (release){
mdm.browsefile(myCallBackFunction)
}
As you can see, instead of entering the return variable, we enter the name of the function to use instead. In this case, the function is called "myCallBackFunction".
Step 2
When the movie is exported and compiled using Zinc™ v2, press the button to trigger the Browse File Dialog. After selecting a file and clicking on OK, the result will be sent to the function which will then prompt the value.
This demonstrates a very simple way to execute callback functions, but advanced usage can also be applied. The main point, however, is that the need to use frame-by-frame loops, or watches is now eliminated and coding becomes far less time consuming.