src/cm/media/js/lib/yui/yui_3.10.3/docs/swf/index.html
author Yves-Marie Haussonne <ymh.work+github@gmail.com>
Fri, 09 May 2014 18:35:26 +0200
changeset 656 a84519031134
parent 525 89ef5ed3c48b
permissions -rw-r--r--
add link to "privacy policy" in the header test
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
525
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
     1
<!DOCTYPE html>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
     2
<html lang="en">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
     3
<head>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
     4
    <meta charset="utf-8">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
     5
    <title>SWF Utility</title>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
     6
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic,700italic">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
     7
    <link rel="stylesheet" href="../../build/cssgrids/cssgrids-min.css">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
     8
    <link rel="stylesheet" href="../assets/css/main.css">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
     9
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    10
    <link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    11
    <script src="../../build/yui/yui-min.js"></script>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    12
    
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    13
</head>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    14
<body>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    15
<!--
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    16
<a href="https://github.com/yui/yui3"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    17
-->
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    18
<div id="doc">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    19
    <div id="hd">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    20
        <h1><img src="http://yuilibrary.com/img/yui-logo.png"></h1>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    21
    </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    22
    
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    23
        <a href="#toc" class="jump">Jump to Table of Contents</a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    24
    
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    25
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    26
            <h1>SWF Utility</h1>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    27
    <div class="yui3-g">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    28
        <div class="yui3-u-3-4">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    29
            <div id="main">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    30
                <div class="content"><div class="intro">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    31
   <p>The YUI SWF Utility provides a standardized method for embedding the Adobe Flash player in web pages. Specifically, the SWF Utility:
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    32
	<ol>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    33
		<li> Creates browser-specific, standards-compliant markup for correctly embedding an instance of Flash player plugin (in browsers with Netscape Plugin Architecture), or an instance of Flash Player ActiveX control (in Internet Explorer).</li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    34
		<li> Allows developers to set a requirement for the minimum version of Flash player installed on the end user's computer.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    35
		<li> Provides a convenient single method instantiation of the embedded player properties and variables.</li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    36
		<li> Wraps the ExternalInterface API of the Flash player to allow method calls on specific player instances.</li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    37
		<li> In conjunction with the YUIBridge ActionScript API, allows Flash applications to dispatch events that get converted to native YUI events.</li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    38
	</ol>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    39
	
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    40
	<p><strong>Important usage notes:</strong></p><ul>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    41
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    42
	<li>The SWF Utility is engineered to only work with A-grade browsers. Because it allows only standards-compliant markup, the utility will not function properly in older browser versions.</li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    43
	<li>The <code>swfReady</code> event provided by the SWF Utility is only available when the Flash application being embedded uses the YUIBridge ActionScript library (see below).</li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    44
  	<li>The current recommended version of the Flash Player is 10.1, available at the <a href="http://www.adobe.com/go/getflashplayer">Adobe Flash Player Download Center</a>.</li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    45
  </ul>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    46
</div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    47
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    48
<h2 id="getting-started">Getting Started</h2>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    49
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    50
<p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    51
To include the source files for SWF Utility and its dependencies, first load
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    52
the YUI seed file if you haven't already loaded it.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    53
</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    54
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    55
<pre class="code prettyprint">&lt;script src=&quot;http:&#x2F;&#x2F;yui.yahooapis.com&#x2F;3.10.3&#x2F;build&#x2F;yui&#x2F;yui-min.js&quot;&gt;&lt;&#x2F;script&gt;</pre>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    56
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    57
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    58
<p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    59
Next, create a new YUI instance for your application and populate it with the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    60
modules you need by specifying them as arguments to the <code>YUI().use()</code> method.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    61
YUI will automatically load any dependencies required by the modules you
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    62
specify.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    63
</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    64
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    65
<pre class="code prettyprint">&lt;script&gt;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    66
&#x2F;&#x2F; Create a new YUI instance and populate it with the required modules.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    67
YUI().use(&#x27;swf&#x27;, function (Y) {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    68
    &#x2F;&#x2F; SWF Utility is available and ready for use. Add implementation
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    69
    &#x2F;&#x2F; code here.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    70
});
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    71
&lt;&#x2F;script&gt;</pre>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    72
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    73
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    74
<p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    75
For more information on creating YUI instances and on the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    76
<a href="http://yuilibrary.com/yui/docs/api/classes/YUI.html#method_use"><code>use()</code> method</a>, see the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    77
documentation for the <a href="../yui/index.html">YUI Global Object</a>.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    78
</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    79
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    80
				
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    81
<h2 id="using-the-swf-utility">Using the SWF Utility</h2>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    82
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    83
<p>This section describes how to use the SWF Utility in further detail.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    84
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    85
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    86
<h3 id="anatomy-of-the-swf-utility">Anatomy of the SWF Utility</h3>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    87
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    88
<p>The SWF Utility uses the browser information from the <code>Y.ua</code> variable to generate the appropriate markup for embedding the Flash player. The markup that the SWF Utility generates is entirely based on the <code>&lt;object&gt;</code> tag, and therefore will not work in older browsers that use the non-standard <code>&lt;embed&gt;</code> tag.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    89
</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    90
<p>In addition, the SWF Utility also determines the version of the Flash player (using YUI's <code>swfdetect</code> library), and places that information in <code>Y.ua.flash</code> as a period-delimited string (MajorVersion.MinorVersion.Revision). This information is used by SWF utility to prevent Flash Player embedding if the version of user's installed Flash player does not match that required by the developer.</p>				
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    91
<p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    92
   While the SWF Utility provides a direct access to the instance of the Flash player it encapsulates, it is recommended that all communication to that instance occur via the methods provided by the SWF Utility (see below.)
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    93
</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    94
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    95
<h3 id="configuring-and-instantiating-the-swf-utility">Configuring and Instantiating the SWF Utility</h3>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    96
<p>For simplicity, all configuration of the embedded Flash player instance happens in the SWF Utility at construction time, and therefore, all configuration parameters must be provided as arguments to the SWF constructor.</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    97
<p>By default, the SWF constructor requires only two arguments &ndash; the reference to the container in which the instance of the Flash player should be placed, and the URL of the swf application that the Flash player instance should load. Note that the Flash player instance created by the SWF Utility always adopts the size of the parent container it is placed into; therefore, setting the size of the Flash player is as simple as setting the size of its container.</p>                 
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    98
<p>To put an instance of the Flash player on the page, simply create a new instance of <code>Y.SWF</code> and provide it with the reference to the container in which it should be placed, as well as the URL of the swf file that needs to be loaded:</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    99
<pre class="code prettyprint">YUI({...}).use(&#x27;swf&#x27;,function (Y) {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   100
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   101
    &#x2F;&#x2F; Default everything
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   102
	var myswf = new Y.SWF(&quot;#swfContainer&quot;, &quot;http:&#x2F;&#x2F;example.com&#x2F;example.swf&quot;);
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   103
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   104
});</pre>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   105
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   106
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   107
<p>If you would like to specify additional parameters or pass arbitrary variables to the SWF, you can provide the constructor with the third argument, a paramter Object:</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   108
<pre class="code prettyprint">var params = {version: &quot;9.0.115&quot;,
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   109
	          fixedAttributes:
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   110
			  {allowScriptAccess:&quot;always&quot;, allowNetworking:&quot;all&quot;},
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   111
			  flashVars:
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   112
			  {foo: &quot;bar&quot;, foo1: &quot;bar1&quot;}
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   113
			 };
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   114
var myswf = new Y.SWF(&quot;#swfContainer&quot;, &quot;http:&#x2F;&#x2F;example.com&#x2F;example.swf&quot;, params);</pre>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   115
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   116
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   117
<p>The parameter object may contain the following possible properties:</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   118
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   119
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   120
                <table>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   121
                <thead>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   122
                    <tr>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   123
                        <th>Property</th>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   124
                        <th>Description</th>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   125
                    </tr>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   126
                </thead>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   127
                <tbody>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   128
                    <tr>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   129
                        <td><code>version</code></td>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   130
                        <td>A period-delimited string of three numbers specifying the minimum version of Flash player that must be installed on the user's machine.</td>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   131
                    </tr>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   132
                    <tr>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   133
                        <td><code>fixedAttributes</code></td>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   134
                        <td>An object with a set of configuration variables specific to the Flash player. The list of all possible configuration variables and their values, provided by Adobe, can be found <a href="http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7f18.html">here</a>.</td>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   135
                    </tr>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   136
                    <tr>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   137
                        <td><code>flashVars</code></td>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   138
                        <td>An object with a set of variables to pass to the Flash player. These variables are made available to the Flash application at initialization time, in the ActionScript's <code>Stage.loaderInfo.parameters</code> container.</td>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   139
                    </tr>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   140
                </tbody>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   141
                </table>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   142
<h3 id="calling-methods-on-the-instance-of-flash-player">Calling Methods on the instance of Flash player</h3>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   143
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   144
<p>The SWF Utility provides a wrapper for calling methods that have been exposed to JavaScript from within the Flash application. This allows the developer to call the methods without having to directly reference the private pointer to the instance of the Flash player contained in the SWF Utility. To call a method <code>foo(arg1, arg2)</code> on an instance of the Flash player, do the following:
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   145
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   146
<pre class="code prettyprint">YUI({...}).use(&#x27;swf&#x27;,function (Y) {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   147
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   148
	var myswf = new Y.SWF(&quot;#swfContainer&quot;, &quot;http:&#x2F;&#x2F;example.com&#x2F;example.swf&quot;);
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   149
	myswf.callSWF(&quot;foo&quot;, [arg1, arg2]);	
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   150
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   151
});</pre>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   152
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   153
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   154
<p>Note that, since Flash player is run as a separate thread, the existence of its instance is not guaranteed when the method call on it is made. To make sure that Flash is ready to accept incoming method calls, it's best to have the Flash player make a call to JavaScript announcing that it has finished initializing. While there is a number of ways to do that, YUI hybrid components use the YUIBridge ActionScript library to automate this process. See the next section for notes on its usage.</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   155
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   156
<h3 id="working-with-the-yuibridge-actionscript-library">Working with the YUIBridge ActionScript Library</h3>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   157
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   158
<p>YUIBridge ActionScript library creates a standardized method for sending YUI events from a Flash application. In an ActionScript application, an instance of YUIBridge is created as follows:</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   159
	
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   160
<pre class="code prettyprint">import com.yahoo.util.YUIBridge
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   161
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   162
...
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   163
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   164
&#x2F;&#x2F; The scope for &#x27;this&#x27; should be either the top-level application
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   165
&#x2F;&#x2F; or a Sprite that has been placed on the stage.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   166
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   167
var yuiBridge:YUIBridge = new YUIBridge(this.stage);</pre>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   168
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   169
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   170
<p>Instead of using <code>ExternalInterface.addCallback</code> on each method that needs to be exposed to JavaScript, you can instead call a collective <code>addCallbacks()</code> method available in YUIBridge:</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   171
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   172
<pre class="code prettyprint">import com.yahoo.util.YUIBridge
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   173
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   174
...
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   175
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   176
&#x2F;&#x2F; The scope for &#x27;this&#x27; should be either the top-level application
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   177
&#x2F;&#x2F; or a Sprite that has been placed on the stage.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   178
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   179
var yuiBridge:YUIBridge = new YUIBridge(this.stage);
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   180
yuiBridge.addCallbacks({externalMethodName:internalMethod, externalMethodName2:internalMethod2});
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   181
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   182
});</pre>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   183
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   184
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   185
<p>To dispatch YUI events (fired by the instance of the SWF Utility on the JavaScript end, you can call YUIBridge's <code>sendEvent</code> method:</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   186
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   187
<pre class="code prettyprint">import com.yahoo.util.YUIBridge
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   188
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   189
...
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   190
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   191
&#x2F;&#x2F; The scope for &#x27;this&#x27; should be either the top-level application
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   192
&#x2F;&#x2F; or a Sprite that has been placed on the stage.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   193
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   194
var yuiBridge:YUIBridge = new YUIBridge(this.stage);
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   195
yuiBridge.sendEvent({type:&#x27;someevent&#x27;, payload:&#x27;some payload&#x27;});
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   196
});</pre>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   197
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   198
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   199
<p>In addition to any custom events you dispatch, YUIBridge also fires a <code>swfReady</code> event at initialization time, announcing that the Flash player is ready for communication with JavaScript:</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   200
<pre class="code prettyprint">YUI({...}).use(&#x27;swf&#x27;,function (Y) {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   201
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   202
	var myswf = new Y.SWF(&quot;#swfContainer&quot;, &quot;http:&#x2F;&#x2F;example.com&#x2F;example.swf&quot;);
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   203
	myswf.on(&#x27;swfReady&#x27;, init);
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   204
	
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   205
	function init() {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   206
		&#x2F;&#x2F; Start communicating with the Flash player instance here
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   207
		myswf.callSWF(&quot;foo&quot;, [arg1, arg2]);
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   208
	}
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   209
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   210
});</pre>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   211
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   212
</div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   213
            </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   214
        </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   215
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   216
        <div class="yui3-u-1-4">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   217
            <div class="sidebar">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   218
                
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   219
                    <div id="toc" class="sidebox">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   220
                        <div class="hd">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   221
                            <h2 class="no-toc">Table of Contents</h2>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   222
                        </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   223
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   224
                        <div class="bd">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   225
                            <ul class="toc">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   226
<li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   227
<a href="#getting-started">Getting Started</a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   228
</li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   229
<li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   230
<a href="#using-the-swf-utility">Using the SWF Utility</a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   231
<ul class="toc">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   232
<li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   233
<a href="#anatomy-of-the-swf-utility">Anatomy of the SWF Utility</a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   234
</li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   235
<li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   236
<a href="#configuring-and-instantiating-the-swf-utility">Configuring and Instantiating the SWF Utility</a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   237
</li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   238
<li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   239
<a href="#calling-methods-on-the-instance-of-flash-player">Calling Methods on the instance of Flash player</a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   240
</li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   241
<li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   242
<a href="#working-with-the-yuibridge-actionscript-library">Working with the YUIBridge ActionScript Library</a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   243
</li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   244
</ul>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   245
</li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   246
</ul>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   247
                        </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   248
                    </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   249
                
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   250
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   251
                
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   252
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   253
                
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   254
            </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   255
        </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   256
    </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   257
</div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   258
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   259
<script src="../assets/vendor/prettify/prettify-min.js"></script>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   260
<script>prettyPrint();</script>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   261
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   262
<script>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   263
YUI.Env.Tests = {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   264
    examples: [],
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   265
    project: '../assets',
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   266
    assets: '../assets/swf',
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   267
    name: 'swf',
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   268
    title: 'SWF Utility',
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   269
    newWindow: '',
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   270
    auto:  false 
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   271
};
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   272
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   273
</script>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   274
<script src="../assets/yui/test-runner.js"></script>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   275
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   276
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   277
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   278
</body>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   279
</html>