Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Extensions and Plugins > Components

Reply
 
Thread Tools Rate Thread Display Modes
Old 04-12-2003, 08:40 PM   #1
heyder
creative soloper
 
Join Date: Sep 2002
Posts: 43
Default macromedia style- change/click handler

How can I set-up an event handler like on some of the macromedia components.

ie.. a user defined function recieves a callback from the component when clicked.

I found the code below but I not sure how to get it working with a new component (I have listed what I have tried to this point)


ActionScript Code:
//put this inside the component ComponentClass.prototype.setClickHandler = function(chng,obj) {         this.handlerObj = (arguments.length<2) ? this._parent : obj;         this.clickHandler = chng; }; ComponentClass.prototype.executeCallBack = function() {         this.handlerObj[this.clickHandler](this); }; //added this code to main timeline componentInstanceName.setClickHandler("myClick", _root); function myClick(component) {         trace (component); }

I know I missing some stuff but not sure what...
heyder is offline   Reply With Quote
Old 04-13-2003, 04:29 AM   #2
tyard
Registered User
 
Join Date: Jan 2003
Location: NYC
Posts: 58
Default

Looks good to me. And you have set up an onPress or onRelease somewhere that will call the executeCallBack?
tyard is offline   Reply With Quote
Old 04-13-2003, 06:24 PM   #3
heyder
creative soloper
 
Join Date: Sep 2002
Posts: 43
Default

How does that part work?

componentname.onPress=function(){
myClick();
}
heyder is offline   Reply With Quote
Old 04-13-2003, 09:09 PM   #4
tyard
Registered User
 
Join Date: Jan 2003
Location: NYC
Posts: 58
Default

Well, it depends on how you've set it up. Normally, you might do it in the component's init method (or whatever initialization script you have for the Class):

Code:
ComponentClass.prototype.init = function() {
        // other code
        this.onPress = this.executeCallback;
};
tyard is offline   Reply With Quote
Old 04-15-2003, 01:05 AM   #5
heyder
creative soloper
 
Join Date: Sep 2002
Posts: 43
Default

Great, thanks. Makes sense now.
heyder 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 Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:45 AM.

///
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.