Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 saving buttons
Index -> Graphics and Design, Web Design -> Flash MX Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Martin




PostPosted: Wed Mar 03, 2004 12:05 am   Post subject: saving buttons

Suppose I have a bunch of buttons that have the same effects (up down over etc.) and animations, but different text and (obviously) doing different things when they're hit. Now, how can I create a bunch of these buttons without redoing the tweaning for each of them?
Sponsor
Sponsor
Sponsor
sponsor
zylum




PostPosted: Thu Mar 04, 2004 12:12 am   Post subject: (No subject)

you can make a prototype which controlst the buttons and the various parameters control the actions and the text of the button (the button being a movieclip)...

for example: make a movieclip with 3 frames, 1 for no action, one for over and one for mousedown... in each of these frames add the action:

stop() ;

remember that these frames can contain other movieclips (to make animations) or what ever else you want ie jpgs... then make a text box with the var name 'name'.

now in the main timeline on the first frame add this code:

code:

//if there is a mouseover, goto frame 2
//if the button is clicked, goto frame 3
//else if there is no action goto the first frame

MovieClip.prototype.buttonActions = function(buttonName) {
        this.name = buttonName
        var clicked
        this.onEnterFrame = function() {
                if (clicked != 1) {
                        if (this.hitTest(_xmouse, _ymouse, true)) {
                                this.gotoAndStop(2);
                        } else {
                                this.gotoAndStop(1);
                        }
                }
        };
        this.onMouseDown = function() {
                if (this.hitTest(_xmouse, _ymouse, true)) {
                        clicked = 1;
                        this.gotoAndStop(3);
                        //do whatever
                }
                this.onMouseUp = function() {
                        clicked = 0;
                };
        };
};
button1.buttonActions("home");
button1.buttonActions("links");
//button1 corrisponds to the instance name of you button


using the protoype parameters you can add other custom actions too. it all depends on what you want to do.

does that sort of help?
Display posts from previous:   
   Index -> Graphics and Design, Web Design -> Flash MX Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: