如何从as3中的给定字符串中拆分数字?

时间:2012-05-08 10:29:37

标签: actionscript-3 flash actionscript

我创造了两个组合框。我必须创建一个匹配以下程序,以便

function changeHandler(e:Event)
{
    trace(ComboBox(e.target).selectedItem.label+ComboBox(a1).selectedItem.label);
}

如果e.target检索a1。我必须将其拆分为1

3 个答案:

答案 0 :(得分:0)

这确实有效

假设您的ComboBox实例名称为a0

import fl.controls.ComboBox;
a0.addEventListener(Event.CHANGE, changeHandler);
function changeHandler(e:Event) {
    trace(e.target.selectedItem.label);
    trace(e.target.selectedItem.label.substring(1));
}

答案 1 :(得分:0)

对于一般字符串"a1"

function changeHandler(e:Event)
{
    var tempStr:String = "a1";
    var intValue:int = int(tempStr.substr(1));
}


适用于ComboBox(e.target).selectedItem.label

 function changeHandler(e:Event)
    {
        var tempStr:String = ComboBox(e.target).selectedItem.label;
        var intValue:int = int(tempStr.substr(1));
    }

答案 2 :(得分:-2)

这里没有Flash,但我想你可以试试

trace(ComboBox(e.target).selectedItem.label+substring(1,ComboBox(a1).selectedItem.label));

有效吗?