While working on a web project this week for IDSODISC I discovered an interesting way of handling events for movieclips in Actionscript. I set a value for each movieclip(as a button) I then used that value to store an additional movieclip, subsequently creating a single function which can be applied to what ever movieclip you click on. I've included a rough example below.
//code begins here----------------
img1.visible = false;
b1.value = img1
b1.addEventListener(MouseEvent.MOUSE_DOWN, callFunction);
function callFunction(e:MouseEvent):void
{
e.target.value.visible = true;
}
//------END-----
So essentially what this does is it makes the "value" of b1 visible. In this case, that would be img1. I'm not sure how this fits in with standard programming best practices. But the benefit here is, as long as a movieclip has a value - it can call that function.
to view the site visit: http://www.mastertrackproductions.com/ISODISC/ISODISC_loader.html
Tuesday, February 10, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment