I'm working on a video player and I have some troubles with flashvars. This is how I define my flashvars :
var beginLive:Date = getFlashVar('beginLive', "undefined");
var endLive:Date = getFlashVar('endLive', "undefined");
I have to retrieve the values (a timestamp) of those vars. My function is going to convert seconds to seconds/minutes/hours --> It is calculating the expected duration of a stream.
This is my getFlashVar function :
//return the content for the flashvar specified by varName, if found, otherwise return the defaultvalue specified
function getFlashVar(varName:String, defaultValue:String):String {
var result:String = defaultValue;
if (undefined != paramsArray[varName] && '' != paramsArray[varName]) {
result = paramsArray[varName] ;
//ExternalInterface.call("displayVar", paramsArray);
}
return result;
}
My problem is that I have to initialize beginLive and endLive to "undefined" but they are of type Date and "undefined" is a string.
Is there an equivalent to "undefined" for the Date type ? How can I initialize those vars and avoid Flash complaining about incompatible types ?
Thank you for your answers :).
Lea.
You could add a convenience method that tries to parse the resulting string from the
getFlashVarfunction as a Date object. It returns aDateobject if the input string could be parsed to a date and otherwise returnsundefined.To use it, pass the returning value from
getFlashVartoparseDateFromStringlike this:Example output: