Be a Supporter!

Listeners

  • 254 Views
  • 7 Replies
New Topic Respond to this Topic
Archawn
Archawn
  • Member since: Sep. 9, 2007
  • Offline.
Forum Stats
Member
Level 27
Game Developer
Listeners 2009-03-22 15:51:05 Reply

Code First (It's confusing, I know, but I'm confused right now):

var TextChanged:Object = new Object();
	function changedText(TargetText, TargetProperty){
		TargetProperty = TargetText.text;
	}
	TextChanged.change = function(evtObj:Object){
		changedText(????, ????);
	};
	prop_xPos.addEventListener("change", TextChanged);

I want to be able to use the same listener for multiple variables (like prop_xPos, prop_yPos, prop_width, etc.)

So, I'd need to access the properties of "changedText" when adding the listener. Is there a way to do this?

kiwi-kiwi
kiwi-kiwi
  • Member since: Mar. 6, 2009
  • Offline.
Forum Stats
Member
Level 09
Programmer
Response to Listeners 2009-03-22 16:07:01 Reply

You can access them inside the event listener function by using event.target.property

Archawn
Archawn
  • Member since: Sep. 9, 2007
  • Offline.
Forum Stats
Member
Level 27
Game Developer
Response to Listeners 2009-03-22 16:14:12 Reply

At 3/22/09 04:07 PM, kiwi-kiwi wrote: You can access them inside the event listener function by using event.target.property

I don't understand, example, please?

kiwi-kiwi
kiwi-kiwi
  • Member since: Mar. 6, 2009
  • Offline.
Forum Stats
Member
Level 09
Programmer
Response to Listeners 2009-03-22 16:19:31 Reply

Oh sorry, my bad i wasn't paying attention I thought you were using AS 3 and I got everything wrong

Redshift
Redshift
  • Member since: Feb. 12, 2005
  • Offline.
Forum Stats
Member
Level 15
Programmer
Response to Listeners 2009-03-22 16:42:17 Reply

At 3/22/09 04:19 PM, kiwi-kiwi wrote: Oh sorry, my bad i wasn't paying attention I thought you were using AS 3 and I got everything wrong

He is using AS3...


#include <stdio.h>
char*p="#include <stdio.h>%cchar*p=%c%s%c;%cmain() {printf(p,10,34,p,34,10);}";
main() {printf(p,10,34,p,34,10);}

BBS Signature
Archawn
Archawn
  • Member since: Sep. 9, 2007
  • Offline.
Forum Stats
Member
Level 27
Game Developer
Response to Listeners 2009-03-22 18:28:02 Reply

At 3/22/09 04:42 PM, Nano256 wrote:
At 3/22/09 04:19 PM, kiwi-kiwi wrote: Oh sorry, my bad i wasn't paying attention I thought you were using AS 3 and I got everything wrong
He is using AS3...

No, I'm not.

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to Listeners 2009-03-22 18:37:29 Reply

I'm not totally sure what you're trying to do, but look up onChanged in the Flash help files. You'd have to apply it to all textfields (and give them instance names), but technically you could refer them to your function and send it the correct parameters.

Aware I may be well of the ball here, if so add more details about exactly what it is you're trying to achieve.


- - Flash - Music - Images - -

BBS Signature
Archawn
Archawn
  • Member since: Sep. 9, 2007
  • Offline.
Forum Stats
Member
Level 27
Game Developer
Response to Listeners 2009-03-22 19:32:19 Reply

At 3/22/09 06:37 PM, Denvish wrote: I'm not totally sure what you're trying to do, but look up onChanged in the Flash help files. You'd have to apply it to all textfields (and give them instance names), but technically you could refer them to your function and send it the correct parameters.

Aware I may be well of the ball here, if so add more details about exactly what it is you're trying to achieve.

Yeah, I ended up doing that for each and every text box I had. I wish there were an easier way. AS3.0 is looking better and better as I improve my AS2.