Jump to content


Video Content Not Seen Until Loaded Completely

Recommended Posts


I'm using Flash Builder. I load videos from an xml and after that i add video content to application. Code is like that:




<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
  xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="application1_creationCompleteHandler(event)">
  import com.greensock.TweenLite;
  import com.greensock.events.LoaderEvent;
  import com.greensock.layout.AlignMode;
  import com.greensock.loading.LoaderMax;
  import com.greensock.loading.VideoLoader;
  import com.greensock.loading.XMLLoader;
  import com.greensock.loading.display.ContentDisplay;
  import com.greensock.loading.display.FlexContentDisplay;

  import mx.collections.ArrayCollection;
  import mx.events.FlexEvent;

  import spark.components.Button;
  import spark.components.HGroup;
  import spark.components.VideoPlayer;
  protected var videosPath:String = "assets/videos.xml";
  protected var videos:ArrayCollection = new ArrayCollection();
  protected var video1:FlexContentDisplay;

  protected function application1_creationCompleteHandler(event:FlexEvent):void
   // TODO Auto-generated method stub
   LoaderMax.activate([xmlLoader, VideoLoader]);
   LoaderMax.contentDisplayClass = FlexContentDisplay;

  protected function loadVideos2():void
   var loader:XMLLoader = new XMLLoader(videosPath, {name:"xmlDoc", onComplete:completeHandler});

  private function completeHandler(event:LoaderEvent):void
   var queue:XMLLoader = LoaderMax.getLoader("xmlDoc");
   videos = new ArrayCollection(queue.getChildren());
   var vl:VideoLoader = videos.getItemAt(0) as VideoLoader;
   video1 = vl.content;
   video1.horizontalCenter = 0;
   video1.verticalCenter = 0;

 <!-- Place non-visual elements (e.g., services, value objects) here -->





<?xml version="1.0" encoding="utf-8" ?>
 <VideoLoader url="assets/vid/magicfall1.flv" name="video4"
  autoPlay="false" load="true" width="400" height="300" crop="false"
  scaleMode="proportionalOutside" />
<!-- Some other videos, not posted for simplicity, but their properties exactly same except names -->



If i run the program from Flash Builder, I've no problem, it is visible immediately. But if I Export Release Build and put that build to server, when i go to that web page i wait for 3-4 minutes until video content seen on the browser. The size of the video is 24.2 MB. Is that normal? By the way I'm using Version: 1.9.

Link to comment
Share on other sites



I believe your problem has to with the fact an XMLLoader's onComplete event doesn't get fired until the XML has done loading AND all the loader assets in the xml that have load = true have loaded. So your code is waiting for the video to completely load before any of the actions in your completeHandler method take place.


If you want the FlexContentDisplay object to be visible as soon as it is created, look at the onInit event handler shortcut:


onInit : Function - A handler function for LoaderEvent.INIT events which are dispatched when the loader finishes loading the XML file, parses its contents, and creates any dynamic XML-driven loaders. If any dynamic loaders are created and have a load="true" attribute, they will begin loading at this point and the XMLLoader's COMPLETE will not be dispatched until the loaders have completed as well. Make sure your onInit function accepts a single parameter of type Event (flash.events.Event).




let us know if that helps.

Link to comment
Share on other sites

Another option is to set the VideoLoader's "bufferMode" attribute to true in the XML which would make the VideoLoader report its progress based solely on the buffering progress rather than the overall file loading progress.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.