ActionScript for movieclip buttons

  • Jack Sparrow
  • Beginner
  • Beginner
  • Jack Sparrow
  • Posts: 36

Post 3+ Months Ago

Hi, I'm needing to know how to do some certain things for my new website.
I have movieclip buttons (because I can do more with them than buttons), that when clicked open a new page/movie or whatever, I'd like to know how I get that button to stay on it's over state once it has been clicked, so that it indicates what page you're on.

Also, I'd like to disbale the button when it is clicked, so that after the new page/movie is loaded, if the button is clicked again nothing will happen, so that the page doesn't load in again, and will only become active once one of the other buttons is clicked.

So basically I'd like it to remain on the over state, and for the functionality to be disabled.

Thank you for any help, or if I could be pointed to anywhere that deals with this type of thing.
  • zhaojany
  • Student
  • Student
  • User avatar
  • Posts: 79

Post 3+ Months Ago

I often use one movieClip,and name them as btnMc_1,btnMc_2,btnMc_3 and so on,
then give another movieclip in it to contain the text in frame 1 for the btnMc_1 and frame 2 for the btnMc_2 and so on,and name it "txt"
then i put my code in this movieClip as follow,

Code: [ Select ]
stop();
var n;
n = int(this._name.substring(6));//This depends on how u name ur mc
this.txt.gotoAndStop(n);
if (_root.selectedBtn == this) {
    this.gotoAndPlay("selected");
}

this.onRelease = function() {
    if (_root.selectedBtn != this) {
        var preSelect, link_str;
        preSelect = _root.selectedBtn;
        this.gotoAndPlay("selected");
        _root.selectedBtn = this;
        preSelect.gotoAndPlay("default");
        link_str = this._parent.getLink(this._name);
        getURL(link_str);
    }
};
this.onRollOver = function() {
    if (_root.selectedBtn != this) {
        this.gotoAndPlay("over");
    }
};

this.onRollOut = function() {
    if (_root.selectedBtn != this) {
        this.gotoAndPlay("default");
    }
};
this.onReleaseOutside = function() {
    if (_root.selectedBtn != this._name) {
        this.gotoAndPlay("default");

    }
};
  1. stop();
  2. var n;
  3. n = int(this._name.substring(6));//This depends on how u name ur mc
  4. this.txt.gotoAndStop(n);
  5. if (_root.selectedBtn == this) {
  6.     this.gotoAndPlay("selected");
  7. }
  8. this.onRelease = function() {
  9.     if (_root.selectedBtn != this) {
  10.         var preSelect, link_str;
  11.         preSelect = _root.selectedBtn;
  12.         this.gotoAndPlay("selected");
  13.         _root.selectedBtn = this;
  14.         preSelect.gotoAndPlay("default");
  15.         link_str = this._parent.getLink(this._name);
  16.         getURL(link_str);
  17.     }
  18. };
  19. this.onRollOver = function() {
  20.     if (_root.selectedBtn != this) {
  21.         this.gotoAndPlay("over");
  22.     }
  23. };
  24. this.onRollOut = function() {
  25.     if (_root.selectedBtn != this) {
  26.         this.gotoAndPlay("default");
  27.     }
  28. };
  29. this.onReleaseOutside = function() {
  30.     if (_root.selectedBtn != this._name) {
  31.         this.gotoAndPlay("default");
  32.     }
  33. };


PS: you should define the "_root.selectedBtn " before,and another "getLink()" function to return the link string.
  • steaplechaser
  • Born
  • Born
  • steaplechaser
  • Posts: 1

Post 3+ Months Ago

This code looks daunting. I understand what you have said at the beginning about creating one movie clip and giving it different instance names. Could you further elaborate on the other terms and why it is coded as such.

thanks

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 13 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.