<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>雪道屋 &#124; Snow on rails blog &#187; javascript</title>
	<atom:link href="http://blog.snowonrails.com/tags/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.snowonrails.com</link>
	<description>life.each{&#124;day&#124; day.live_well!}</description>
	<lastBuildDate>Thu, 11 Feb 2010 07:03:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9-rare</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Let Javascript and ActionScript talk to each other</title>
		<link>http://blog.snowonrails.com/2007/05/08/let-javascript-and-actionscript-talk-to-each-other/</link>
		<comments>http://blog.snowonrails.com/2007/05/08/let-javascript-and-actionscript-talk-to-each-other/#comments</comments>
		<pubDate>Tue, 08 May 2007 14:29:00 +0000</pubDate>
		<dc:creator>snow</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[ExternalInterface]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">urn:uuid:c5a91810-06e6-4ecb-b689-9685cb07a4e1</guid>
		<description><![CDATA[flash.external.ExternalInterface is  the External API that enables the communication between actionscript and flash player container. It enables the communication between javascript and actionscript.
From ActionScript, you can do the following on the HTML page:
    * Call any JavaScript function.
    * Pass any number of arguments, with any names.
  [...]]]></description>
			<content:encoded><![CDATA[<p>flash.external.ExternalInterface is  the External <span class="caps">API</span> that enables the communication between actionscript and flash player container. It enables the communication between javascript and actionscript.</p>
<p>From ActionScript, you can do the following on the <span class="caps">HTML</span> page:<br />
    * Call any JavaScript function.<br />
    * Pass any number of arguments, with any names.<br />
    * Pass various data types (Boolean, Number, String, and so on).<br />
    * Receive a return value from the JavaScript function.</p>
<p>From JavaScript on the <span class="caps">HTML</span> page, you can:</p>
<ul>
<li>Call an ActionScript function.</li>
<li>Pass arguments using standard function call notation.</li>
<li>Return a value to the JavaScript function.</li>
</ul>
<p>Here is how to access javascript functions from flash or flex file:</p>
<div class="typocode">
<pre><code class="typocode_xml ">
flash.external.ExternalInterface.call(function_name:
    String[, arg1, ...]):Object;</code></pre>
</div>
<p>The function_name is the name of the function in the <span class="caps">HTML</span> page&#8217;s JavaScript. The arguments are the arguments that you pass to the JavaScript function. You can pass one or more arguments in the traditional way of separating them with commas, or you can pass an object that is deserialized by the browser. The arguments are optional.</p>
<p>Here is how to access flash or flex functions from javascript:</p>
<p>In your Flex application, you add a local Flex function to the list by using the addCallback() method of the ExternalInterface <span class="caps">API</span>. This method registers an ActionScript method as callable from the JavaScript or VBScript in the wrapper.</p>
<p>Javascript code likes this:</p>
<div class="typocode">
<pre><code class="typocode_default ">
$('flash_object_id').as_method();  // this will invoke the method called &quot;as_method&quot; in flash or flex file</code></pre>
</div>
<p>But, in order to make the above code to work correctly, you have to add following as code in flash or flex:</p>
<div class="typocode">
<pre><code class="typocode_default ">flash.external.ExternalInterface.addCallback('as_method', instance, method_define_in_as):Boolean (ActionScript 2.0)
flash.external.ExternalInterface.addCallback('as_method', method_define_in_as):Void(ActionScript 3.0) </code></pre>
</div>
<p> Here are some examples for <a href="http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/js/html/wwhelp.htm">as 2.0</a> and <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/index.html">as 3.0</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.snowonrails.com/2007/05/08/let-javascript-and-actionscript-talk-to-each-other/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Event Delegation(bubbling)</title>
		<link>http://blog.snowonrails.com/2007/01/24/event-delegationbubbling/</link>
		<comments>http://blog.snowonrails.com/2007/01/24/event-delegationbubbling/#comments</comments>
		<pubDate>Wed, 24 Jan 2007 15:40:00 +0000</pubDate>
		<dc:creator>snow</dc:creator>
				<category><![CDATA[event]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">urn:uuid:8aa808a4-c16f-4b33-b4b3-07d02eb36239</guid>
		<description><![CDATA[&#26152;&#22825;&#22312;yahoo user interface blog &#30475;&#21040;&#20102;&#19968;&#29255;&#25991;&#31456; : Event Driven Web Application Design
&#22312;&#35835;&#21040;&#20851;&#20110;event delegation&#30340;&#26102;&#20505;,&#25105;&#34987;&#36825;&#20010;&#27010;&#24565;&#21560;&#24341;&#27880;&#20102;,&#20110;&#26159;&#36890;&#36807;&#36825;&#20010;&#22320;&#22336;&#30475;&#21040;&#20102;&#19968;&#31687;&#20851;&#20110;
event delegation vs event handling &#30340;&#25991;&#31456;, &#36825;&#31687;&#25991;&#31456;&#23558;event delegation&#30340;&#27010;&#24565;&#35762;&#30340;&#27604;&#36739;&#35814;&#32454;&#20102;,
&#19981;&#36807;&#36824;&#26159;&#22312;&#33258;&#24049;&#21160;&#25163;&#20889;&#30340;&#20195;&#30721;&#20043;&#21518;&#25165;&#30495;&#27491;&#26126;&#30333;&#20102;&#26159;&#24590;&#20040;&#19968;&#22238;&#20107;,&#30475;&#30475;&#25105;&#20889;&#30340;&#36825;&#20010;&#38750;&#24120;&#31616;&#21333;&#30340;&#20363;&#23376;&#21543;

&#60;html&#62;
&#60;head&#62;

&#60;script src=&#34;prototype.js&#34;&#62;&#60;/script&#62;
&#60;script&#62;
function containerHandler(e){
alert(&#34;target:&#34;+e.target.id+&#34;---currentTarget:&#34;+e.currentTarget.id+&#34;---bubbles:&#34;+e.bubbles) ;
}

&#60;/script&#62;
&#60;/head&#62;

&#60;body&#62;
&#60;div id=&#34;container&#34;&#62;
&#60;ul id=&#34;list&#34;&#62;
&#60;li id=&#34;li-1&#34;&#62;List Item 1&#60;/li&#62;
&#60;li id=&#34;li-2&#34;&#62;List Item 2&#60;/li&#62;

&#60;li id=&#34;li-3&#34;&#62;List Item 3&#60;/li&#62;
&#60;li id=&#34;li-4&#34;&#62;List Item 4&#60;/li&#62;
&#60;li id=&#34;li-5&#34;&#62;List Item 5&#60;/li&#62;

&#60;li id=&#34;li-6&#34;&#62;List Item 6&#60;/li&#62;
&#60;/ul&#62;
&#60;/div&#62;
&#60;/body&#62;
&#60;script&#62;
Event.observe($('container'),'click',containerHandler,false);
&#60;/script&#62;
&#60;/html&#62;


Event&#23545;&#35937;&#26377;&#20960;&#20010;&#27604;&#36739;&#37325;&#35201;&#30340;&#23646;&#24615;,&#20063;&#23601;&#26159;&#25105;&#20204;alert&#20986;&#26469;&#30340;&#37027;&#20960;&#20010;,&#20854;&#20013;target&#34920;&#31034;&#35302;&#21457;&#20107;&#20214;&#30340;&#20803;&#32032;,currentTarget&#34920;&#31034;&#30417;&#21548;&#20107;&#20214;&#30340;&#20803;&#32032;,bubbles&#34920;&#31034;&#26102;&#38388;&#26159;&#21542;&#21521;&#22806;&#23618;&#20256;&#25773;. &#20045;&#30475;&#19978;&#21435;target&#21644;currentTarget&#38750;&#24120;&#23481;&#26131;&#28151;&#28102;,&#19981;&#36807;&#35753;&#25105;&#20204;&#30475;&#30475;event bubble&#30340;&#27010;&#24565;&#21487;&#33021;&#23601;&#20250;&#26356;&#28165;&#26970;&#19968;&#20123;.
&#8230;In essence this means that whenever you do something to an  [...]]]></description>
			<content:encoded><![CDATA[<p>&#26152;&#22825;&#22312;yahoo user interface blog &#30475;&#21040;&#20102;&#19968;&#29255;&#25991;&#31456; : <a href="http://yuiblog.com/blog/2007/01/17/event-plan/">Event Driven Web Application Design</a></p>
<p>&#22312;&#35835;&#21040;&#20851;&#20110;event delegation&#30340;&#26102;&#20505;,&#25105;&#34987;&#36825;&#20010;&#27010;&#24565;&#21560;&#24341;&#27880;&#20102;,&#20110;&#26159;&#36890;&#36807;<a href="http://icant.co.uk/sandbox/eventdelegation/">&#36825;&#20010;&#22320;&#22336;</a>&#30475;&#21040;&#20102;&#19968;&#31687;&#20851;&#20110;<br />
event delegation vs event handling &#30340;&#25991;&#31456;, &#36825;&#31687;&#25991;&#31456;&#23558;event delegation&#30340;&#27010;&#24565;&#35762;&#30340;&#27604;&#36739;&#35814;&#32454;&#20102;,<br />
&#19981;&#36807;&#36824;&#26159;&#22312;&#33258;&#24049;&#21160;&#25163;&#20889;&#30340;&#20195;&#30721;&#20043;&#21518;&#25165;&#30495;&#27491;&#26126;&#30333;&#20102;&#26159;&#24590;&#20040;&#19968;&#22238;&#20107;,&#30475;&#30475;&#25105;&#20889;&#30340;&#36825;&#20010;&#38750;&#24120;&#31616;&#21333;&#30340;&#20363;&#23376;&#21543;
<div class="typocode">
<pre><code class="typocode_default ">&lt;html&gt;
&lt;head&gt;

&lt;script src=&quot;prototype.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;
function containerHandler(e){
alert(&quot;target:&quot;+e.target.id+&quot;---currentTarget:&quot;+e.currentTarget.id+&quot;---bubbles:&quot;+e.bubbles) ;
}

&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;div id=&quot;container&quot;&gt;
&lt;ul id=&quot;list&quot;&gt;
&lt;li id=&quot;li-1&quot;&gt;List Item 1&lt;/li&gt;
&lt;li id=&quot;li-2&quot;&gt;List Item 2&lt;/li&gt;

&lt;li id=&quot;li-3&quot;&gt;List Item 3&lt;/li&gt;
&lt;li id=&quot;li-4&quot;&gt;List Item 4&lt;/li&gt;
&lt;li id=&quot;li-5&quot;&gt;List Item 5&lt;/li&gt;

&lt;li id=&quot;li-6&quot;&gt;List Item 6&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;script&gt;
Event.observe($('container'),'click',containerHandler,false);
&lt;/script&gt;
&lt;/html&gt;</code></pre>
</div>
<p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_iqOpK1FJhno/Rba7PbRDEjI/AAAAAAAAAAM/1XnLRHkuAr4/s1600-h/alert.PNG"><img style="cursor: pointer; width: 320px; height: 242px;" src="http://bp0.blogger.com/_iqOpK1FJhno/Rba7PbRDEjI/AAAAAAAAAAM/1XnLRHkuAr4/s320/alert.PNG" alt="" id="BLOGGER_PHOTO_ID_5023408308070060594" border="0" /></a><br />
Event&#23545;&#35937;&#26377;&#20960;&#20010;&#27604;&#36739;&#37325;&#35201;&#30340;&#23646;&#24615;,&#20063;&#23601;&#26159;&#25105;&#20204;alert&#20986;&#26469;&#30340;&#37027;&#20960;&#20010;,&#20854;&#20013;target&#34920;&#31034;&#35302;&#21457;&#20107;&#20214;&#30340;&#20803;&#32032;,currentTarget&#34920;&#31034;&#30417;&#21548;&#20107;&#20214;&#30340;&#20803;&#32032;,bubbles&#34920;&#31034;&#26102;&#38388;&#26159;&#21542;&#21521;&#22806;&#23618;&#20256;&#25773;. &#20045;&#30475;&#19978;&#21435;target&#21644;currentTarget&#38750;&#24120;&#23481;&#26131;&#28151;&#28102;,&#19981;&#36807;&#35753;&#25105;&#20204;&#30475;&#30475;event bubble&#30340;&#27010;&#24565;&#21487;&#33021;&#23601;&#20250;&#26356;&#28165;&#26970;&#19968;&#20123;.</p>
<blockquote><p>&#8230;In essence this means that whenever you do something to an  element in the page (like clicking it), this element gets very excited and talkative about it &#8211; especially to its parent elements. The link clicked in the example  will tell the LI it resides in, the UL it resides in and so on and so forth up  until the <span class="caps">BODY</span> of the document. And this is what you can use to your advantage; all you need to do is to set one event handler on a main element, and use the  getTarget() method of the library of your choice.</p></blockquote>
<p>&#37027;&#20040;&#25105;&#20204;&#20026;&#20160;&#20040;&#35201;&#20351;&#29992;&#36825;&#31181;&#26041;&#24335;&#21602;, &#20182;&#21644;event handling&#30340;&#26041;&#24335;&#21040;&#24213;&#26377;&#20160;&#20040;&#19981;&#21516;&#21602;?&#25105;&#33021;&#24819;&#21040;&#22914;&#19979;&#20960;&#28857;:</p>
<ul>
<li>event delegation&#30340;&#25928;&#29575;&#20250;&#26356;&#39640;&#20123;, &#23545;&#27604;&#20197;&#24448;&#24490;&#29615;&#28155;&#21152;listener &#30340;&#24773;&#20917;, &#21482;&#28155;&#21152;&#19968;&#20010;listener&#32943;&#23450;&#20250;&#26377;&#26356;&#39640;&#30340;&#25928;&#29575;&#21644;&#31616;&#27905;&#24615;.</li>
</ul>
<ul>
<li>&#35797;&#24819;&#36825;&#26679;&#30340;&#19968;&#20010;&#22330;&#26223;,&#25105;&#24076;&#26395;ul&#24403;&#20013;&#25152;&#26377;&#30340;li&#22312;&#34987;&#28857;&#20987;&#30340;&#26102;&#20505;&#37117;&#20250;&#35302;&#21457;&#19968;&#20010;&#20107;&#20214;,&#21516;&#26102;&#29992;&#25143;&#21487;&#20197;&#38543;&#26102;&#21521;ul&#24403;&#20013;&#28155;&#21152;&#26032;&#30340;li,&#26032;&#28155;&#21152;&#30340;li&#20063;&#20855;&#26377;&#22914;&#27492;&#30340;&#29305;&#24615;, &#22312;&#36825;&#20010;&#26102;&#20505;&#20256;&#32479;&#30340;&#24490;&#29615;&#28155;&#21152;listener&#30340;&#21150;&#27861;&#21487;&#33021;&#23601;&#19981;&#22826;&#22863;&#25928;&#20102;,&#32780;&#36825;&#26102;&#27491;&#22909;&#26102;event delegation &#25490;&#19978;&#29992;&#22330;&#30340;&#26102;&#20505;</li>
</ul>
<p>&#21333;&#21333;&#23601;&#26159;&#31532;&#20108;&#28857;&#25105;&#20204;&#24050;&#32463;&#26377;&#36275;&#22815;&#30340;&#29702;&#30001;&#20351;&#29992;event delegation&#20102;,&#22240;&#20026;&#22312;&#19968;&#20010;RIA&#24212;&#29992;&#24403;&#20013;,&#36825;&#26679;&#30340;&#38656;&#27714;&#26102;&#38750;&#24120;&#30340;&#24120;&#35265;&#30340;.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.snowonrails.com/2007/01/24/event-delegationbubbling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
