A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Website navigation buttons

  1. #1
    Junior Member
    Join Date
    Nov 2007
    Posts
    4

    Website navigation buttons

    I'm creating a website in Flash and I need buttons which take you to other pages on the website, four buttons in total. But how ever much I try I just can't get them to work eg so 'Homepage button' takes you to the 'Homepage', 'button 2' takes you to 'page 2' etc.

    I've converted the button graphics using Insert>New symbol>Button
    then creating a new layer for my pages I want in my website, inserting a Keyframe into the first 4 frames of ‘Pages’ layer.
    Then for example for my 'homepage', Insert>New symbol>Movie Clip, then the new time line and canvas comes up so I can add the info I want on that page, in this case my Homepage. After doing that going back to 'scene 1', clicking on Frame 1 of the ‘Pages’ Layer. Then dragging my 'Homepage' movie clip from the library onto my page.
    Then trying to make the buttons work with the pages I've created by using the ‘Behaviors’ palette.

    Using the ‘Selection Tool’ clicking my homepage button, clicking the blue ‘+’ symbol in the ‘Behaviors’ palette MovieClip > Goto and Stop at Frame or Label, entering Frame number 1.

    Then I changed the event handler from ‘On Release’ to ‘On Press’.


    But it just doesn't work no matter how many times I try (I've also looked at tutorials and still don't get anywhere), this is my first time using Flash and I release this is meant to be an easy thing to do in Flash but I can't see how/where I've gone wrong and its really frustrating! All my graphics and pages are ready I just need my buttons to work to take the user to different pages and I'm done.

    I would really appreciate any help, as I'm really lost and have been trying for ages, so hopefully someone will know as my last resort, thanks!

  2. #2
    strandedgenius.com
    Join Date
    Apr 2005
    Location
    Toronto
    Posts
    187
    Yeah this is really basic. I don't know how exactly you're coding here, but onRelease doesn't exist in AS3, not to worry though. This is how you do it in AS3. So let's assume your four buttons are called as follows:

    button_1, button_2, button_3, and button_4.

    Lets add an mouse event listener to button_1.

    Code:
    import flash.display.*;
    import flash.events.*;
    
    button_1.addEventListener(MouseEvent.CLICK, buttonAction);
    button_1.buttonMode = true;
    
    function buttonAction( m:MouseEvent ):void {
    	trace( m.target.name+" has been pressed" );
    }
    First import the classes (good practice). add an mouse event listener. So when the user clicks on that button it dispatches the CLICK mouse event. When this event is dispatched run the buttonAction function. The buttonAction function will run and you can trace which button was presssed by tracing the events target which is "m.target", but this won't give you the name so therefore add name at the end so therefore it would be "m.target.name". You can do the same for each button.

    Now my question is each section of this website in the same FLA/SWF? Or are you combining HTML with Flash, or are you loading an external SWF everytime you press on a button?
    JScarlip,
    That Was Nice!

  3. #3
    Junior Member
    Join Date
    Nov 2007
    Posts
    4
    Thanks a lot for your help!

    I've just realised you're right, in my technical lectures we were working in AS2, so I changed mine to that. Totally forgot I'd done that. Since I'm working in AS2 I'm guessing I should have this thread moved to the correct section, so what I was talking about makes more sense.
    The way I explained how I've done it in my first post is how we have been told to set about doing a basic website in Flash in my lectures, and I've followed that but my buttons won't navigate to the pages I want them too.

    I really know nothing about Flash, as I said it's my first time using it. The code you've given me I wouldn't even know where to put, or how to go about doing the mouse event listener, its all over my head (maybe only possible in AS3?).

    We've been told to create the whole website in Flash, in one Flash document.

    I really wanted to do it the way I've posted in my first post, I'm guessing it has to be possible in AS2, as thats the way we've been told to do it yet I must be going wrong somewhere along the line.

    If anyone knows how to do it in AS2, and knows the kind of process we've been told to do it, and where I might be doing wrong I'd be so grateful!
    Also if you do know hows its done could I have it in simple/step by step translation. Thanks!

  4. #4
    strandedgenius.com
    Join Date
    Apr 2005
    Location
    Toronto
    Posts
    187
    AS2

    This code goes on the timeline. So make a new layer and name in actions.

    Copy and paste this code there.

    button_1.onRelease = function() {
    trace("this button works");
    }

    Make a new symbol name if whatever you want, make it a movieclip (never use Buttons or Graphics, they're useless). Put that movieclip on stage. In the properties window at the bottom give it the instance name of "button_1".

    Now publish you FLA, and click on that button. Hope this helps.
    JScarlip,
    That Was Nice!

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