Skip navigation
Currently Being Moderated

Action Script Error # 2099 when flash context menu is opened in fullscreen

Apr 26, 2011 9:53 PM

I have created a MJPG/MJPEG component by using multiple image components. This component is working fine as far motion jpeg stream is concerned but when flex application is in fullscreen and user tries to open the flash context menu error 2099 occurs. This error is shown in the image below.

Error.PNG

How can i stop this error?

I am using

Flex Framework 3.5.1

Flash Runtime   10.2.152.32

 

My MJPG Component is shown below

 

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas
  xmlns:mx="http://www.adobe.com/2006/mxml"
  initialize="onInit(event)"
  creationComplete="onCreation(event)"
  width="640" height="480"
  backgroundAlpha="0"
  resize="resizeImages(event)"
  >

<mx:Script><![CDATA[
  import mx.core.UIComponentCachePolicy;
  import mx.collections.ArrayCollection;
  import mx.logging.Log;
  import mx.logging.ILogger;  
  import mx.controls.Image;
  
  private static var log:ILogger = Log.getLogger(MJPG);

  private var maxImages:uint = 4;
  private var imgBuf:ArrayCollection = new ArrayCollection();
  private var idleQue:ArrayCollection = new ArrayCollection();
  private var _playing:Boolean = false;
  private var _actualSize:Boolean = false;
  private var imgWidth:uint = 0;
  private var imgHeight:uint = 0;
  
  // Statistics Variables
  private var sTime:Number = 0;
  private var decTime:uint = 0;
  private var _fRecCount:uint = 0;
  private var _fDecCount:uint = 0;
  private var _fps:Number = 0.0;

  private function onInit(e:Event):void
  {
    for (var i:uint = 0; i < maxImages; i++)
    {
      var loader:Image = new Image();
      loader.id = "loader" + i;
      loader.name = "loader" + i;      
      loader.setStyle("horizontalAlign", "center");
      loader.setStyle("verticalAlign", "middle");      
      loader.setStyle("horizontalCenter", 0);
      loader.setStyle("verticalCenter", 0);
      loader.width = width;
      loader.height = height;
      loader.cacheAsBitmap = false;
      loader.autoLoad = false;
      loader.cachePolicy = UIComponentCachePolicy.OFF;
      loader.data = {loading:false, loadTime:0.0, inQue:false, frame:0}
      loader.addEventListener(Event.COMPLETE, onLoadComplete);
      this.addChild(loader);
    }
  }
  
  private function onCreation(e:Event):void
  {
    log.info("Using {0} Loaders", maxImages);
  }

  private function resizeImages(e:Event):void
  {
    var arr:Array = getChildren();
    for each(var loader:Image in arr)
    {
      loader.width = (actualSize && width > imgWidth) ? imgWidth : width;
      loader.height = (actualSize && height > imgHeight) ? imgHeight : height;
    }
  }

  [Bindable(event='framesDecChanged')]
  public function get framesDecoded():uint { return _fDecCount; }  
  private function updateDecFrames(v:uint):void
  {
    _fDecCount = v;
    dispatchEvent(new Event(framesDecChanged));    
  }

  [Bindable(event='playingChanged')]
  public function get playing():Boolean { return _playing; }  
  private function updatePlaying(v:Boolean):void
  {
    _playing = v;
    dispatchEvent(new Event(playingChanged));    
  }

  [Bindable(event='fpsChanged')]
  public function get fps():Number { return _fps; }    
  private function updateFps(v:Number):void
  {
    _fps = v;
    dispatchEvent(new Event(fpsChanged));    
  }
  
  private function loadImage(loader:Image, obj:Object):void  
  {
    loader.data.loading = true;
    loader.data.inQue = false;
    loader.data.loadTime = new Date().getTime();
    loader.data.frame = obj.frame;
    loader.source = obj.data as ByteArray;
    loader.load();
    //log.debug(Frame: {0}, Loader: {1}, Size    : {2}, Time: {3}, obj.frame, 
    //  loader.name, obj.data.length, loader.data.loadTime);
    obj = null;
  }
  
  public function load(image:ByteArray):void
  {    
    if(imgBuf.length >= maxImages+3)
    {
      var obj:Object = imgBuf.removeItemAt(0); 
      log.warn(Frame: {0}, Dropped, TotalDropped: {1}, obj.frame, _fRecCount-framesDecoded);
      obj = null;
    }
    _fRecCount++;
    imgBuf.addItem({frame:_fRecCount, data:image});
    //log.debug(Frame: {0}, Size: {1}, _fRecCount, image.length);

    if(!playing)
    {
      log.info(Starting Stream);
      sTime = new Date().getTime();
      decTime = 0;
      _fRecCount = 1;
      updateDecFrames(0);      
      updatePlaying(true);

      var arr:Array = getChildren();
      var loader:Image = null;
      for each(loader in arr)
      {
        loader.data.inQue = true;
        idleQue.addItem(loader);
      }
    }
    
    if(idleQue.length > 0)
    {
      loader = idleQue.removeItemAt(0) as Image; 
      //log.debug(Using {0} From Idle Que, Length: {1}., loader.name, idleQue.length);
      loadImage(loader, imgBuf.removeItemAt(0));
    }
  }

  private function onLoadComplete(event:Event):void
  {
    if(!playing) return;

    var arr:Array = getChildren();
    var loader:Image = event.currentTarget as Image;
    var bitmap:Bitmap = loader.content as Bitmap;
    if (bitmap != null) bitmap.smoothing = true;
    loader.data.loading = false;    
    
    if(imgWidth == 0)
    {
      imgWidth = loader.contentWidth;
      imgHeight = loader.contentHeight;
      resizeImages(null);
    }
    
    var curTime:Number = new Date().getTime();
    decTime += curTime - loader.data.loadTime;
    //var avgDecTime:Number = decTime / framesDecoded; 
    //log.debug(Frame: {0}, Loader: {1}, DecTime : {2}, AvgDecTime: {3}, loader.data.frame, 
    //  loader.name, curTime - loader.data.loadTime, avgDecTime.toFixed(2));
    if(arr[arr.length-1].data.loadTime > loader.data.loadTime)
    {
      log.warn(Frame decoded out of sequence, {0}, {1}, 
        arr[arr.length-1].data.frame, loader.data.frame);
    }
    else
    { 
      removeChild(loader);
      addChild(loader);
      updateDecFrames(framesDecoded+1);
      updateFps((framesDecoded * 1000) / (curTime - sTime));
    }

    arr = getChildren();
    for (var i:uint = 0; i < arr.length-1; i++)
    {
      loader = arr[i] as Image;
      //log.debug("{0}, Loading  : {1}, inQue : {2}", loader.name, obj.loading, obj.inQue);      
      if(loader.data.inQue == true || loader.data.loading) continue;
      
      if(imgBuf.length == 0)
      {
        loader.data.inQue = true;
        idleQue.addItem(loader);
        //log.debug("Sending {0} to Idle Que, Length: {1}.", loader.name, idleQue.length);
      }
      else
        loadImage(loader, imgBuf.removeItemAt(0));
    }
  }
  
  public function reset():void
  {
    updatePlaying(false);
    idleQue.removeAll();
    imgWidth = 0;
    imgHeight = 0;  
    var arr:Array = getChildren();
    for each(var loader:Image in arr)
    {
      loader.source = null;
      if(loader.data.loading)
        updateDecFrames(framesDecoded+1);
      loader.data.loading = false;
      loader.data.inQue = false;
      loader.data.loadTime = 0.0;
    }
    while(imgBuf.length != 0)
    {
      _fRecCount--;
      var obj:Object = imgBuf.removeItemAt(0);
      log.info("Frame: {0} removed frome the image buffer.", obj.frame);
      obj = null;
    }  

    updateFps((framesDecoded * 1000) / (new Date().getTime() - sTime));

    var recvFps:Number = (_fRecCount * 1000) / (new Date().getTime() - sTime); 
    log.info("Resetting, AvgRendered : {0}fps, AvgReceived: {1}fps, FramesDropped: {2}", 
      fps.toFixed(2), recvFps.toFixed(2), _fRecCount - framesDecoded);
  }
  
  public function getCurrImage():ByteArray
  {
    var arr:Array = getChildren();
    var loader:Image = arr[arr.length-1] as Image;
    if(loader.source is ByteArray)
      return loader.source as ByteArray;
    return new ByteArray();  
  }     

  [Bindable]  
  public function get actualSize():Boolean { return _actualSize; } 
  public function set actualSize(v:Boolean):void
  {
    _actualSize = v;
    resizeImages(null);
  } 
         
]]></mx:Script>

</mx:Canvas>


 

 

Publish Settings are

 

<noscript>
     <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
          id="${application}" width="${width}" height="${height}"
          codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
          <param name="movie" value="${swf}.swf" />
          <param name="quality" value="high" />
          <param name="bgcolor" value="${bgcolor}" />
          <param name="allowScriptAccess" value="sameDomain" />
          <param name="allowFullScreen" value="true" />
    <param name="menu" value="false" />
    <param name="wmode" value="opaque" />          
          <embed src="${swf}.swf" quality="high" bgcolor="${bgcolor}"
               width="${width}" height="${height}" name="${application}" align="middle"
               play="true"
               loop="false"
               quality="high"
               allowScriptAccess="sameDomain"
               allowFullScreen="true"
               menu="false"
               wmode="opaque"
               type="application/x-shockwave-flash"
               pluginspage="http://www.adobe.com/go/getflashplayer">
          </embed>
     </object>
</noscript>

 

 

Note : Before adding menu and wmode parameters in publish settings this error was occuring without fullscreen.

 

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