【问题标题】:Flex: Number input with buttonsFlex:带按钮的数字输入
【发布时间】:2015-10-31 00:26:27
【问题描述】:

我正在尝试使用按钮进行文本输入,但到目前为止我只能让它输入一个数字。 (如果我单击另一个按钮进行第二个输入,它会删除第一个输入。)有没有办法解决这个问题?

我在此处添加了我的代码和一张图片以显示我正在尝试制作的内容。

非常感谢您的帮助!

<mx:Button x="18" y="116" label="1" width="20" height="20" fontSize="7" click="one(event)"/>
<mx:Button x="37" y="116" label="2" width="20" height="20" fontSize="7" click="two(event)"/>
<mx:Button x="56" y="116" label="3" width="20" height="20" fontSize="7" click="three(event)"/>
<mx:Button x="18" y="135" label="4" width="20" height="20" fontSize="7" click="four(event)"/>
<mx:Button x="37" y="135" label="5" width="20" height="20" fontSize="7" click="five(event)"/>
<mx:Button x="56" y="135" label="6" width="20" height="20" fontSize="7" click="six(event)"/>
<mx:Button x="18" y="154" label="7" width="20" height="20" fontSize="7" click="seven(event)"/>
<mx:Button x="37" y="154" label="8" width="20" height="20" fontSize="7" click="eight(event)"/>
<mx:Button x="56" y="154" label="9" width="20" height="20" fontSize="7" click="nine(event)"/>
<mx:Button x="18" y="173" label="x" width="20" height="20" fontSize="7" click="erase(event)"/>
<mx:Button x="37" y="173" label="0" width="20" height="20" fontSize="7" click="zero(event)"/>
<mx:Button x="56" y="173" width="20" height="20" label="ent" fontSize="7" click="ent(event)"/>

public function one(event:MouseEvent):void {
        numberCopies.text = "1";
    }
    public function two(event:MouseEvent):void {
        numberCopies.text = "2";
    }

...

image

【问题讨论】:

    标签: apache-flex button text textinput


    【解决方案1】:
    <?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" >
    
        <fx:Script>
            <![CDATA[
    
                [Bindable] public var copies:String = "";
    
                public function one(event:MouseEvent):void {
                    copies += "1";
                }
                public function two(event:MouseEvent):void {
                    copies += "2";
                }
    
            ]]>
        </fx:Script>
        <s:Label id="numberCopies" text="{copies}"/>
        <mx:Button x="18" y="116" label="1" width="20" height="20" fontSize="7" click="one(event)"/>
        <mx:Button x="37" y="116" label="2" width="20" height="20" fontSize="7" click="two(event)"/>
    
    
    </s:Application>
    

    【讨论】:

      猜你喜欢
      • 2020-12-03
      • 2012-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多