易截截图软件、单文件、免安装、纯绿色、仅160KB

Flex与JavaScript的交互

Flex 与 JavaScript 交互,主要依靠Flex的ExternalInterface,其提供了addCallBack和call方法.
下面的例子将演示Flex调用javascript,和javascript调用Flex。
js 代码
-------------------------------------------------------------------------------------------------------------
function hello(param) {
alert(param);
return "jsp Hello:" + param;
}

function callFlexFunction() {
var x = document.getElementById("flexObject").flexHelloWorld("Hello", "world");
alert(x);

  
html代码
--------------------------------------------------------------------------------------------------------------
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553537800"
width="640" height="378" id="flexObject">
<param name="allowScriptAccess" value="always" />
<embed src="Test.swf" mce_src="Test.swf" width="640" height="378"
name ="flexObject" play="true" loop="false"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>
</object> 
Flex 代码
--------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
initialize="initApp()">

<mx:Script>
<![CDATA
import mx.controls.Alert;

public function flexHelloWorld(param1:String, param2:String):String {
Alert.show("param1: " + param1 + "; param2:" + param2);
return "Hello " + param1 + param2;
}

public function initApp():void {
ExternalInterface.addCallback("flexHelloWorld", flexHelloWorld);
}

p


相关文档:

Flex 4 :使用 Halo 主题

此例展示了如何在 Flex 4 中为 Halo 控件设置旧的 Halo 皮肤,而不是新的 Spark 皮肤。
<?xml version="1.0" encoding="utf-8"?>
<!-- http://www.slsay.com/archives/131 -->
<s:Application name="Spark_Halo_theme_test"
       xmlns:fx="http://ns.adobe.com/mxml/2009"
&nbs ......

Flex通过HTTPService与servlet通信

flex代码:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768">
<fx:Script>
<!--[CDATA[
i ......

Asp.net中自定义控件引用javascript中的日历脚本心得


自定义控件中的页面代码:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="wcontrol.ascx.cs" Inherits="wcontrol" %>
<script type ="text/javascript">
function PopupCalendar(InstanceName)
{
///Global Tag
this.instanceName=InstanceName;
///Properties
this.separator="-"
t ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号