- <mx:Application xmlns:mx=‘http://www.macromedia.com/2003/mxml‘>
- <
mx:Panel title=‘My Application‘ >
- <
mx:HBox>
- <
mx:Label text=‘Temperature in Farenheit:‘/>
- <
mx:TextInput id=‘farenheit‘ width=‘120‘/>
- <
mx:Button label=‘Convert‘ click=‘celsius.text=(farenheit.text-32)/1.8;‘ />
- <
mx:Label text=‘Temperature in Celsius:‘/>
- <
mx:Label id=‘celsius‘ width=‘120‘ fontSize=‘48‘/>
- </
mx:HBox>
- </
mx:Panel>
- </
mx:Application>
- <mx:Application xmlns:mx=‘http://www.macromedia.com/2003/mxml‘>
- <
mx:Script>
- <![
CDATA[
- function
calculate() {
celsius.text=(farenheit.text-32)/1.8;
- }
- ]]>
- </
mx:Script>
- <
mx:Panel title=‘My Application‘ >
- <
mx:HBox>
- <
mx:Label text=‘Temperature in Farenheit:‘/>
- <
mx:TextInput id=‘farenheit‘ width=‘120‘/>
- <
mx:Button label=‘Convert‘ click=‘calculate();‘ />
- <
mx:Label text=‘Temperature in Celsius:‘/>
- <
mx:Label id=‘celsius‘ width=‘120‘ fontSize=‘48‘/>
- </
mx:HBox>
- </
mx:Panel>
- </
mx:Application>
- <mx:Application xmlns:mx=‘http://www.macromedia.com/2003/mxml‘>
- <!--
Specify the ActionScript file containing the function. -->
- <
mx:Script source=‘sample3script.as‘/>
- <
mx:Panel title=‘My Application‘ >
- <
mx:HBox>
- <
mx:Label text=‘Temperature in Farenheit:‘/>
- <
mx:TextInput id=‘farenheit‘ width=‘120‘/>
- <
mx:Button label=‘Convert‘ click=‘calculate();‘ />
- <
mx:Label text=‘Temperature in Celsius:‘/>
- <
mx:Label id=‘celsius‘ width=‘120‘ fontSize=‘48‘/>
- </
mx:HBox>
- </
mx:Panel>
- </
mx:Application>
- function calculate() {
celsius.text=(farenheit.text-32)/1.8;
- }
- <mx:Application xmlns:mx=‘http://www.macromedia.com/2003/mxml‘
initialize=‘converter.setupListener()‘>
- <
local:TempConverter id=‘converter‘ xmlns:local=‘*‘/>
- <
mx:Panel title=‘My Application‘ >
- <
mx:HBox>
- <
mx:Label text=‘Temperature in Farenheit:‘ />
- <
mx:TextInput id=‘farenheit‘ width=‘120‘ />
- <
mx:Button id=‘myButton‘ label=‘Convert‘ />
- <
mx:Label text=‘Temperature in Celsius:‘ />
- <
mx:Label id=‘celsius‘ width=‘120‘ fontSize=‘24‘ />
- </
mx:HBox>
- </
mx:Panel>
- </
mx:Application>
- class TempConverter implements mx.core.MXMLObject{
public var view;
- function
initialized(doc : Object, id : String) : Void {
view = doc;
- }
- function
setupListener() : Void {
view.myButton.addEventListener(‘click‘, this);
- }
- function
click(event) {
view.celsius.text=(view.farenheit.text-32)/1.8;
- }
- }
联系客服