Archive for June, 2008

firefox shortcut keys

June 24, 2008

firefox shortcut keys

Firefox Keyboard and Mouse Shortcuts

Firefox search box type-suggest/autocomplete

June 23, 2008

Firefox addressbar: “about:config” -> double click “browser.search.suggest.enabled” to toggle the setting

dataprovider for datagrid

June 19, 2008

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; layout=”vertical” viewSourceURL=”../src/Layout02.mxml”>
<mx:Script>
<![CDATA[
private function myLabelFunc(item:Object, dataField:DataGridColumn):String
{
var p:String = item.Price? item.Price: “N/A”;
return item.Year+” / ” +p;
}
]]>
</mx:Script>
<mx:ArrayCollection id=”dgPD”>
<mx:source>
<mx:Object Artist1=”Pavement” Album1=”Slanted and Enchanted” Price1=”11.99″ Year=”2003″/>
<mx:Object Artist=”Finches” Album=”Daniel’s Song” Price2=”11.99″ Year=”2007″/>
<mx:Object Artist=”Pavarotti” Album=”Twilight” Price=”11.99″ Year=”1999″/>
<mx:Object Artist=”Other” Album=”Other” Price=”5.99″ Year=”2002″/>
</mx:source>
</mx:ArrayCollection>

<mx:VBox>
<mx:Label text=”Data matter!”/>
<mx:DataGrid id=”myDG” width=”400″ rowCount=”10″ dataProvider=”{dgPD}”>
<mx:columns>
<mx:DataGridColumn headerText=”ARTIST” dataField=”Artist”/>
<mx:DataGridColumn headerText=”ALBUM” dataField=”Album”/>
<mx:DataGridColumn headerText=”YEAR &amp; PRICE” labelFunction=”myLabelFunc”/>
<!–<mx:DataGridColumn headerText=”PRICE” dataField=”Price”/>–>
</mx:columns>
</mx:DataGrid>
</mx:VBox>

</mx:Application>

click on marker always show the last entry of data

June 14, 2008

This is a question from a co-worker of my last job. His is using gcliendGeocoder within a for-loop to dynamically get lat/lng and creating makers on Google maps. The problem is each time you click on a marker, the html text in the info window is always the one that should be for the last marker in the for-loop.

His code:

for (id = 0; id < addresses.length; id++)
{
var description = addresses[id];
var myBiz = biz[id];
geocoder.getLatLng(
description,
function(point)
{
var marker = new GMarker(point);
GEvent.addListener(marker, ‘click’,function(){marker.openInfoWindowHtml(description);});
map.addOverlay(marker);
}
);
}

The point here is “geocoder.getLatLng” is an “asynchronous” callback. That means when the “for-id-loop” reaches its end, the very first “getLatLng” may not get back yet. That’s why you always get the last description in the array. The fix is to add an additional counter inside the call back of “getLatLng”, and assign it as a dynamic property to the marker that gets returned from the callback, and then increment the counter by one at the end of the callback. When you handle the click, you always do a lookup on the marker using the id to find the right marker and the description.

var markers = [];
var closureID = 0;

for (id = 0; id < addresses.length; id++) {
var description = addresses[id];

geocoder.getLatLng(
description,
function(point) {
if(point)
{
var marker = new GMarker(point);
marker.id = closureID;
markers[closureID]=marker;
GEvent.addListener(marker, ‘click’,
function()
{
markers[marker.id].openInfoWindowHtml(addresses[marker.id]);
}
);
map.addOverlay(marker);
++closureID;
}
}
);

}

To see it in action, here is what happens “before“, and “after“:

How to get your YouTube API?

June 14, 2008

http://www.youtube.com/my_profile_dev

Look for “Developer ID” on top of the “profile” box