---
title: "Flex中的类型转换"
author: "gzd3618"
date: "2009-08-19T17:22:54Z"
tags: ["Flex", "XML"]
slug: "flex"
draft: false
lastmod: "2009-08-21T08:31:52Z"
id: 453021
url: "https://gzd3618.iteye.com/blog/453021"
---

```xml
<local:Finance id="finance" fid="{finance.fid}" month="{month.text}" income="{Number(income.text)}" overhead="{Number(overhead.text)}"/>
  
  <mx:RemoteObject id="f" destination="service" result="resultShow(event)" fault="faultShow(event)">
  </mx:RemoteObject>
  
  <mx:Canvas width="100%" height="100%">
	<mx:Form x="68.5" y="33" height="160">
		<mx:FormItem label="编号">
			<mx:TextInput id="fid" text="{finance.fid}" editable="false"/>
		</mx:FormItem>
		<mx:FormItem label="月份">
			<mx:TextInput id="month" text="{finance.month}"/>
		</mx:FormItem>
		<mx:FormItem label="收入">
			<mx:TextInput id="income" text="{finance.income}"/>
		</mx:FormItem>
		<mx:FormItem label="支出">
			<mx:TextInput id="overhead" text="{finance.overhead}"/>
		</mx:FormItem>
	</mx:Form>
	<mx:ControlBar x="229.5" y="181">
	    <mx:Button label="更新" click="f.update(finance)"/>
	</mx:ControlBar>
  </mx:Canvas>  
```


**说明：local:Finance 是个model对象。 其中income和overhead 是其中的两个Nubner类型的属性。
income.text 从TextInput标签中获得的是String类型。
将string类型转换成Number类型 

Number(income.text)}

var s:Number = "3" as Number 
**