ART - Core
ART - Shapes
Elements
Animations
Ajax
Natives
Classes
Utilities
Class: Swiff
Creates and returns a Flash object using supplied parameters.
Credits:
Flash detection and Internet Explorer/Flash Player 9 fix adapted from SWFObject.
Syntax:
var mySwiff = new Swiff(path[, options]);
Arguments:
- path - (string) The path to the SWF file.
- options - (object, optional) See Options below.
Options:
- id - (string: defaults to 'Swiff_' + unique id) The id of the SWF object.
- width - (number: defaults to 1) The width of the SWF object.
- height - (number: defaults to 1) The height of the SWF object.
- container - (element) The container into which the SWF object will be injected.
- params - (object) Parameters to be passed to the SWF object (wmode, bgcolor, allowScriptAccess, loop, etc.).
- allowScriptAccess - (string: defaults to always) The domain that the SWF object allows access to.
- quality - (string: defaults to 'high') The render quality of the movie.
- swLiveConnect - (boolean: defaults to true) the swLiveConnect parameter to allow remote scripting.
- wMode - (string: defaults to 'window') Changes the way the SWF is displayed in the browser.
- properties - (object) Additional attributes for the object element.
- vars - (object) Vars will be passed to the SWF as querystring in flashVars.
- callBacks - (object) Functions to call from the SWF. These will be available globally in the movie, and bound to the object.
Returns:
- (element) A new HTML object Element.
Example:
var obj = new Swiff('myMovie.swf', { id: 'myBeautifulMovie', width: 500, height: 400, params: { wMode: 'opaque', bgcolor: '#ff3300' }, vars: { myVariable: myJsVar, myVariableString: 'hello' }, callBacks: { load: myOnloadFunc } });
Note:
- Although Swiff returns the object, this element will NOT have any Element methods applied to it.
- The $ function on an object/embed tag will only return its reference without further processing.
- Avoid changing the wMode param to 'transparent'. It will make your page more processor intensive, especially when running in a background tab.
Swiff Function: remote
Calls an ActionScript function from JavaScript.
Syntax:
var result = Swiff.remote(obj, fn[, arg, arg, arg ...]);
Arguments:
- obj - (element) A Swiff instance (an HTML object Element).
- fn - (string) The name of the function to execute in the Flash movie.
- arg - (mixed) Any number of arguments to pass to the named function.
Returns:
- (mixed) The ActionScript function's result.
Example:
var obj = new Swiff('myMovie.swf'); // alerts "This is from the .swf file!". alert(Swiff.remote(obj, 'myFlashFn'));
Note:
The SWF file must be compiled with the ExternalInterface component. See the Adobe documentation on External Interface for more information.