Skip navigation
Currently Being Moderated

Dynamically change text during narration

Jul 11, 2011 8:06 AM

Hi!

 

I've got a file that contains narration. The content appears progressively on the stage as narration plays.

 

On the first frame I added a dynamic textfield, which I called : soustitrage_txt (would be "caption_txt" in English).

 

On another layer, on the same frame I added this code :

 

soustitrage_txt.html = true;
soustitrage_txt.autoSize = "left";
soustitrage_txt.selectable = true;
soustitrage_txt.multiline = true;
soustitrage_txt.wordWrap = true;

 

var txtFormat:TextFormat = new TextFormat();
txtFormat.size = 20;
txtFormat.font = "Arial";

txtFormat.bold= true;

//I exagerated the value, to be sure it's really not working...


_global.myData = new LoadVars();
_global.myData.load("p1.txt");

_global.myData.onLoad = function() {
      soustitrage_txt.setTextFormat(txtFormat);
};

 

 

I need to make appear the first sentence around the frame 115, in which I entered this code on my "action layer" :

 

soustitrage_txt.text = _global.myData.phrase1;

 

One positive point, the text appears (yay!) but the negative point is that the formatting doesn't work...

 

Finally, when I want to switch to the next phrase, around frame 195, I enter the same code (with only a different variable name to call) :

 

soustitrage_txt.text = _global.myData.phrase2;

 

And now it shows me "undefined"... :/

 

Here's a preview of my external text file (I translated it...since it's in French normally) :

 

phrase1=Hello and welcome to this guide that will show you how to adjust your workstation step by step.&
phrase2=Adjusting your workstation properly will prevent you from having any discomfort that may result from bad posture or improper adjustment.&

phrase3=...&

(and so on...)

 

Thanks a lot!

 

Geneviève

 
Replies
  • Currently Being Moderated
    Jul 11, 2011 8:27 AM   in reply to jacquesge

    If you are placing those ampersands at the end followed by a carriage return as you seem to be per what you posted, don't do that. Keep them adjacent to variables they are defining.

     

    phrase1=Hello and welcome to this guide that will show you how to adjust your workstation step by step.

    &phrase2=Adjusting your workstation properly will prevent you from having any discomfort that may result from bad posture or improper adjustment.

    &phrase3=...

    &

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 11, 2011 8:58 AM   in reply to jacquesge

    You need to set the textformat after you assign the text, not before.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points