Вопрос

I need basically a way to convert a group of selected text in movieclips separately with Flash commands. For example, I know to select just text items in the stage is:

var theSelectionArray = fl.getDocumentDOM().selection;

for(var i = 0; i < theSelectionArray.length; i++){

    if(theSelectionArray[i].elementType == "text"){
       ...    
    }
}

And I know to convert a selection in a movieclip is:

fl.getDocumentDOM().convertToSymbol("movie clip", theName, "top left");

So I need to know the way to loop over the stage and convert each text field in a movieclip.

Thanks.

Это было полезно?

Решение

Why don't you select all the objects and iterate over them as in your example?

var startIndex = prompt("Please enter the start index", "0");
if (startIndex == null || startIndex.length == 0) {
    startIndex = 0;
};
startIndex = parseInt(startIndex); // Just to be on the safe side.

fl.getDocumentDOM().selectAll();
var theSelectionArray = fl.getDocumentDOM().selection;
for(var i = 0; i < theSelectionArray.length; i++){
    if(theSelectionArray[i].elementType == "text") {
        fl.getDocumentDOM().selectNone();
        fl.getDocumentDOM().selection = [theSelectionArray[i]];
        fl.getDocumentDOM().convertToSymbol("movie clip", "textfield" + startIndex, "top left");
        startIndex++;
    }
}  

Edited: the code above works now. (with a start index.)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top