192
Chapter 9: Using Flash, Flash Components, and Other Interactive Media Types
In Flash, the ActionScript would look as follows:
getURL("event:alertMessageReceived");
When Director receives the getURL message from the Flash sprite, the Director movie
immediately executes the script statement.
Sending script statements with arguments
It is possible to send script statements that are more complicated than a string or statements that
call a single script handler reference. Sending handlers with arguments or sending arguments that
contain double quote characters takes more effort to make sure that the script statement is
properly formed.
Note:
To send simple strings and statements, see
“Sending simple messages and script statements”
on page 190
.
Suppose you have a Director handler in a movie script that adds two numbers and presents an
alert with the sum, as follows:
on addTwoNumbers number1, number2
myResult = n number2
_player.alert(string(myResult))
end
To pass arguments to this script (
number1
and
number2
), you would include the following
statement in your Flash ActionScript:
getURL("lingo:addTwoNumbers 100, 200");
If the arguments are strings, you need to escape the double quote characters using a backslash
character on each double quote character that you want to be passed through to Director. For
example, if you want to send a script statement from the Flash sprite which tells Director to
launch a browser and open macromedia.com, you would do the following:
getURL("lingo:gotonetpage(\"http://www.macromedia.com\")");
It may be easier to fabricate the script statement in a temporary variable inside the Flash method
and then use getURL on that variable as follows:
var theString = getURL("lingo:gotonetpage(\"http://www.macromedia.com\")");
getURL(theString);
Additionally, you may want to send the value of a Flash variable as part of the script statement.
For example, if
myFlashVar
in Flash represents a Macromedia product such as Director
(
myFlashVar="director"
in ActionScript), you could form a script statement as follows in your
Flash script:
var theString = getUrl("lingo:gotonetpage(\"http://www.macromedia.com/
software/" + myFl "\")");
getURL(theString);
The resulting URL would be "http://www.macromedia.com/software/director" and would be
passed to the browser through Director's
goToNetPage
command.
Summary of Contents for DIRECTOR MX 2004-USING DIRECTOR
Page 1: ...DIRECTOR MX 2004 Using Director...
Page 16: ...16 Chapter 1 Introduction...
Page 82: ...82 Chapter 3 Sprites...
Page 98: ...98 Chapter 4 Animation...
Page 134: ...134 Chapter 5 Bitmaps...
Page 242: ...242 Chapter 10 Sound and Synchronization...
Page 274: ...274 Chapter 11 Using Digital Video...
Page 290: ...290 Chapter 12 Behaviors...
Page 302: ...302 Chapter 13 Navigation and User Interaction...
Page 334: ...334 Chapter 15 The 3D Cast Member 3D Text and 3D Behaviors...
Page 392: ...392 Chapter 16 Working with Models and Model Resources...
Page 418: ...418 Chapter 18 Movies in a Window...
Page 446: ...446 Chapter 22 Managing and Testing Director Projects...