简体   繁体   中英

Migrate from AS3 to AIR, flvPlayback VideoEvent Error

Is the first time I post here, here's my question: (sorry for my english)
I have a desktop application programmed in Flash AS3, (not AIR) and wanted to migrate to AIR because I saw that you can have control over the files and other stuff that I need. The problem is that is ALL programmed on the TimeLine (I have never programmed with classes and really scared me a bit), so I have about 2200 lines of code in the main script all in one frame.
When I pass the proyect to AIR and I try to run it, I get a lot of errors. I searched on the internet but I find no answers. I don't konw what I'm doing wrong ... and why if I run my application with a SWF file it's works, but I got these errors when I compile for AIR.
Here, the code:

var myVideo:FLVPlayback;
function CreateFLVPlayback():void {
    myVideo = new FLVPlayback(); //FLVPlayback.
    //Configuration and Listeners:
    myVideo.addEventListener(VideoEvent.COMPLETE, RepeatFLVPlayback); //1st ERROR
    myVideo.addEventListener(VideoEvent.READY, ReadyFLVPlayback); //2nd ERROR
    myVideo.addEventListener(VideoEvent.STATE_CHANGE, StateChangeFLVPlayback ); //3rd
}
// [ ... more code ...]
function StateChangeFLVPlayback(e:VideoEvent ):void {
    var videoPlayer:FLVPlayback = e.target as FLVPlayback;
    if (e.state == VideoState.CONNECTION_ERROR) {   ///Line of the 4th ERROR
        trace("No se encontró el video: "+myVideo.source );
    }
}
  • Escena 1, Capa 'Acciones', Fotograma 3, Línea 838 1119: Acceso a una propiedad COMPLETE posiblemente no definida mediante una referencia con tipo estático Class.
  • Escena 1, Capa 'Acciones', Fotograma 3, Línea 839 1119: Acceso a una propiedad READY posiblemente no definida mediante una referencia con tipo estático Class.
  • Escena 1, Capa 'Acciones', Fotograma 3, Línea 840 1119: Acceso a una propiedad STATE_CHANGE posiblemente no definida mediante una referencia con tipo estático Class.
  • Escena 1, Capa 'Acciones', Fotograma 3, Línea 870 - 1119: Acceso a una propiedad state posiblemente no definida mediante una referencia con tipo estático flash.events:VideoEvent.

Here the same Errors in english (using Google Translator):

  • Scene 1, Layer 'Actions', Frame 3, Line 838 1119: Access to a possibly undefined property COMPLETE through a reference with static type Class.
  • Scene 1, Layer 'Actions', Frame 3, Line 839 1119: Access to undefined property READY possibly through a reference with static type Class.
  • Scene 1, Layer 'Actions', Frame 3, Line 840 1119: Access to undefined property state_change possibly through a reference with static type Class.
  • Scene 1, Layer 'Actions', Frame 3, Line 870-1119: Access to a possibly undefined state property through a reference with static type flash.events: VideoEvent.

For complete event try following,

 myVideo.addEventListener(Event.COMPLETE, RepeatFLVPlayback);

 function RepeatFLVPlayback(e:Event):void
 {
      //Your code
 }

The READY, STATE_CHANGE are working for me in AIR 2.0 with,

import fl.video.VideoEvent;

This way it works! Don't know why!

myVideo.addEventListener("complete", RepeatFLVPlayback);
myVideo.addEventListener("ready", ReadyFLVPlayback);

I haved same problem but only with AIR for Android. I digged for this problem many hours and finally this helped me:

display.addEventListener(Event.COMPLETE, koniec);
function koniec(e:Event):void
{
    display.stop();
    MovieClip(root).gotoAndPlay(3);
}

So no VideoEvent but just Event instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM