Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-16-2009, 09:03 AM   #1
Blade27
Member
 
Join Date: Jan 2009
Posts: 81
Default naming multiple functions

Hi,

I'm just trying to name my 12 functions using a for loop, but its not working.
It works for the event target linked to the listener, but not for the function.

Code below

ActionScript Code:
for(var m:int = 0; m<12;  m++){                 this["holder_thumb_" +m].addEventListener(MouseEvent.CLICK, "changeImage"+m);                 }

Thanks for any help
Blade27 is offline   Reply With Quote
Old 11-16-2009, 09:38 AM   #2
tean28
Member
 
Join Date: May 2009
Posts: 64
Default

what kind of code it that?

i dont undestand why people still use dynamic properties..

and why do you need 12 functions?
you planning on having one function for each image?
why dont you use one function for all images and a target property?
tean28 is offline   Reply With Quote
Old 11-16-2009, 09:59 AM   #3
raghu_thejus
Senior Member
 
Join Date: Apr 2009
Location: Chennai
Posts: 259
Thumbs up

u can do that task like:

Code:
 
for (var m:int = 0; m<12; m++) {
 this["holder_thumb_" + m].addEventListener(MouseEvent.CLICK,this["changeImage"+m]);
}
what tean28 told is right.why r u writing 12 functions?u can write one only.in that u wil get wch object is clicked using

Code:
 
ev.target.name.split("_")[2]
__________________
Learn from your mistakes/fault.Never make any mistake/fault....
raghu_thejus is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:41 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.