A Flash Developer Resource Site

Results 1 to 19 of 19

Thread: Making buttons in menu to go to pages

  1. #1
    Senior Member
    Join Date
    Oct 2005
    Posts
    157

    Smile Making buttons in menu to go to pages

    Hello, I am attempting to make a flash website, and have 5 buttons on my menu. I made 5 pages in a movieclip called "content". I want to know how I can link those buttons to go to those pages (actionscript and where to put it).

    I have seen flash website templates, and see only ONE button, but when I looked at it in an .swf, it shows all buttons with their specific text label.

    Any other actionscripting that i might need or would be useful for my website, please let me know.

    Also, if anyone can help me making a basic preloader, that will be a great help!

    Sorry if these are stupid questions, but i'm still learning!


    Thanks in advance,
    SK

  2. #2
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    It would mean the button was designed dynamically, one button designed but used multiple times. To link your buttons, try researching getURL Request, http://snipplr.com/view/9312/as3-get...-links-in-as3/

    For the preloader, view this tutorial by Lee Brimelow, it's a good one. http://www.gotoandlearn.com/play?id=85

    HTH, cheers!
    Wile E. Coyote - "Clear as mud?"

  3. #3
    Senior Member
    Join Date
    Oct 2005
    Posts
    157
    Thanks for the preloader tutorial!

    The button tutorial didn't fix my problem though. I was looking for a way to make my MovieClip buttons link to my pages (the pages are on individual frames in a movieclip called "content"
    Imagination is the creator of reality...

  4. #4
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    Then try something like,
    PHP Code:
    button.onRelease = function() [
        
    content.gotoAndPlay(frame#);

    Wile E. Coyote - "Clear as mud?"

  5. #5
    Senior Member
    Join Date
    Oct 2005
    Posts
    157

    Question

    this is really weird. why does my stop(); command not work? haha
    Imagination is the creator of reality...

  6. #6
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    Could be any number of reasons for that... try looking at this post and see if it helps http://board.flashkit.com/board/showthread.php?t=686333
    Wile E. Coyote - "Clear as mud?"

  7. #7
    Senior Member
    Join Date
    Oct 2005
    Posts
    157
    try my file.

    if you can fix these problems and try to link my button MCs to the pages, that would be GREAT!
    Attached Files Attached Files
    Imagination is the creator of reality...

  8. #8
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    OK, had a look at your files and I'm not seeing any code? Might explain why nothing works.
    Wile E. Coyote - "Clear as mud?"

  9. #9
    Senior Member
    Join Date
    Oct 2005
    Posts
    157
    yes i know. i purposely didnt put any code in because it didnt work when i put it in.
    I wanted to see if you could help put in the code.

    Hope this isnt too much trouble,
    Thanks so much,
    SK
    Imagination is the creator of reality...

  10. #10
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    Well, can't say that I'll do it for you, but I will try to guide you through. First off, give the content symbol of the content layer an instance name (I used "content"). Next, add a stop(); action to the last frame of the main timeline. Next give the buttons on the main timeline instant names as well. I used the typical naming convention of "btn1", "btn2" etc.

    Next go into your content mc clip and add a stop(); action to each frame (to prohibit the mc from looping, or advancing to some other frame). After that, go back to the main timeline and next add some code for the buttons. So underneath the stop action add this code.
    PHP Code:
    btn1.addEventListener(MouseEvent.MOUSE_DOWNmouseDownfalse0true);
    btn2.addEventListener(MouseEvent.MOUSE_DOWNmouseDownfalse0true);
    // add for each button


    function mouseDown(e:MouseEvent):void {
        var 
    numFrame:int e.currentTarget.name.substr(3); //this takes the instance name of the button selected and isolates the the 4 character, ie on btn1 - isolates the 1, then goes to the corresponding frame of the content mc
        
    content.gotoAndStop(numFrame);

    Wile E. Coyote - "Clear as mud?"

  11. #11
    Senior Member
    Join Date
    Oct 2005
    Posts
    157
    It looks great! Just one problem,
    in the complier errors it says:
    Access of undefined property btn1
    Access of undefined property btn2
    Access of undefined property btn3
    Access of undefined property btn4
    Access of undefined property btn5

    also, The stop(); command doesnt work for some reason. it doesnt stop when i look at it through Ctrl+Enter (exported), but it stops if I look at it in the main timeline when I just press Enter.

    Thanks so much for your time and help,
    SK
    Imagination is the creator of reality...

  12. #12
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    Not sure what's wrong, I didn't receive any errors when I did it. Do the buttons work? And if the stop(); does not seem to be working what is actually looping, the main timeline or the content mc?
    Wile E. Coyote - "Clear as mud?"

  13. #13
    Senior Member
    Join Date
    Oct 2005
    Posts
    157
    the main timeline
    it works when i dont put that script for the buttons in. once i put it in, the stop doesnt work.

    Where exactly do you want me to put the script?


    Thanks,
    SK
    Last edited by FlashmanSK; 07-06-2009 at 12:38 PM.
    Imagination is the creator of reality...

  14. #14
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    Place the stop(); action plus all the code for the buttons on the last frame of the main timeline.
    Wile E. Coyote - "Clear as mud?"

  15. #15
    Senior Member
    Join Date
    Oct 2005
    Posts
    157
    Description: 1021: Duplicate function definition. Source: function mouseDown(e:MouseEvent):void {


    This is the only complier error shown.

    Do you have any idea what I should do?
    Take a look at my file, please.
    Attached Files Attached Files
    Imagination is the creator of reality...

  16. #16
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    Hmmm, I didn't get that error. I did however notice a few things. Put your actions on its' own layer, much easier to edit when it doesn't reside on the same layer as objects/artwork. I didn't see any code for the buttons, and I noticed that your content symbol on the stage did not have an instance name associated with it.
    Wile E. Coyote - "Clear as mud?"

  17. #17
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    Have a look at this.
    Last edited by Robb@exo; 03-01-2010 at 11:41 AM.
    Wile E. Coyote - "Clear as mud?"

  18. #18
    Senior Member
    Join Date
    Oct 2005
    Posts
    157
    it works perfect on yours, but even when i define everything and put it on a different layer, the same error comes up! This is very strange.

    Try this file please and tell me what you get.

    Sorry and thanks so much,
    SK
    Attached Files Attached Files
    Imagination is the creator of reality...

  19. #19
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    Yeah, I get an error (1009) which to say the least is quite ambiguous. Even googling the error doesn't give one much to go on. And I noticed as well that there is something very suspicious with the contact button. Once pressed, disables buttons 1, 2 and 3... leaving only button 4 as operational. However, press button 4 and the remaining buttons become active again. If it were me I'd probably start over... creating something functional before creating something graphical. But hey, that's just my approach.
    Wile E. Coyote - "Clear as mud?"

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center