Fanboy I’m not
I’ll shelve off ranting about anything for now. There are a couple points I want to make then I’m out.
I’ll shelve off ranting about anything for now. There are a couple points I want to make then I’m out.
Aight…Apple’s turned in 3.3.1 and I’ve accepted it. What next?
Adobe has publicly stated they are not removing the iPhone Packager from Flash CS5. This means people will still see the feature. It means they will use the feature. It means apps might still get pushed to the App Store.
The big question for those who are 3.3.1 aware: Should we still build iPhone apps with Flash CS5?
Let’s talk rally for a sec. Oh wait…maybe I should say: Good people of Flash Land…lend me your ears!
I figured I’d post my thoughts on it too.
Read on after the break.
I’ve been thinking about AIR a lot more lately and it prompted me to think about what 2.0 might provide us in ways of building better AIR apps. So, here is a short list of items I think AIR needs in order to make me happy.
I know…buy ColdFusion right? Use PHP? .NET? Java? Nix those assumptions. If we want to use them, great, but not in all cases do we have a web server at our disposal. Keep making server integration better but don’t force a desktop app to use a server.
I should be able to use full smtp, pop, and imap. Those features would provide a TON of support for a solid number of AIR apps. In AIR 3.0 extend it to integrate with Exchange, etc. Heck, do it in 2.0 if you have the time.
If you provide this one, 1-3 above aren’t as important anymore.
Yes, I know I can use AS to write the files or download then save but that shouldn’t be a requirement. We need more control over the installation.
I’ll leave it at that. If AIR beefed up to provide most of these there would be an uproar of praise. If no one else uproared with me, you’d still have an army of 1 supporting you.
Let’s see what 2.0 brings. 1.x has been great and I’ve enjoyed working with it but it is time to “beef up” in 2.0. We need much more than what AIR currently offers for true enterprise applications, heck even some small to robust apps need the above.
The Flash Player uses the same epoch as Unix (January 1, 1970). An epoch is “a particular period of time marked by distinctive features, events, etc.” (source: Dictionary.com)
One thing to note is the date pertains to the UTC (univeral time coordinated: “Universal time, taking into account the addition or omission of leap seconds by atomic clocks each year to compensate for changes in the rotation of the earth.” [source: Dictionary.com]). Flash can handle this just fine. Let’s get to the code (starting to itch with all of these definitions).
One option to get the UTC date:
var now:Date = new Date(); var epoch:Number = Date.UTC(now.fullYear, now.month, now.date, now.hours, now.minutes, now.seconds, now.milliseconds); trace(now, epoch/1000, Math.round(epoch/1000));
The only real thing to note is the epoch/1000 is there because Flash uses milliseconds and epoch is in seconds so we divide by 1000 to get the seconds since the epoch. Now, that is how I first did it until I RTFM (read the freaking manual). It felt so dirty and unnecessary. Here is the easiest way to do it.
var now:Date = new Date(); var epoch:Number = Math.round(now.valueOf()/1000); trace(now.valueOf(), epoch); //1238595716133 1238595716
Notice the first trace shows a lot more numbers since it is milliseconds since the epoch. The second number is the epoch/1000 and rounded. Don’t forget to round or you’ll get three decimal places. Date.value() is the trick here. By definition: “Returns the number of milliseconds since midnight January 1, 1970, universal time, for a Date object.” (source: Adobe LiveDocs)
Anyways…that’s it. No need to pontificate (been wanting to use that word; lol) anymore about such a simple task.
UPDATE
Since someone on Twitter made the statement about getTime() I guess I wasn’t clear. Let me clarify.
The above is NOT the only way to do it. Yes, you can use new Date().getTime() or new Date().time (preferred over getTime() since it really is a property). They both yield the same result as new Date().value(). Dividing by 1000 and rounding is still required since we’re still fooling with milliseconds since epoch.
Thanks.