PDA

View Full Version : media display component and bad oop design



fumeng
December 9th, 2004, 12:53 AM
hi.

i've got an .fla that exports fine from the flash ide, but in an html page i get plenty of errors (inconsistently). sometimes it plays in IE, sometimes Firefox, sometimes neither, etc...

i never thought that the code that is in my .fla could affect my browser displaying it, but it definitely seems to be the case.

the situation is that i have an .fla with a media display component. the component links to an external .flv.

i am calling an onEnterFrame event on the component itself, ie:

videoController.onEnterFrame = function()
{
// execute these statements
};

is that a bad idea? i just need to do a few things like define some variables, display the timecode in some textfields, and have the progress bars follow the video.

these are the statements i'm triggering inside this function:

define the variables
playLength = 48; // total length of video, hardcoded
currentTime = Math.floor(videoController.playheadTime);

display current time and total time in text fields
var timeCode = convertTime( currentTime );
var timeTotal = convertTime( playLength );
totalTime_txt.text = "/ " + timeTotal;
controlTime_txt.text = timeCode;

this is the number that the progress bar will follow -- video progress essentially
var pos:Number = Math.floor( 112 / ( playLength / currentTime ) );

if user clicks to go to end, extend progress bars and change time display
if (seekEnd == true)
{
pos = 112;
controlTime_txt.text = timeTotal;
}

have progress bars follow these positions
pIBar_mc.targetScale = pos;
pIHead_mc._x = pIBar_mc._x + pIBar_mc._width;

and that's it. am i missing something here? is there a better way to do this?

thanks. matt.