How to configure FlashCanvas
Setting options
You can configure FlashCanvas Pro by setting options. The options should be passed to FlashCanvas.setOptions() method in the form of JavaScript object. For example, if you would like to use legacy mode compatible with FlashCanvas Pro 1.1, you can set the options in the following way:
if (typeof FlashCanvas != "undefined") {
FlashCanvas.setOptions({
turbo: false,
delay: 30
});
}
It is also possible to set the options before loading flashcanvas.js. In that case, please assign the options to a window.FlashCanvasOptions object. Then the options will be passed to flashcanvas.js. For example, you can specify the location of the SWF files in the following way.
window.FlashCanvasOptions = {
swfPath: "http://example.com/swf/"
};
Available options
The options supported by the current version of FlashCanvas Pro are described below.
swfPath
- Summary:
- Location of the SWF files.
- Default value:
- Same directory as flashcanvas.js
- Possible value:
- URL with a trailing slash
With this option, you can specify the location of the SWF files if those files are in a different place than flashcanvas.js. Please note that flashcanvas.js preloads the SWF file just after it is loaded. Thus you must set this option via a FlashCanvasOptions object before loading flashcanvas.js.
And you should set this option when you asynchronously load flashcanvas.js, because the detection of the URL will fail in that case.
disableContextMenu
- Summary:
- Disable the right-click context menu of Flash.
- Default value:
- false
- Possible value:
- true / false
FlashCanvas provides a customized right-click menu from which you can save the Canvas image as a PNG file. But there would be times when you'd like to use right mouse button for your own purpose. In that case, please set this option "true".
turbo
- Summary:
- Use asynchronous data transfer via FlashVars.
- Default value:
- true
- Possible value:
- true / false
This option enables/disables a turbo mode of FlashCanvas Pro. The turbo mode uses asynchronous data transfer via FlashVars in combination with synchronous execution via ExternalInterface. As a result, the turbo mode provides better performance.
The other features of the turbo mode are as follows:
- The turbo mode requires a smaller delay time. If you disables the turbo mode, some demos like Starfield demo, for example, require a delay time of 30ms or so.
- In the turbo mode, you cannot catch an exception thrown from Flash.
While we recommend to keep this option "true", some demos might show strange behavior in the turbo mode. In that case, please try to set this option "false".
delay
- Summary:
- Delay time for setTimeout() method.
- Default value:
- 0
- Possible value:
- Nonnegative number (The unit is millisecond)
As you increase this value, the screen is updated less frequently and the animation becomes jerky. But at the same time, FlashCanvas Pro consumes less CPU time if you increase this value.
imageCacheSize
- Summary:
- Size of the ring buffer used for image caching.
- Default value:
- 100
- Possible value:
- Positive number
This option defines the cache size used for storing bitmap data of loaded images. The cache is implemented as a ring buffer, and the default value of this option is set to 100. That means the first image will be removed from the cache when you load the 101st image.
usePolicyFile
- Summary:
- Use a cross-domain policy file to load images from other domain.
- Default value:
- false
- Possible value:
- true / false
This option switches a way to load images from other domain. If it is set to true, FlashCanvas utilizes a cross-domain policy file instead of the proxy.php script.
To use this feature, you are required to put a crossdomain.xml file in the root directory. For example, if you'd like to load http://example.com/images/foo.jpg from other domain, you must edit http://example.com/crossdomain.xml.