MadBeat
09-29-2008, 11:31 AM
Hi All,
For a while now ive been using actionscript3 to achieve some good results when doing my projects without truly understanding whats happening with eventlisteners, by making use of examples on the internet and feel its about time i actually knew the in's and out's of it all. So im hoping someone could enlighten me by answering a few questions i have::confused:
1. When should i use the removeEventListener to optimize my programs? For example:
playAll.addEventListener(MouseEvent.CLICK, onPlayClick, false, 0,
true);
Does this create a new instance of the event each time my button is pressed which should be removed or does it just retrigger the one function each time it is pressed.
2. What is the (e) all about when compared to (evt) e.g:
function onPlayClick(evt:Event):void or function onComplete(e:Event):void
3. One more! If i want to add an EventListener when another event is complete what is the code. I understand the concept of events linked to buttons etc, but I want to simply create an event from another event e.g.
function LayerArrow2(evt:Event):void{
LayerSelection = LayerSelection+1
if(LayerSelection >= 3){
LayerSelection = 3}
if(LayerSelection == 3){
whatVelLayer = "HiHatCL";
whatLayer = "HiHatCL";
layerText.text = "HiHatClosed";
}
if(LayerSelection == 2){
whatVelLayer = "Snare";
whatLayer = "Snare";
layerText.text = "Snare";
}
addEventListener(event.Event, myEvent) // create another event here.
}
Hope this is not too much to ask, any insight would be great. Thx.:)
For a while now ive been using actionscript3 to achieve some good results when doing my projects without truly understanding whats happening with eventlisteners, by making use of examples on the internet and feel its about time i actually knew the in's and out's of it all. So im hoping someone could enlighten me by answering a few questions i have::confused:
1. When should i use the removeEventListener to optimize my programs? For example:
playAll.addEventListener(MouseEvent.CLICK, onPlayClick, false, 0,
true);
Does this create a new instance of the event each time my button is pressed which should be removed or does it just retrigger the one function each time it is pressed.
2. What is the (e) all about when compared to (evt) e.g:
function onPlayClick(evt:Event):void or function onComplete(e:Event):void
3. One more! If i want to add an EventListener when another event is complete what is the code. I understand the concept of events linked to buttons etc, but I want to simply create an event from another event e.g.
function LayerArrow2(evt:Event):void{
LayerSelection = LayerSelection+1
if(LayerSelection >= 3){
LayerSelection = 3}
if(LayerSelection == 3){
whatVelLayer = "HiHatCL";
whatLayer = "HiHatCL";
layerText.text = "HiHatClosed";
}
if(LayerSelection == 2){
whatVelLayer = "Snare";
whatLayer = "Snare";
layerText.text = "Snare";
}
addEventListener(event.Event, myEvent) // create another event here.
}
Hope this is not too much to ask, any insight would be great. Thx.:)