Hey there!
It sounds like you could have a couple of issues here.
#1 - ActionScript Version
If you're using CS3, the default ActionScript version is 3.0. If you're using AS3, then you should probably be using event listeners to "listen" for the button getting clicked. See the following code:
// This code should be placed on the timeline of the button's parent (the movie clip that holds the button)
// Also, frameNumber in each of these functions should be replaced with the correct frame
button1.addEventListener(MouseEvent.CLICK,btnClick1);
button1.buttonMode = true;
function btnClick1(e:Event)
{
gotoAndPlay(frameNumber);
}
button2.addEventListener(MouseEvent.CLICK,btnClick2);
button2.buttonMode = true;
function btnClick2(e:Event)
{
gotoAndPlay(frameNumber);
}
- // This code should be placed on the timeline of the button's parent (the movie clip that holds the button)
- // Also, frameNumber in each of these functions should be replaced with the correct frame
- button1.addEventListener(MouseEvent.CLICK,btnClick1);
- button1.buttonMode = true;
- function btnClick1(e:Event)
- {
- gotoAndPlay(frameNumber);
- }
- button2.addEventListener(MouseEvent.CLICK,btnClick2);
- button2.buttonMode = true;
- function btnClick2(e:Event)
- {
- gotoAndPlay(frameNumber);
- }
You can write more efficient functions to handle the events (for example, you could write one function to handle ALL button clicks and change where they go based on a variable inside the button, etc.), but this should give you an idea on how to handle assigning button functions in AS3.
#2 - Targeting
Another thing to bear in mind is the target of the function. Image you have a movie clip called "container" sitting on your main timeline and inside "container" are the two buttons in the code above ("button1" and "button2"). In the functions above, "gotoAndPlay" refers to the "container" movie clip - so the container will go to [frameNumber]. If you want the buttons to change the frame of the ROOT timeline (NOT "container"), then you need to tell the "gotoAndPlay" function that. In AS3, that code would look like
function btnClick1(e:Event)
{
e.target.parent.parent.gotoAndPlay(10);
}
- function btnClick1(e:Event)
- {
- e.target.parent.parent.gotoAndPlay(10);
- }
What this code says is: look at the thing that triggered the event ("e.target" or "button1"), then look at it's parent ("container"), then look at the parent's parent (the root).
The same thing would apply in ActionScript 2.0 :
// This code should be placed on the timeline of the button's parent (the movie clip that holds the button)
// Also, frameNumber in each of these functions should be replaced with the correct frame
button1.onRelease = function() {
this._parent._parent.gotoAndPlay(10);
}
button2.onRelease = function() {
this._parent._parent.gotoAndPlay(20);
}
- // This code should be placed on the timeline of the button's parent (the movie clip that holds the button)
- // Also, frameNumber in each of these functions should be replaced with the correct frame
- button1.onRelease = function() {
- this._parent._parent.gotoAndPlay(10);
- }
- button2.onRelease = function() {
- this._parent._parent.gotoAndPlay(20);
- }
Rock on and happy coding!