MyIcon class
/******************************************************************************
MyIcon class
copyright Flashscript.biz: 2010
********************************************************************************/
package
{
import fl.controls.CheckBox;
import flash.utils.setTimeout;
import flash.events.Event;
/*
* This class extends the AbstractClass, which allows us to communicate
* with the Document class of the movie.
*/
public class MyIcon extends AbstractClass
{
private var cb:CheckBox;
public function MyIcon ():void
{
/*
* Because we use the constructor we need to delay to add checkbox instances
* on the Displaylist. The instances will be placed in the MyIcon Sprite
* from the movie library. This makes each instance independent from the
* movie.
*/
var st:uint = setTimeout(stOut,1);
}
private function stOut ():void
{
cb = new CheckBox();
cb.label = "Add to Cart";
cb.addEventListener (Event.CHANGE, cHandler);
addChild (cb);
}
private function cHandler (e:Event):void
{
/*
* To get to the DataGrid we can also get access by climbing the tree:
*
* var myGrid:DataGrid = parent.parent.parent.parent as DataGrid;
*
* We need to add e.stopPropagation(); in order to prevent bubbling of the event.
*/
e.stopPropagation();
/*
* We send a message to the Document class with the set_Message function,
* which is a function of the AbstractClass.
*/
set_Message(e.currentTarget.selected);
}
}
}