Reputation: 186762
I am not a flash developer, but I am debugging an issue where the copy/text is not rightly assigned.
In the .as
file, the headings and subheadings are assigned and work:
195 body.heading.htmlText = heading;
196 body.sectionheading.htmlText = nav_name;
197 body.subheading.htmlText = subheading;
198 body.subheading.htmlText = 'testtt';
However, the main body copy does not:
180 body.textholder.myText.htmlText = 'mederTest';
Is there some way I could find out all text areas ( anything that has an assignable htmlText
) programmatically? In Flash itself I can't seem to select the heading/subheading objects themselves, as they dont appear to be in the canvas? They appear hidden.
Edit: I'm on my 24th swf of debugging. I have finally found the actual text that needs to be updated.
428 var bodyClip:MovieClip = eval("bodyparts.bodycontent_"+tmpclipname.id+"_0");
429 ExternalInterface.call( "console.log" , bodyClip )
430 for ( var p in bodyClip ) {
431 ExternalInterface.call( "console.log" , p )
432 ExternalInterface.call( "console.log" , bodyClip[p] )
433 ExternalInterface.call( "console.log" , bodyClip[p] )
434 for ( var thing in bodyClip[p] ) {
435 if ( thing === 'htmlText' ) {
436 ExternalInterface.call( "console.log" , 'OMG' );
437 ExternalInterface.call( "console.log" , bodyClip[p][thing] )
438 }
439
440 if ( thing === 'myText' ) {
441 ExternalInterface.call( "console.log" , 'SUPEROMG' );
442 ExternalInterface.call( "console.log" , bodyClip[p][thing]['htmlText'] )
443 }
444 ExternalInterface.call( "console.log" , thing )
445 }
446 }
It drills down and when bodyClip has an instance with a 'myText' property, THATS the thing I want to update.
Why doesn't this line update it?
body.textholder.myText.htmlText = 'mederTest';
Programmatically speaking, it could only be because I'm possibly referencing the wrong object/instance, no? The .as
file does not contain a reference to body
.
I can only assume it was define in the first .as
file or its a global object. Can anyone lend me a hand?
Upvotes: 0
Views: 212
Reputation: 1025
Are you trying to amend the text from within your if statement when you discover it? Or somewhere else?
if ( thing === 'myText' ) {
bodyClip[p][thing]['htmlText'] = "mederTest"
}
.. because its possible the TextField doesn't exist when you are trying to alter it. If the playhead is not on a frame which contains the TextField, the TextField doesn't exist.
Another suggestion is to change the _alpha of the Textfield to make sure you are working on the correct Textfield?
Upvotes: 0
Reputation: 8053
As well as TextFields, there's also StaticText which is the object that gets exported if we put a normal TextField down in Flash and it's not dynamic.
It's possible that the textfield you're looking for is this type, in which case, you won't be able to set the text.
For a truly hack-tastic response though, if you can't re-edit this TextField and make it dynamic, then one solution would be to dynamically create a new TextField. Copy the width, height, font, colour etc of the old one. Either set the background property to true, or set the old TextField's visible property to false. Now add your new TextField as a child of the parent of the old TextField, just above it. Edit the text as you please :D
Upvotes: 0
Reputation: 2013
You can walk the display list, looking for objects of type TextField:
function findTextFields(container:DisplayObjectContainer):Array
{
var result:Array = [];
// Examine each child of the container
for(var i:int = 0; i < container.numChildren; i++)
{
var obj:DisplayObject = container.getChildAt(i);
// If the child is a TextField, add it to the result array
if(obj is TextField)
result.push(obj);
// If the child is a DisplayObjectContainer, recurse on it
var c:DisplayObjectContainer = obj as DisplayObjectContainer;
if(c !== null)
result.concat(findTextFields(c));
}
return result;
}
Upvotes: 1