Skip to main content
Inspiring
July 29, 2010
Question

Trying to embed a VideoDisplay instance.

  • July 29, 2010
  • 1 reply
  • 2665 views

I dont know what else to do.  The video simply doesnt appear.  Any help is welcomed.

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                            xmlns:s="library://ns.adobe.com/flex/spark"
                            xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="windowedapplication1_creationCompleteHandler(event)">
     
     <fx:Script>
          <![CDATA[
               import flashx.textLayout.container.ContainerController;
               import flashx.textLayout.conversion.TextConverter;
               import flashx.textLayout.elements.InlineGraphicElement;
               import flashx.textLayout.elements.ParagraphElement;
               import flashx.textLayout.elements.TextFlow;
               import flashx.textLayout.events.StatusChangeEvent;
               
               import mx.events.FlexEvent;
               
               import spark.components.VideoDisplay;
               
               private var container:ContainerController;
               private var textFlow:TextFlow;

               
               private function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
               {
                    textFlow = TextConverter.importToFlow("Here is a video.", TextConverter.PLAIN_TEXT_FORMAT);
                    container = new ContainerController(new Sprite(), 575, 600);
                    textFlow.flowComposer.addController(container);
                    
                    textFlow.addEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE, onInlineHandler);
                    
                    var p:ParagraphElement = new ParagraphElement();
                    var inlineGraphicElement:InlineGraphicElement = new InlineGraphicElement();
                    
                    // add the video
                    var vp:VideoDisplay = new VideoDisplay();
                    vp.width      = 200;
                    vp.height      = 150;
                    vp.loop      = true;
                    vp.autoPlay = true;
                    vp.visible      = true;
                    vp.source      = "http://www.blamogames.com/SC2/hydra.f4v";
                    inlineGraphicElement.source = vp;
                    p.addChild(inlineGraphicElement);
                    
                    // add paragraph to text flow and update controller to display
                    textFlow.addChild(p);
                    
                    sve.addChild(container.container);
                    
                    textFlow.flowComposer.updateAllControllers();
               }
               
               protected function onInlineHandler(event:StatusChangeEvent):void
               {
                    trace(event.type);
                    label.text = event.type;
                    textFlow.flowComposer.updateAllControllers();
               }
          ]]>
     </fx:Script>
     
     <s:SpriteVisualElement id="sve" />
     
     <s:Label id="label" y="200"/>

</s:WindowedApplication>

This topic has been closed for replies.

1 reply

Adobe Employee
July 30, 2010

Flex components cannot be used in an InlineGraphicElement.  They need to be parented by other Flex components.

I don't have a good solution that gets you the power of the VideoDisplay.  You can certainly set the source of the ILG to a swf that contains a video.  If Loader can handle f4v objects than that will work as well.  I haven't tried that.

Hope that helps,

Richard

injpixAuthor
Inspiring
July 30, 2010

rdermer, thanks again for your time.

What alternatives are there to have video appear to be in a TextFlow?  The current project I am coding has one container that is scrollable.  All I need is to have a VideoPlayer instance appear center at random places.  Can you please briefly (or in detail) explain the steps to split the ControllerContainer so that there will be VPs instances between them?  The XML feed I am using is external.

I havent used TLF for about 8 months and I am trying to get up to speed.  Thanks so much.

Adobe Employee
August 2, 2010

Another possibility is to make an InlineGraphicElement that is the same height and width as your VideoDisplay.Then get the position of the ILG, and place the VideoDisplay at the same location on the screen, as the child of some existing Flex object (maybe the one that has the RichText) so it comes out on top of the text. If the text can reflow or get edited or scrolled, you will have to reposition the VideoDisplay in response.

There is a discussion thread on this here:

http://forums.adobe.com/thread/647767?tstart=0

Scrolling should cause an updateComplete event, but you'll have to check to see if the inline is still in view; if it's scrolled out, you'll want to remove the VideoDisplay.

Hope this helps,

- robin