暇だったのでデモを作ってみました。以下のリンクをチェックしてください。
デモ: http://ronnieswietek.com/_random/phone_nums.swf
ソース: http://ronnieswietek.com/_random/phone_nums.fla
以下のコードは少し肥大化しているかもしれませんが、これはデモ用です
import flash.events.MouseEvent;
import fl.controls.TextInput;
import flash.display.Sprite;
var lastY:Number = origPhoneField.y;
var fieldHolder:Sprite = new Sprite();
fieldHolder.x = origPhoneField.x;
fieldHolder.y = origPhoneField.y + 35;
addChild(fieldHolder);
function addPhoneField(e:MouseEvent):void
{
//-- clicking the plus icon will add a new custom text input
//-- its only custom because I added a minus button to it
var newInput:CustomTextInput = new CustomTextInput();
newInput.y = (fieldHolder.numChildren > 0) ? fieldHolder.height + 5 : 0;
fieldHolder.addChild(newInput);
newInput.minusBtn.addEventListener(MouseEvent.CLICK, removePhoneField);
}
addBtn.addEventListener(MouseEvent.CLICK, addPhoneField);
function removePhoneField(e:MouseEvent):void
{
//-- clicking the minus will remove the movie clip and reposition the other fields vertically
fieldHolder.removeChild(e.target.parent);
for (var i:int = 0; i < fieldHolder.numChildren; i++)
{
var target = fieldHolder.getChildAt(i);
target.y = (i * 35);
}
}
function showNumbers(e:MouseEvent):void
{
//-- for demo purposes, this will output all the values
outputWin.text += origPhoneField.text + "\n";
for (var i:int = 0; i < fieldHolder.numChildren; i++)
{
var target = fieldHolder.getChildAt(i);
outputWin.text += target.theField.text + "\n";
}
outputWin.text += "================\n";
}
showNums.addEventListener(MouseEvent.CLICK, showNumbers);