Completley lost with movieclip-as-button actionscript

hi, i was in new york last week, so i’m out of practice and cant seem to get this working.
i have this code on a movieclip.

on (rollOver) {
	this.gotoAndPlay("in");
}
on (rollOut) {
	this.gotoAndPlay("out");
}
on (releaseOutside) {
	this.gotoAndPlay("out");
}
on (press) {
	gotoAndPlay("main-out");
	chosen = "_root.home";
}

the rollover and rollout actions work, its just that when i press, it doesnt goto frame labelled “main-out” (which is the next frame from where this code is). instead, it plays the rollout animation. :confused:

someone over at flashkit reccommended this, but it still didnt work.

onClipEvent (load) {
	onRollOver = function () {
		this.gotoAndPlay("in");
	};
	onRollOut = onReleaseOutside=function () {
		this.gotoAndPlay("out");
	};
	onPress = function () {
		gotoAndPlay("main-out");
		chosen = "_root.home";
	};
}

can anyone help???

thanks :slight_smile:

Hmm, what’s the instance name of this MC?


        INSTANCENAME.onRollOut = function () {
               INSTANCENAME.gotoAndPlay("out");
        };
        INSTANCENAME.onRollOver = function () {
               INSTANCENAME.gotoAndPlay("in");
        };
        INSTANCENAME.onReleaseOutside=function () {
                INSTANCENAME.gotoAndPlay("out");
        };
        INSTANCENAME.onPress = function () {
                _root.gotoAndPlay("main-out");
                chosen = "_root.home";
        };
  • Try that, not sure though (untested).

it needed an onclip handler, so i tried enterFrame, and it didnt even make the rollover work :frowning:

thanks for trying :slight_smile:

Dont put that on the movieclip, put that on the main timeline :).

oh, lol
ok, ta :slight_smile:

Did it work? No right?

has the same effect, rollovers dont work :frowning:

thanks :slight_smile:

on what timeline is the frame “main-out” located? if it’s within
the MC itself, try putting ‘this.’ in front of all your commands.

like this:
[AS]on (press) {
this.gotoAndPlay(“main-out”);
chosen = “_root.home”;
}[/AS]
if the frame you want to play is on the main timeline, put _root instead. hope that helps.

Thats wat im wondering.

ok, sorry. i’ll try to explain where evrything is :slight_smile:

i have a mc called “main” which is placed on the root stage. (just to make the whole file neater :)) and in this movieclip is another mc, which is the menu button, but its a movieclip.
the label “main-out” is “main” mc, not the button mc.

so the label “in” and “out” are in the menu mc, which is why i have this.
but the “main-out” label is not on the root, but in the same stage as the menu mc, which is why _root. wont work.

hope thats help a bit. if not, i can try to upload the fla. but some people have trouble opening my fla’s as i use a mac.

thanks :slight_smile:

Do you really need a clip event? On the MC of the button (not the main root one but the second one), add these actions:

onClipEvent (enterframe) {
        onRollOver = function () {
                _root.main.gotoAndPlay("in");
        };
        onRollOut = function () {
               _root.main.gotoAndPlay("out");
        };
        onReleaseOutside = function () {
              _root.main.gotoAndPlay ("out");
        };
        onPress = function () {
                _root.main.gotoAndPlay("main-out");
                chosen = "_root.home";
        };
}

And then make sure that the main mc’s instance name is main.

nope, still doesnt work. :frowning:

this is srange, i’ve used this code before and it worked.

on (rollOver) {
        this.gotoAndPlay("in");
}
on (rollOut) {
        this.gotoAndPlay("out");
}
on (releaseOutside) {
        this.gotoAndPlay("out");
}
on (press) {
        getURL("http://www.myurl.com");
}

so it must be something to do with the gotoAndPlay code.

How about without the clipEvent then if that worked :):

onRollOver = function () {
                _root.main.gotoAndPlay("in");
        };
        onRollOut = function () {
                _root.main.gotoAndPlay("out");
        };
        onReleaseOutside = function () {
                _root.main.gotoAndPlay ("out");
        };
        onPress = function () {
                _root.main.gotoAndPlay("main-out");
                chosen = "_root.home";
        };

ok, but why is “in” have _root.main? shouldnt it be just this. ?

and the “main-out” label isnt on the _root. its on the same mc as the button is on, its the next frame actually. :slight_smile:

hey sharif, chek your pm’s :wink:

To make it a little more clear, post your fla:)
(or upload it, seems that the attachments are not working at the moment)

scotty(-:

ok, here’s the url.
[edit] resolved now

thanks :slight_smile: