Interesting flash tips
During our normal maintenance of advertising screens in where we reproduce video under flash player over linux we have found several things that we believe are important to document.
NetStream.close should be changed to being synchronic or to dispatch an event as soon as the stream is reall closed.
Doing this:
- myNetStream.close();
- myNetStream.play("test.flv");
May not work under some circunstances because the “close” method will happen after the play or in the middle of it. I’m creating a “callLater” alike method to bypass this.
Under linux if you playback a video playlist it is recommended to destroy the video object on every video switch or the flash player will keep consuming memory without releasing it. I have had better results by naming the Video instance different everytime. This doesn’t happen under windows or mac btw, only linux.
This reminds me of this:
- var myVideo:Video = new Video();
- var tmp:Array = new Array(myVideo);
- trace (tmp[0] is Video);
Under windows/mac it will trace true but in linux it will trace false. A workaround is to point directly to the instance:
- trace (myVideo is Video);
Will trace true under all OS.
If you load an external movie using the Loader class you should stop, close and “nullify” all vars/instances before unloading the movie. This is a “feature” btw which is pretty uncomfortable to work with.
All this behaviors appear to be more serious under the linux flash player but there are workaround for everything so be cool :)
At the beggining flash player 9 was consuming 200~ MB and 31% cpu, now after studying everything and applying the workarounds it consumes 23~ MB and 3% cpu :)
Hope this helps someone. We will post any other findings we step upon.
— fernando