myFunctions.as文件
public function textMerge(input1:String, input2:String):String{
var res:String = input1 + input2;
return res;
}
mxml文件
<?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/mx" minWidth="955" minHeight="600">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<fx:Script source="myFunctionAddTwoString.as"/>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
]]>
</fx:Script>
<s:Group>
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<s:TextInput id="value1"/>
<mx:Label text="and"/>
<s:TextInput id="value2"/>
<s:Button label="Join the two" click="Alert.show(textMerge(value1.text,value2.text))"/>
</s:Group>
</s:Application>
运行结果:
shift + f2 打开flash builer 的API页面
将href=#是指联接到当前页面,其实是无意义的,页面也不会刷新