dcsimg
A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: Flash slide down menu help ! :>

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    9

    Flash slide down menu help ! :>

    Hey people out there, i have a some touble with this menu bar. im not that good at flash, so i hope there is some help to get

    Well, i wanna make a menubar, where the menu btn (forside) is sliding down above and push the tekst (in white) underneath down, when u hover (forside in white). and when you not hovering it, it should slide back.

    then, when your clicking it, it should be down, and ref to a specifik site.

    Maybee its to much to require, but i hope a flashnewb like me cuold get some help.

    Thanks alot
    Attached Files Attached Files

  2. #2
    mentally unstable member smayer72's Avatar
    Join Date
    Jan 2001
    Posts
    527
    Try this tutorial. Sounds like exactly what you need and is very easy to follow.

    http://www.tutvid.com/tutorials/flas...pDownMenus.php
    Scott (Australia)

    Sarcasm, chaos and disorder. My work here is done!

    **Mark you threads as [RESOLVED] please.**

  3. #3
    Junior Member
    Join Date
    Feb 2010
    Posts
    9
    Quote Originally Posted by smayer72 View Post
    Try this tutorial. Sounds like exactly what you need and is very easy to follow.

    http://www.tutvid.com/tutorials/flas...pDownMenus.php
    Hey Scott!

    Thanks for the tip, but its not quite what im looking for.
    What im looking for is like this menu : http://www.templatemonster.com/websi...tes/27346.html.

    just in the opposite way. det menu butten should be comming from upsite, instead from downsite.

  4. #4
    Junior Member
    Join Date
    Feb 2010
    Posts
    9

    Question Im abit closer to the result! :>

    Now im close to what i want - the first problem is now it would not stop :/ and the secound is i need the code in AS3 - an not in AS2 - maybee someone could help me out abit ?
    -Thanks so far
    Attached Files Attached Files

  5. #5
    mentally unstable member smayer72's Avatar
    Join Date
    Jan 2001
    Posts
    527
    I can see a couple of things straight up. Firstly, on your main timeline you have AS on multiple layers. While it will still work, it is not best practices and can make it hard to find later on. Make 1 layer and call it actions and put nothing but AS on it.
    Secondly, I would make the animation into it's own movie clip, not on the main timeline as you have it as I assume you will be having multiple buttons. Again for your sanity. Keep the timeline uncluttered.
    Lastly, and most importantly, you cannot have code on your buttons or movieclips in AS3. All code must be on the timeline. You then add event listeners to your items from the timeline to respond to actions. Example.

    Code:
    btn_name.addEventListener(MouseEvent.CLICK, onClick);
    btn_name.addEventListener(MouseEvent.ROLL_OVER, onOver);
    btn_name.addEventListener(MouseEvent.ROLL_OUT, onOut);
    
    // Action when button is pressed
    function onClick(event:MouseEvent):void
        {
        play(event.target);   //plays clicked movieclip 
        }
    
    //Mouse roll over enlarges item size
    function onOver(event:MouseEvent):void
        {
    	event.target.scaleX = 1.3;
    	event.target.scaleY = 1.3;
        }
        
    //Mouse roll out return to normal size
    	function onOut(event:MouseEvent):void
        {
    	event.target.scaleX = 1;
    	event.target.scaleY = 1;
    	}
    As you can see, you could place any actions inside the functions, depending on what you want to do. Hope this helps a bit. Any more questions, just ask.
    Scott (Australia)

    Sarcasm, chaos and disorder. My work here is done!

    **Mark you threads as [RESOLVED] please.**

  6. #6
    Junior Member
    Join Date
    Feb 2010
    Posts
    9
    Quote Originally Posted by smayer72 View Post
    I can see a couple of things straight up. Firstly, on your main timeline you have AS on multiple layers. While it will still work, it is not best practices and can make it hard to find later on. Make 1 layer and call it actions and put nothing but AS on it.
    Secondly, I would make the animation into it's own movie clip, not on the main timeline as you have it as I assume you will be having multiple buttons. Again for your sanity. Keep the timeline uncluttered.
    Lastly, and most importantly, you cannot have code on your buttons or movieclips in AS3. All code must be on the timeline. You then add event listeners to your items from the timeline to respond to actions. Example.

    Code:
    btn_name.addEventListener(MouseEvent.CLICK, onClick);
    btn_name.addEventListener(MouseEvent.ROLL_OVER, onOver);
    btn_name.addEventListener(MouseEvent.ROLL_OUT, onOut);
    
    // Action when button is pressed
    function onClick(event:MouseEvent):void
        {
        play(event.target);   //plays clicked movieclip 
        }
    
    //Mouse roll over enlarges item size
    function onOver(event:MouseEvent):void
        {
    	event.target.scaleX = 1.3;
    	event.target.scaleY = 1.3;
        }
        
    //Mouse roll out return to normal size
    	function onOut(event:MouseEvent):void
        {
    	event.target.scaleX = 1;
    	event.target.scaleY = 1;
    	}
    As you can see, you could place any actions inside the functions, depending on what you want to do. Hope this helps a bit. Any more questions, just ask.
    First i wanna thank you scott for your kindness, i really appreciate your help.
    secound - sorry for my lameness for flash :/

    Well, im abit confused now, because it ask for a number to play, when i try to roll the movie. heh

    Now i have added all the buttens, but do i need to make the AS for evry single button : ex . forside_btn, sikkerhed_btn and so on? i propaly need af sort of hitarea right? to activate the buttens?

    i allmost get you AS kode now, but this one :

    play(event.target); //plays clicked movieclip <- is that for link the "forside" link or what?

    heh, sorry for all the questions, but im thankfull for your help.

  7. #7
    Junior Member
    Join Date
    Feb 2010
    Posts
    9
    i forgot the new fla file - so you can see the problem.
    Attached Files Attached Files

  8. #8
    mentally unstable member smayer72's Avatar
    Join Date
    Jan 2001
    Posts
    527
    Your welcome for the help. I would not know half what I do if it were not for these forums.
    Firstly when you check the fla you will see I gave each button an instance name and added the stop actions within each one.
    Yes you do need the AS for each button but there is a shortcut as you will see. I make an array that holds all the button instance names. Then I just loop through the array adding the same listener to each button. The hit area is activated by the buttonMode = true line. It tells flash to treat the clip as a button.

    Code:
    //create an array to hold all menu button instances
    var menu:Array = [forside_btn, sikkerhed_btn, referencer_btn, job_btn, total_btn, kontakt_btn];
    
    // add listeners to each item from the menu array
    for each (var element:MovieClip in menu)
    {
        element.addEventListener(MouseEvent.CLICK, onClick);
        element.addEventListener(MouseEvent.ROLL_OVER, onOver);
        element.addEventListener(MouseEvent.ROLL_OUT, onOut);
        //this line treats movieclips as buttons, turns pointer to hand
        element.buttonMode = true; 
    }
    Now you just have one set of functions for all the buttons. The line you asked about 'event.target.play();' is quite simple. The function responds to an 'event', in this case a mouse event. The 'target' part refers to the clip/button you are activating by referencing it's instance name. The last part just says play it.

    Code:
    function onClick(event:MouseEvent):void
        {
         //whatever action you need here 
        }
    
    //Mouse roll over plays the animation
    function onOver(event:MouseEvent):void
        {
        //this line just means the current target of the mouse event you are over or clicking etc...
        event.target.play(); 
        }
        
    //Mouse roll out plays and returns to frame 1
    function onOut(event:MouseEvent):void
        {
        event.target.play(); 
        }
    The only glitch I can see is the fact both roll over and roll out functions tell the clip to play. If the movement happens to fast it can miss a move and start going wierd as you will see. May need to place an if statement within the functions to check the current frame. Will think on it a bit as to the best way to apply it.

    Hope all this helps. Feel free to keep asking if things are not clear.
    Last edited by smayer72; 02-12-2010 at 03:51 AM.
    Scott (Australia)

    Sarcasm, chaos and disorder. My work here is done!

    **Mark you threads as [RESOLVED] please.**

  9. #9
    Junior Member
    Join Date
    Feb 2010
    Posts
    9
    well - it really looks like its a good place to come, when you have some flash problems. and people in here are very freindly to help. I hope can help a bit, when i got the touch on flash like you.

    I see the what you mean now, about the btn's. The roll over and roll out funktion is to fast sometimes, so it kindda stock when the btn is down. Maybee I need some kind of invisible hit area so its not taking action on the text, but on the hit area? - instead of a if statement.

    Maybe om wrong, but it could be an option.

    Thanks again.

  10. #10
    mentally unstable member smayer72's Avatar
    Join Date
    Jan 2001
    Posts
    527
    Think I've got it. Just added an invisible button to the menu clips so the hit area is better defined. Then just added a few conditional statements to check where the target clip is to decide which action to take. Seems to work well. No clips get stuck in the down pos any more anyway. Have a look and let me know how it goes.
    Attached Files Attached Files
    Scott (Australia)

    Sarcasm, chaos and disorder. My work here is done!

    **Mark you threads as [RESOLVED] please.**

  11. #11
    Junior Member
    Join Date
    Feb 2010
    Posts
    9
    It's working fine, no problem at all after the invisible btn with the hitarea, its perfekt thanks.

    Now i just have to make the menu buttens stay down, when they are clicked, and first roll up when another btn are clicked, and then ref to a specifik link. (ex forside_btn, have to link to http://www........forside.php, when its clicked, and so on with the other links.

    And then the btn "forside_btn" should started rolled down when i play the movieclip.

    I really apreciate you help.

  12. #12
    Junior Member
    Join Date
    Feb 2010
    Posts
    9
    Hey again smayer!

    under the "onClick" event, here is all the actions for the url reqeust right? (ex. forside_btn onclick, should go to www.whateverlink.forside.php, and sikkerhed_btn should go til www.whateverlink.sikkerhed.php and so on.)

    and then the buttens should stay down when they are clicked, can you help me out of that?

    I also write you a private message if you notice that.

    thanks alot.

  13. #13
    mentally unstable member smayer72's Avatar
    Join Date
    Jan 2001
    Posts
    527
    Yes the click event is where you place the code for the url request. Is this menu for a full flash site? Or are you implementing it with html? This will affect keeping the button down if the menu reloads each time a new page is called. I use only flash myself, so I won't be much help if it is.
    Scott (Australia)

    Sarcasm, chaos and disorder. My work here is done!

    **Mark you threads as [RESOLVED] please.**

  14. #14
    Junior Member
    Join Date
    Feb 2010
    Posts
    9
    okay, but then i have to make the specifik url on evry butten under "onClik"? its gonne be implementing with html, so maybe i have to make som XML for holding down the taps on evry site ex?

  15. #15
    mentally unstable member smayer72's Avatar
    Join Date
    Jan 2001
    Posts
    527
    For the onClick function I would use a switch statement. It basically checks which movie is being pressed and sets the url to be called accordingly. To keep the movie in the down position, even though it will reload, you can pass a variable via FlashVars with the url string I think. So, unless you know what I'm going on about, research a switch statement first, then google flashvars. Good luck. Will help where I can, but as I said, not really up there with html interaction.
    Scott (Australia)

    Sarcasm, chaos and disorder. My work here is done!

    **Mark you threads as [RESOLVED] please.**

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