You may have already noticed the Hide button in the sample component we added to our toolbar. Clicking the Hide button does three things – it unloads the swf file, making sure the game is not running, it replaces the Hide button with a Show button, and it minimizes the components dimensions to fit the new buttons dimensions.
The JavaScript for creating such a behavior is included entirely in “index.html” in the tutorial files. It uses SWFObject to attach and remove the swf file, and the Conduit API to resize the component, and store the last state on the local machine. It also takes care of showing alternate content if a sufficient Flash version was not detected.
You may use this file as a template for your Conduit games. It can be easily adjusted to wrap your own game, and showing your own Show/Hide buttons.
To do so, open it up in an HTML editor and view the source. Take a look at script starting at line 17
|
var gameURL = |
|
'SampleGame.swf'; |
|
var playerVersion = |
|
'9.0.115'; |
|
var gameWidth = |
|
250; |
|
var gameHeight = |
|
26; |
That is where we specify our custom embed parameters – URL of the SWF file, game width, game height, and lowest Flash Player version required. Modify these values to match your own SWF file.
Next create your own Show/Hide buttons, and modify the HTML source to display them. Use the existing <imge> tags, and do not change their ID or any other attribute. These are required for the script to run properly.
And that’s pretty much it. Your component is ready to be uploaded and added to the toolbar.
NOTE: opening up "index.html" in a browser will redirect you to an error page. This is caused by calling API functions that are meant to interact with the engine, and cannot be called within a web page.