首页 > 开发 > Flex > 正文

Flex dynamic 关键字的用法

2024-09-12 17:51:10
字体:
来源:转载
供稿:网友
EmployeeRecord.as
复制代码 代码如下:

package empty
{
public dynamic class EmployeeRecord
{
}
}

EmptyClass.mxml
复制代码 代码如下:

<?xml version="1.0" encoding="utf-8"?>

<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"

viewSourceURL=""
horizontalAlign="center" verticalAlign="middle"
width="100%" height="100%"
>
<mx:Script>
<!--[CDATA[
import empty.EmployeeRecord;
private function showProperties():void
{
var emp:EmployeeRecord = new EmployeeRecord();
emp.name = "Peter Griffen";
emp.age = 22;
emp.address = "123 St Peter Blvd, #552";
emp.city = "Quahog";
emp.state = "NY";
emp.zip = "02593";

var displayInfo:Function =
function ():String
{
var out:String;
out = "Employee Record:/n";
out += "Name: " + emp.name + "/n";
out += "Age: " + emp.age + "/n";
out += "Address: " + emp.address + "/n";
out += "City: " + emp.city + "/n";
out += "State: " + emp.state + "/n";
out += "Zip: " + emp.zip + "/n";

return out;
}

emp.displayRecord = displayInfo;
panelPropertyArea.text = emp.displayRecord();
}
]]-->
</mx:Script>
<mx:Panel id="panel" title="A Simple Use of Package" status="Active"
height="75%" width="75%"
paddingTop="5" paddingLeft="5" paddingRight="5" paddingBottom="5">
<mx:Label width="100%" color="blue"
text="Program Execution Result: "/>
<mx:TextArea id="panelPropertyArea" width="100%" height="100%"/>
<mx:Button label="Click to Run Program" click="showProperties();"/>
</mx:Panel>
</mx:Application>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表