Passing parameters into 'handleClick'

100 views
Skip to first unread message

Oren Shvalb

unread,
Dec 23, 2015, 10:32:21 AM12/23/15
to CreateJS Discussion
Hi,

I wonder if it's possible to pass several params into 'handleClick' ?

Look at this code example:


displayObject
.addEventListener("click", handleClick);
     
function handleClick(event) {
       
// Click happened.
}



Is it possible to add more parameters beside the 'event' ? or maybe add parameters to 'event' ?



Sebastian DeRossi

unread,
Dec 23, 2015, 11:15:59 AM12/23/15
to createjs-...@googlegroups.com
Depending on what version of EaselJS you are using. There are a couple of ways do that this. 
  1. Add whatever data directly onto your displayObject, then reference it on the event handler.
    1. Ex: displayObject.data = {foo:value};
  2. Use the data parameter found with the on method when listening for the click event. 

I would recommend using #2 instead of addEventListener use on.
Have a look at the documentation, there you'll see that you can pass a data parameter which will accept arbitrary data.


--
You received this message because you are subscribed to the Google Groups "CreateJS Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to createjs-discus...@googlegroups.com.
To post to this group, send email to createjs-...@googlegroups.com.
Visit this group at https://groups.google.com/group/createjs-discussion.
For more options, visit https://groups.google.com/d/optout.



--
<u>Sebastian DeRossi</u>

Oren Shvalb

unread,
Dec 23, 2015, 11:21:08 AM12/23/15
to createjs-...@googlegroups.com
I'll look into 'on' method.

Thank you!

--
You received this message because you are subscribed to a topic in the Google Groups "CreateJS Discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/createjs-discussion/-93EVxl5qhw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to createjs-discus...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages