       loader.y = (stage.stageHeight - loader.height) / 2;
     }
 
-    private function onLoadComplete(event:Event):void {
-      if (!playing) { return; }
-
-      var arr:Array = getChildren();
-      var loader:MJPGImage = event.currentTarget.loader as MJPGImage;
-      var bitmap:Bitmap = event.currentTarget.content;
-      if (bitmap != null) {
-        bitmap.smoothing = true;
-      }
-      loader.data.loading = false;
-
-      scaleAndPosition(loader);
-
-      var curTime:Number = new Date().getTime();
-      if (arr[arr.length - 1].data.loadTime <= loader.data.loadTime) {
-        if (maxImages > 2) {
-          removeChild(loader);
-          addChild(loader);
-        } else if (maxImages == 2) {
-          this.swapChildren(arr[0], arr[1]);
-        }
-      }
-
-      arr = getChildren();
-      for (var i:uint = 0; i < arr.length - 1; i++) {
-        loader = arr[i] as MJPGImage;
-
-        if (loader.data.inQue == true || loader.data.loading) { continue; }
-
-        if (imgBuf.length == 0) {
-          loader.data.inQue = true;
-          idleQue.push(loader);
-        } else {
-          loadImage(loader, imgBuf.shift());
-        }
-      }
-
-      if (firstImage) {
-        ExternalInterface.call(ipCam.getJsEventCallbackName(), "started");
-        firstImage = false;
-      }
-    }
-
-    private function onImageError(event:IOErrorEvent):void {
-      var loader:MJPGImage = event.currentTarget.loader as MJPGImage;
-      loader.data.loading = false;
-      if (imgBuf.length == 0) {
-        loader.data.inQue = true;
-        idleQue.push(loader);
-      } else {
-        loadImage(loader, imgBuf.shift());
-      }
-    }
-
     public function reset(clear:Boolean = false):void {
       playing = false;
       firstImage = true;
-      idleQue.length = 0;
+      idleQueue.length = 0;
 
       while (imgBuf.length != 0) {
         imgBuf.shift();

    }

    public function getChildren():Array {
       var children:Array = [];
       for (var i:uint = 0; i < this.numChildren; i++) {
        children.push(this.getChildAt(i));
       }
       return children;
    }

    public function load(image:ByteArray):void {
      if (imgBuf.length >= maxImages + 3) {
        imgBuf.shift();
      }
      imgBuf.push({ data: image });

      if (!playing) {
        playing = true;
        for each (var loader:MJPGImage in getChildren()) {
          loader.data.inQue = true;
          idleQue.push(loader);
        }
      }

      if (idleQue.length > 0) {
        loadImage(idleQue.shift(), imgBuf.shift());
      }
    }


    }

    private function createLoaders():void {
      for (var i:uint = 0; i < MAX_IMAGES; i++) {
        var loader:MJPGImage = new MJPGImage();
        loader.cacheAsBitmap = false;
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
