Passing parameters to event listeners / handlers

前端 未结 8 1351
清酒与你
清酒与你 2020-12-06 06:40

How do you pass parameters / variables through event listeners? I\'ve overcome this problem fairly effectively using anonymous functions; which is an incredibly simple solut

8条回答
  •  旧巷少年郎
    2020-12-06 06:55

    If the MovieClip needs to keep track of extra information that you need to know when it's been clicked, then I would use a more formalised version of your Leprechaun technique.

    I'd create a new class called something like SpecialImage that extends MovieClip and has a property for storing the url to load.

    Depending on how your SpecialImages are created you can either create them in code or link a MovieClip in your library to this class.

    It's basically a posh leprechaun, but as the information is directly related to the image MovieClip, storing them together feels like the best thing.

提交回复
热议问题