views:

413

answers:

3

How can I set the font used by the FLVPlaybackCaptioning component for subtitles? Using the style property of the textarea does nothing, and using a TextFormat makes the text go blank, even though the font had been embedded.

+1  A: 

It seems the font, as well as the other properties of the text, are specified in the XML file where the subtitles are read (this is from the documentation):

<?xml version="1.0" encoding="UTF-8"?>
  <tt xml:lang="en" xmlns="http://www.w3.org/2006/04/ttaf1"  xmlns:tts="http://www.w3.org/2006/04/ttaf1#styling"&gt;
      <head>
          <styling>
              <style id="1" tts:textAlign="right"/>
              <style id="2" tts:color="transparent"/>
              <style id="3" style="2" tts:backgroundColor="white"/>
              <style id="4" style="2 3" tts:fontSize="20"/>
          </styling>
      </head>
      <body>
           <div xml:lang="en">
              <p begin="00:00:00.50" dur="500ms">Four score and twenty years ago</p>
              <p begin="00:00:02.50"><span tts:fontFamily="monospaceSansSerif,proportionalSerif,TheOther"tts:fontSize="+2">our forefathers</span> brought forth<br /> on this continent</p>
              <p begin="00:00:04.40" dur="10s" style="1">a <span tts:fontSize="12 px">new</span> <span tts:fontSize="300%">nation</span></p>
              <p begin="00:00:06.50" dur="3">conceived in <span tts:fontWeight="bold" tts:color="#ccc333">liberty</span> <span tts:color="#ccc333">and dedicated to</span> the proposition</p>
              <p begin="00:00:11.50" tts:textAlign="right">that <span tts:fontStyle="italic">all</span> men are created equal.</p>
     <p begin="15s" style="4">The end.</p>
          </div>    
      </body>
  </tt>

So maybe the component doesn't want you overriding those?

hasseg
+1  A: 

t seems the font, as well as the other properties of the text, are specified in the XML file where the subtitles are read

That might well be, but what if you are using an flv that has had its captions added using captionate and there is no xml files involved in the whole set up? I too am looking for a solution to this. Any idea appreciated, Thanks

+1  A: 

//Create a listener for your FLVPlaybackCaptioning instance, listening for the creation of the textfield/target eg.

myFLVPlybkcap.addEventListener(CaptionTargetEvent.CAPTION_TARGET_CREATED, captionTargetCreatedHandler);

//Then when that occurs, set the 'defaultTextFormat' of the textfield to your own...

private function captionTargetCreatedHandler(e:CaptionTargetEvent):void{
  var myTextFormat:TextFormat = new TextFormat();
  myTextFormat.font = "Arial";
  myTextFormat.color = 0x00FF00;
  myTextFormat.size = 18;
  (e.captionTarget as TextField).defaultTextFormat = myTextFormat; 
}
Trevor Boyle