stoimen.com/blog

web developing

Archive for May, 2009

JavaScript typeof operator

typeof vs ==

It sounds strange but most of the web developers still use == operator to check the ‘undefined’ value of a JavaScript variable. Don’t know why but however there’s typeof operator and I strongly recommend it for that purpose.

It simply should be:

typeof variable == ‘undefined’

Flex 3 DateChooser UTC issue

What I intend to do

The task can be described as it is. There’s a Flex 3 DateChooser component integrated with a custom timeline component. The problem occurs when exporting the data from the flash to the browser. Than I write the unix timestamp to the url of the browser. Of course I’m using date.getTime() in Flex.

getTime()

Applying getTime() to any object of type Date in Flex results in a unix timestamp with included milliseconds. Of course the server side technology which in our case is PHP should devide by 1000 to remove the milliseconds. (more…)

reload the page with javascript

Sometimes there’s a need to reload the page with JavaScript. There’s a built in method for that! Just use:

window.location.reload()

The Problem

Although the SWFObject method – createSWF is working fine under IE sets the wmode not to be transparent but with the strange value of window, i.e. <PARAM name=”WMode” value=”Window” />

The Solution is …

to replace the createSWF method calls with other SWFObject method – embedSWF. There you can simply describe the desired wmode for the flash.

Zend_Date with dates before 1901

Zend_Date

Zend_Date is the Zend Framework module for manipulation of dates. It gives several advantages. Everybody how has dealed with dates knows that built in PHP date function cannot manage dates before 1901. With that kind of problems Zend_Date is pretty fine.

How to do that

If you have only

Zend_Date::set($timestamp);

is not enough. The timestamp is an int representation and the framework cannot get the timezone from that and trows an error.

The simple way to solve the problem

Replace the line above with these: (more…)