Total hits since 4th Jan 2010

Tuesday, February 2, 2010

FLV Component and preloading problem


Most of the time We have seen the application’s preloader doesn’t appear properly. It starts after certain time interval. It is due to we are exporting the library items on Frame 1.  When the application starts loading the library linkage items are given preference after that timeline frame. The screen remains blank till then.   Check bandwidth Profiler, Streaming Graph from view menu and click Simulate Download to behave it like downloading from internet.


See the graph bars in above screen shot. If the First bar of a graph (that’s First Frame data) from the left is below 1 Kb then your preloader start properly otherwise you need to work around your program.
Note: If you are exporting library items in 1st Frame it will increase data size in Frame/bar 1.
So export library items on Frame 2 to avoid it.
Go to File Publish setting-> Flash Tab ->Settings and change Export Class in Frame 1 to 2. See the screen shot below.

 Check linkage property of library item, now Export in Frame 1 is automatically updated to 2.

FLV Component and preloading problem:
We faced problem when exporting FLV player in Frame 2. The preloader was not working properly. Despite Frame 2 It was loading data in Frame 1.
Check it.
Open New Fla and insert 2 blank Key Frames. Drag FLV component and Place it on Frame 2 and give it an instance name ‘flvPlayer’. Insert Following code on Frame 1 for Preloader.
function update(e:ProgressEvent):void {
                var percent:Number = Math.floor((e.bytesLoaded/e.bytesTotal)*100 );
                pbar_mc.scaleX=percent/100;
                per_txt.text=percent+"%";

                if (percent==100) {
                                play();
                }
}
loaderInfo.addEventListener(ProgressEvent.PROGRESS, update);

stop();
You need to create 2 symbols ‘pbar_mc’ MovieClip and ‘per_txt’ TextField for showing percentage and scaling of a movieclip bar.
Insert Following Code on Frame2
stop();
flvPlayer.skinBackgroundColor=0x666666;
flvPlayer.skinBackgroundAlpha=0.5;
flvPlayer.source="http://www.helpexamples.com/flash/video/water.flv";

Open Bandwidth Profiler and check the Graph it is showing below screen shot despite Exporting on Frame 2 that’ why preloader not behaving properly.


  
Solutions:
Click on FLV Player in 2 Frame and convert it into a Movie Clip. Cut the Code Frame 2 and Place with in a MovieClip.
Now check Bandwidth Profiler. I hope everything will work properly now.

2 comments: