A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Movieclip button - click to play, click to stop

  1. #1
    Junior Member
    Join Date
    Dec 2001
    Location
    UK
    Posts
    17

    Unhappy Movieclip button - click to play, click to stop

    Hello everyone.

    I've been searching for this for quite some time but can't find a specific answer. I bought a big fat magazine on the subject (a special!) and it still has left me stumped, so maybe you can help.

    I am building a flash interface and I would like a menu where it is hidden to begin with (just a tab). You click the tab to expand it, and click again to collapse it. I've made a movieclip with animation of the menu opening up and closing, but I can't seem to work out how I'd go about making the movieclip open and close properly. Can anyone help?

    Thanks in advance for any pointing in the right direction!
    adamoliver.com

  2. #2
    Senior Wabbit
    Join Date
    Jul 2008
    Location
    Winchester, Uk
    Posts
    215
    Being lazy I quickly sorted something out for you.

    http://www.hobo-town.com/Flashkit/hide-show.zip

    Just a case of downloading it and away you go its in as2.

    Basically I have a hide and a show button but you could have both function on one.

    The buttons trigger a state ie true or false or in my case 0 and 1 then the MC has the following function placed on it. basically moving the mc to mimic a slide you can use a mask over the mc (xvel) is the variable.

    Actionscript Code:
    onClipEvent (enterFrame) {
        if (_root.xvel == 1) {
            _x = _x+(45-_x)/2;
        }
        if (_root.xvel == 0) {
            _x = _x+(-240-_x)/10;
        }
    }


    All is shown in the Zip contains a fla and swf

    Trust my code, and not my english.

  3. #3
    Junior Member
    Join Date
    Dec 2001
    Location
    UK
    Posts
    17
    Thanks for that. I had a look and it all looks quite complicated to me! But maybe the point I was trying to explain was missed slightly (due to my explanation!)

    The menu I have animates in and out. It has a tab. The bit I need help with is the code to make this tab open on a click, and stay open until they click it again. Because my menu movieclip has animation for the opening then closing, with stop actions in between, i wondered if there was some code that literally says 'on release goto next frame' (of the movieclips timeline) or something like that (obviously written in AS2 correctly!)

    Or I thought something where is works out what frame it is on (labeled on the stop actions or through frame numbers) and so if it's on 'over' go and play 'out', but the idea before seems like it would be simpler.

    Sorry to take up your time creating examples for me, I am very appreciative for your help and your example will be a nice one to learn how to hide/show...when I figure it out!

    Any further help would be fantastic.
    adamoliver.com

  4. #4
    Senior Wabbit
    Join Date
    Jul 2008
    Location
    Winchester, Uk
    Posts
    215
    Thats call it didnt take 5 mins, if you email me the file I will add the code required to the relevant places and send it back to you.
    my email is
    PHP Code:
    ben@hobo-town.com 

    Trust my code, and not my english.

  5. #5
    Junior Member
    Join Date
    Dec 2001
    Location
    UK
    Posts
    17
    Ok thanks. Well through a lot of reverse engineering and further research from what you presented, I found myself a solution! But I still have one problem:

    I have movieclips (links) within a movieclip (menu). I would like to control the link mcs' timelines when you mouseover and out, but I'm not sure of the code. So far I've tried these and none seem to work:

    Actionscript Code:
    on (rollOver) {
        hometext.gotoAndPlay("over");
    }
    on (rollOut) {
        hometext.gotoAndPlay("out");
    }

    and with absolute linking!

    Actionscript Code:
    on (rollOver) {
        _root.sidenav.hometext.gotoAndPlay("over");
    }
    on (rollOut) {
        _root.sidenav.hometext.gotoAndPlay("out");
    }

    sidenav = mc with side menu bar
    hometext=my 'home' mc link, which also has the button in on a layer called 'hotlink'

    Note: I might be doing this the wrong way, but it was my attempt at trying to keep the button to activate the animation and the actual animation in the same place. Let me know if there is a better way.
    adamoliver.com

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