Frage

I've got a movie clip with an instance name of 'location_mc' in which there is a single classic static text field.

I want to change the value of this field.

So far i've attempted searching for the instance by name using findObjectInDocByName and then setTextString of the nested text box however this is setting the value of a text field, parent to the movieclip i searched for by instance name?

How can I change the text value of a field nested inside: movieclip(no instance name)>movieclip(instance name 'location_mc')>classic static text field on layer 0, frame 0 (only element in this movieclip)?

Code so far:

var nameToSearchFor = "location_mc"; 
var doc = fl.getDocumentDOM(); 
var results = fl.findObjectInDocByName(nameToSearchFor, doc); 
if (results.length > 0) { 
    var firstItem = results[0];

    var childTimeline = firstItem.timeline;
    var textinput = childTimeline.layers[0].frames[0].elements[0];
    var txtValue = textinput.setTextString('hello world');
} 
else {  
    alert("failed, no objects named " + nameToSearchFor + " found"); 
}
War es hilfreich?

Lösung

This should do the trick:

var nameToSearchFor = "location_mc"; 
var doc = fl.getDocumentDOM(); 
var results = fl.findObjectInDocByName(nameToSearchFor, doc); 
if (results.length > 0) { 
    var firstItem = results[0].obj.libraryItem;
    var childTimeline = firstItem.timeline;
    childTimeline.layers[0].frames[0].elements[0].setTextString('hello world');
} 
else {  
    alert("failed, no objects named " + nameToSearchFor + " found"); 
}

Accessing child/nested movie clips with JSFL AS3 CS5.5

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top