Why is it bad to add dynamic properties to movieclips?

Hello Kirupa,

I often do something like the following to add dynamic properties to MCs to be passed to a handler.

(note I use Flash to make touchscreen kiosk apps 99% of the time, so I don’t bother with button objects with roll-overs, etc)


function myFunction():void
{
     var mc:MovieClip = new MovieClip();
     mc.somethingMyHandlerNeedsToKnow = "I am awesome";
     mc.addEventListener(MouseEvent.MOUSE_DOWN, mcButtonHandler);
}
function mcButtonHandler(event:MouseEvent):void
{
     var whatINeedToKnow:String = event.currentTarget.somethingMyHandlerNeedsToKnow;
     trace(whatINeedToKnow); //traces "I am awesome"
}

Will this cause memory issues? Famine in 3rd world countries?

Or is it just “bad OOP practice”, but really just harmless if it gets the job done?

Thank you.