You can use Flash methods to send JavaScript calls to Flash movies from the HTML pages. A Flash method is a JavaScript function that is specific to Flash movies. Each method has a name and most methods take arguments. An argument specifies a value on which the method operates.
For our purposes we're going to focus on one technique, SetVariable, to send data from JavaScript to the Flash movie. Inside Flash we use SetVariable to set dynamic data; outside of Flash we'll do the same with JavaScript to send in information. SetVariable sets the value of the Flash variable specified by variableName to the value specified by value. The argument type for both arguments is string. For example, an HTML page could have the following: <a href='javascript: window.pocketpc.SetVariable("myvariable","your ad here")'>Click me</ a> The HTML looks like this: <HTML> <HEAD> <TITLE> Your Ad Here</TITLE> </HEAD> <BODY bgcolor="#FFFFFF"> <OBJECT class WIDTH=240 HEIGHT=240> <PARAM NAME=movie VALUE="myflash.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="/books/2/36/1/html/2/myflash.swf" quality=high bgcolor=#FFFFFF WIDTH=200 HEIGHT=130 swLiveConnect=true NAME=pocketpc TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/ index.cgi?P1_Prod_Version=ShockwaveFlash"> </EMBED> </OBJECT> <br> <a href='javascript:window.pocketpc.SetVariable("myvariable","Your Ad Here")'>Send data in!</a><br> </BODY> </HTML> This allows you to have a link inside the HTML page and send that information (myvariable=your ad here ) into the Flash movie (see Figure 2.41). Note the ID tag as well as the "swLiveConnect=true NAME=pocketpc" in the EMBED tag. The ID tag is so the Pocket PC knows where to send the data to. The swLiveConnect is for the benefit of the Netscape users; while it's not needed for the Pocket PC it's a good idea to put it in there in case you need your content to be viewable on desktops as well as devices. Figure 2.41. Sending data into a Flash application from JavaScript in Pocket Internet Explorer.
The Flash movie simply has a variable text field called myvariable .
|