Copy link to clipboard
Copied
Hi, I have functions i have to re-use with differents objects, i don't want to write a function for each symbol as they use the same mecanisms, but i don't know how to use dynamic targeting and parameters, everything i tried did'nt worked
for example, i tried to pass the instance name in parameters of the function, it does not work :
this.auto.addEventListener("click", obj_function.bind(this, obj='auto'));
function obj_function.(obj) {
this.obj.goToAndStop();
this.obj.removeEventListener();
}
Thanks for your help
I hadn't thought about working that way before, and I'll check into whether it works like I think it would.
Assuming it works, either of these might do better:
this.auto.addEventListener("click", obj_function.bind(this, obj='auto'));
function obj_function.(obj) {
this[obj].goToAndStop();
this[obj].removeEventListener("click",obj_function);
}
or:
this.auto.addEventListener("click", obj_function.bind(obj=this.auto));
function obj_function.(obj) {
obj.goToAndStop();
obj.removeEventListener("
...Copy link to clipboard
Copied
I hadn't thought about working that way before, and I'll check into whether it works like I think it would.
Assuming it works, either of these might do better:
this.auto.addEventListener("click", obj_function.bind(this, obj='auto'));
function obj_function.(obj) {
this[obj].goToAndStop();
this[obj].removeEventListener("click",obj_function);
}
or:
this.auto.addEventListener("click", obj_function.bind(obj=this.auto));
function obj_function.(obj) {
obj.goToAndStop();
obj.removeEventListener("click",obj_function);
}
Copy link to clipboard
Copied
Thanks a lot, it works perfectly ( I tried the first solution).
Best Regards
Gilles
this[obj]
Find more inspiration, events, and resources on the new Adobe Community
Explore Now