dcsimg
A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: Control of Movie Clips using buttons

  1. #1
    Hi,
    I've been trying to figure this out and realize I need some
    help. The story is this, I have text that I have converted to a graphic symbol. I have a mask of a smaller
    part of the text so it will reveal 3 lines at a time
    and the text motion tweened so it goes up through the mask.
    I have two buttons that I want to use to control the
    motion tween of the text. I have figured out how to
    start the text on roll over and stop the text from moving on roll off but I want the movement to resume at the same spot when the mouse rolls over the button again.
    Also I want the other button to reverse the flow of the
    text and also start and stop when rolled over and off.
    Is there an easier way? I hope I am explaining this well.
    Thanks a million,
    Dant.

  2. #2
    Senior Member
    Join Date
    Nov 2000
    Posts
    143
    make the text tween a movieclip then go to the main time line select the movieclip and goto the action editor and enter this actionscript:-

    onClipEvent (load) {
    this.stop();
    }
    onClipEvent (enterFrame) {
    if (_root.forward == "true") {
    this.gotoAndStop(this._currentframe+1);
    }
    if (_root.backwards == "false") {
    this.gotoAndStop(this._currentframe-1);
    }
    }

    then on the forward button put this code:-

    on (rollOver) {
    forward = "true";
    }
    on (rollOut) {
    forward = "false";
    }

    and on the backwards button put the same code but substitute the 'forward' for 'backwards', forward and backwards are both variables, so on the first frame of your movie just initialise the two variables by putting this code:-

    forward = "false";
    backwards = "false";

    this will then make the movieclip run forwards or backwards when the mouse is over the relevant button.

    if you need any more explanation just ask in a reply and i will try to answer your question, coz i realise this might not be very easy to follow!!

  3. #3
    One cow army..OH NOES!
    Join Date
    Apr 2001
    Location
    Silvermoon
    Posts
    357
    OK if you didn't understand the above...
    You can see this tut it's great for understanding:

    http://www.flashkit.com/tutorials/Ga...98/index.shtml
    Hope this helped!!!!!


  4. #4
    hey thanks very much!

  5. #5
    I used your code and it worked sort of. The problem
    is it only works once. If you roll off the buttons and
    then roll back on nothing happens. Also the down
    button reacts when the mouse rolls off not on. Any
    ideas and again thanks for your assistance.


    Originally posted by adamsr
    make the text tween a movieclip then go to the main time line select the movieclip and goto the action editor and enter this actionscript:-

    onClipEvent (load) {
    this.stop();
    }
    onClipEvent (enterFrame) {
    if (_root.forward == "true") {
    this.gotoAndStop(this._currentframe+1);
    }
    if (_root.backwards == "false") {
    this.gotoAndStop(this._currentframe-1);
    }
    }

    then on the forward button put this code:-

    on (rollOver) {
    forward = "true";
    }
    on (rollOut) {
    forward = "false";
    }

    and on the backwards button put the same code but substitute the 'forward' for 'backwards', forward and backwards are both variables, so on the first frame of your movie just initialise the two variables by putting this code:-

    forward = "false";
    backwards = "false";

    this will then make the movieclip run forwards or backwards when the mouse is over the relevant button.

    if you need any more explanation just ask in a reply and i will try to answer your question, coz i realise this might not be very easy to follow!!

  6. #6
    Senior Member
    Join Date
    Nov 2000
    Posts
    143
    there is a fault in the code i posted, just spotted it now, and it should fix the problem

    onClipEvent (load) {
    this.stop();
    }
    onClipEvent (enterFrame) {
    if (_root.forward == "true") {
    this.gotoAndStop(this._currentframe+1);
    }
    if (_root.backwards == "false") {
    this.gotoAndStop(this._currentframe-1);
    }
    }


    where it says:-

    if (_root.backwards == "false") {

    it should say:-

    if (_root.backwards == "true") {

  7. #7
    Thanks I will try this. One more question please, let's
    say I don't want this clip to appear on the stage immediately. Let's say I want to have a button bring
    the clip up on mouse release. Are we talking a whole new
    ball game? Will the mc need to be in frame one of the stage in order work? Thanks a billion for all your help.

  8. #8
    Senior Member
    Join Date
    Nov 2000
    Posts
    143
    you just need a bit more actionscript, there is a variable called _alpha which allows you to change the alpha value of a movieclip, all you have to do is on the frame in which the movie clip is loaded put this code:-

    movieClipName._alpha = 0;

    this will make the movieclip invisible, then have a button which has this code:-

    on (release) {
    movieClipName._alpha = 100;
    }

    which will show the movieclip. the movie clip doesn't have to be in frame 1 of the stage, but has to be loaded before any actionscript tries to use it, or an error will occur saying that a symbol of that name cannot be found.

  9. #9
    Perfect, thanks alot.

  10. #10
    Junior Member
    Join Date
    Sep 2000
    Posts
    5
    Hi this is dant again. That worked like a charm BUT I left one
    thing out that I could really use some help on. The buttons that
    control the movie clip also have to be invisible when the the
    page loads. Can I have that 3rd button that a affected the
    alpha on the mc also effect the alpha on the buttons? If this can be done I am so in business. Thanks again for all of your help I truly appreciate it.


    Originally posted by adamsr
    you just need a bit more actionscript, there is a variable called _alpha which allows you to change the alpha value of a movieclip, all you have to do is on the frame in which the movie clip is loaded put this code:-

    movieClipName._alpha = 0;

    this will make the movieclip invisible, then have a button which has this code:-

    on (release) {
    movieClipName._alpha = 100;
    }

    which will show the movieclip. the movie clip doesn't have to be in frame 1 of the stage, but has to be loaded before any actionscript tries to use it, or an error will occur saying that a symbol of that name cannot be found.

  11. #11
    Member
    Join Date
    May 2001
    Posts
    34

    Lightbulb


    Dant, instead of a third button, won't it be easier to add a new layer in your MC with the appropriate buttons? This way, when you click the button to view the MC, all its buttons will be visible as well.


    Adamsr: is there an advantage to using _alpha instead of _visible? The end result is the same, isn't it?

    -calyx

  12. #12
    Hi and thanks for your response. The third button is
    a constant on the stage. There are three others that
    are the same. The viewer clicks on any buttono and
    a movie clip, etc. plays on the lower part of the stage.
    I script adam gave me totally works, but I left out
    an important detail. I can't seem to do anything with the
    buttons that control the text. The are always on the stage and I can't do it that way. I need to control the
    alpha or visibilty of the scroll buttons using that 3rd button. Any ideas? Thanks.

  13. #13
    Member
    Join Date
    May 2001
    Posts
    34
    I don't know if I'm reading your post right, but here's what I think it says (if I'm wrong, put the URL up so we can take a look at what you're talking about):

    The third button is always on the stage, and you want it to control the alpha of the scroll buttons? This might be a long way of doing it, but I'm just learning too. I'm sure a faster way's out there, but this is how I'd do it...

    Put the scoll buttons in a movie clip.
    Put the MC on the stage, give it an instance name, ex Scroll.
    Then you'll be doing the same thing as before, just adding in an few extra lines of actionscript:

    In the movie frame actions:
    movieClipName._alpha = 0;
    movieClipScroll._alpha = 0;

    In the third button's actions:
    on (release) {
    movieClipScroll._alpha = 100;
    }

    Hope it helps,
    -calyx-

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