Note that there are some explanatory texts on larger screens.

plurals
  1. POFlex: convert VideoPlayer.currentTime to string "00:00:00:000"
    primarykey
    data
    text
    <p>what about this one:</p> <p>I want to format the currentTime displayed by a videoPlayer component inside flex, something like : <code>8230.999 to something like 01:59:59:999 which is "hours:minutes:seconds:milliseconds"</code></p> <p>I trie different sets of codes but they can't get it to work because currentTime is nor a correct miliseconds time as it adds a floating 3 digit point to seconds;</p> <p>so instead of : <code>2000ms it outputs 2.000</code></p> <p>something people like me just can't understand!</p> <p>thanx for any help :)</p> ### UPDATE <p>I still have problem with milliseconds. here's the current MXML:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"&gt; &lt;fx:Script&gt; &lt;![CDATA[ protected function convert_clickHandler(event:MouseEvent):void { var val:Number = new Number(inPut.text); //inPut.text = 1000.001 //val = val * 1000; outPut.text = timeFormat(val); } public static function timeFormat(value:Number):String { var milliseconds:Number = value % 1000; var seconds:Number = Math.floor((value/1000) % 60); var minutes:Number = Math.floor((value/60000) % 60); var hours:Number = Math.floor((value/3600000) % 24); var s_miliseconds:String = (milliseconds&lt;10 ? "00" : (milliseconds&lt;100 ? "0" : ""))+ String(milliseconds); var s_seconds:String = seconds &lt; 10 ? "0" + String(seconds) : String(seconds); var s_minutes:String = minutes &lt; 10 ? "0" + String(minutes) : String(minutes); var s_hours:String = hours &lt; 10 ? "0" + String(hours) : String(hours); return s_hours + ":" + s_minutes + ":" + s_seconds + '.'+s_miliseconds; // returns 00:00:01.000.0009999999999763531 should return 00:00:01.001 // I still have problem with milliseconds } ]]&gt; &lt;/fx:Script&gt; &lt;fx:Declarations&gt; &lt;!-- Place non-visual elements (e.g., services, value objects) here --&gt; &lt;/fx:Declarations&gt; &lt;s:TextInput x="240" y="72" id="inPut" text="1000.001"/&gt; &lt;s:TextInput x="240" y="140" id="outPut"/&gt; &lt;s:Button x="274" y="107" label="convert" id="convert" click="convert_clickHandler(event)"/&gt; &lt;/s:Application&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload