.shivanshi.
. Home . Share . Share Success . Join Us! .

ActionScript - Code Samples

Delegate Class

Delegate class can be used for proxy events.

Write the following code in fla that has two components.
1. Datagrid instance name: dg
2. Combobox instance name: cb


//delegate.fla
// Delegate class is used to handle multiple events with same name.
// Needs Flash MX 2004 Professional 7.2
import mx.utils.Delegate;
// Data for the datagrid component
dg.addItem({Name:"Abhishek", Industry:"Bollywood"});
dg.addItem({Name:"Amitabh", Industry:"Bollywood"});
dg.addItem({Name:"Gaurav", Industry:"eLearning"});
dg.addItem({Name:"Sachin", Industry:"Cricket"});
dg.addItem({Name:"Sunil", Industry:"Cricket"});
dg.addEventListener("change", Delegate.create(onDgChange));
// Data for the combobox component
cb.addItem("eLearning");
cb.addItem("Internet");
cb.addItem("Information Technology");
cb.addEventListener("change", Delegate.create(onCbChange));
// Event handler for datagrid component
function onDgChange(evt:Object) {
	trace(evt.target+" change event fired.");
}
// Event handler for combobox component
function onCbChange(evt:Object) {
	trace(evt.target+" change event fired.");
}           
Add Favorite
| About Us | Site Map | Privacy Policy | Contact Us |
.shivanshi.