Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSFL - Change Static Text value

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"); 
}
like image 304
dg85 Avatar asked Aug 27 '26 07:08

dg85


1 Answers

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

like image 93
null.point3r Avatar answered Aug 30 '26 07:08

null.point3r



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!