Question

J'ai besoin d'un moyen de convertir séparément un groupe de texte sélectionné dans MovieClips avec des commandes flash. Par exemple, je sais sélectionner uniquement les éléments de texte dans la scène est:

var theSelectionArray = fl.getDocumentDOM().selection;

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

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

Et je sais convertir une sélection dans un movielip est:

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

J'ai donc besoin de savoir le moyen de boucler sur la scène et de convertir chaque champ de texte dans un movieclip.

Merci.

Était-ce utile?

La solution

Pourquoi ne sélectionnez-vous pas tous les objets et ne les itérez-vous pas comme dans votre exemple?

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++;
    }
}  

Édité: le code ci-dessus fonctionne maintenant. (avec un index de démarrage.)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top