Flex Strangeness Part Two: getTime is not a recognized method of the dynamic class Date

13Oct2008

new Date().getTime() will produce the following warning:

“getTime is not a recognized method of the dynamic class Date”

To fix it, simply do it like this instead:

var myDate:Date = new Date();
trace(myDate.getTime());

Seems like a Flex compiler bug to me. Searching for the error message turned up *nothing* in Google, so I thought I’d add it to their index.

3 Comments

Peter 10/14/2008 at 03:11 PM

This seems to work for me:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

<mx:Label text="{new Date().getTime()}” >
<mx:Label text="{Capabilities.version}" >

</mx:Application>

Which version of the Flex SDK and Flash Player are you using?

Peter

Bjørn 10/24/2008 at 08:13 PM

Hi Peter, and thanks for commenting :)

Unfortunately I’ve reinstalled my Windows since I wrote this post, and when I tested this now I wasn’t able to reproduce it on Flex 3, nor on Flex 2.0.1 HotFix 3.

Ted 06/02/2009 at 12:40 AM

I got this on code I had written in as3 in Flash CS3 and then when compiling the same code in CS4 produced an error along with many others… so compiler version discrepancies? Thanks for getting this out there though…

Leave a comment

Remember my personal information

Notify me of follow-up comments?