Archive for April, 2008

scroll datagrid by actionscript (flex 3)

April 30, 2008

//Highlight the itemrender
dgPeopleList.selectedIndex = 212;

//validateNow needs to be called before verticalScrollPosition is set.

dgPeopleList.verticalScrollPosition = 212;


ScrollPane doesn’t clip loaded content

April 17, 2008

When a ScrollPane is used to load media (Flash 8 IDE), sometimes the loaded content didn’t get clipped (it either sits on top of the scrollpane or goes underneath it).

Cause: An absolute URL is used (such as “myScrollPane.contentPath = ‘'”) for the loaded content.

Solution: Change the absolute URL to relative URL (“img/image.jpg”). Of course you should be able to put the loading swf file and the loaded contents on the same domain.

Mouse hitTest (collision test) in AS 2

April 6, 2008

As a spatially challenged person (easily lost in a street/inside an office building/mall, etc.), I am always confused by the maths that is required when converting a spatial point from one coordinate space into another (localToGlobal, globalTolocal, etc. in Flash).

But hitTest for mouse cursor (collision test to see if mouse cursor collide with movieclip/subclass instances) is much more straightforward;) You always test the mouse coordinates at the _root; this also holds true when you load the swf as an external file using MovieClip.loadMovie or MovieClipLoader.loadClip.

var bigMC:MovieClip;
var cir:MovieClip = bigMC.cir;
var rec:MovieClip = bigMC.rec;

var lsnr:Object = new Object();
lsnr.onMouseMove = function(evt:Object)
var tof:Boolean = cir.hitTest(_root._xmouse, _root._ymouse, true);

In actionScript 3, the cumbersome way of using onMouseMove is gone because of the added event types such as MOUSE_OVER and MOUSE_OUT.