Drop Down Menu Problem

  • Yumi
  • Born
  • Born
  • Yumi
  • Posts: 3

Post 3+ Months Ago

Ok so i made the drop down menu and it works fine but i tried to get the inside buttons to take me to another page and they won't.
Heres the code in the buttons that i use.

on(release){
gotoAndStop(Frame#);
}

What i did was i went inside the button that when you move over it it creates the drop down. Then theres all those buttons that i made for different pages. Then I clicked on one and pressed F9 for the actions and typed that in.
Don't know if I did something wrong or what but its not working.
Btw I am using Adobe Flash CS3 Professional

Thank You

Yumi
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Xarathal
  • Born
  • Born
  • User avatar
  • Posts: 3

Post 3+ Months Ago

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:

Code: [ Select ]
// 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);
}
  1. // This code should be placed on the timeline of the button's parent (the movie clip that holds the button)
  2. // Also, frameNumber in each of these functions should be replaced with the correct frame
  3. button1.addEventListener(MouseEvent.CLICK,btnClick1);
  4. button1.buttonMode = true;
  5. function btnClick1(e:Event)
  6. {
  7.     gotoAndPlay(frameNumber);
  8. }
  9. button2.addEventListener(MouseEvent.CLICK,btnClick2);
  10. button2.buttonMode = true;
  11. function btnClick2(e:Event)
  12. {
  13.     gotoAndPlay(frameNumber);
  14. }


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

Code: [ Select ]
function btnClick1(e:Event)
{
    e.target.parent.parent.gotoAndPlay(10);
}
  1. function btnClick1(e:Event)
  2. {
  3.     e.target.parent.parent.gotoAndPlay(10);
  4. }


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 :

Code: [ Select ]
// 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);
}
  1. // This code should be placed on the timeline of the button's parent (the movie clip that holds the button)
  2. // Also, frameNumber in each of these functions should be replaced with the correct frame
  3. button1.onRelease = function() {
  4.     this._parent._parent.gotoAndPlay(10);
  5. }
  6. button2.onRelease = function() {
  7.     this._parent._parent.gotoAndPlay(20);
  8. }


Rock on and happy coding!

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 17 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.