A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: how to play movie clip on release of a button??

  1. #1
    flash addict
    Join Date
    Jun 2003
    Posts
    136

    how to play movie clip on release of a button??

    eh, I thought I knew how to do this...it seems so simple but for some reason my method is not working.

    I want to play a simple two frame movie clip(stop action included inside of it, yes, so it doesnt repeat over and over again) on release of a button. so i figure the script should look something like this, where no01 is the instance name of the movie clip and (1) is the first frame of the movie clip.

    on (release) {
    no01.play(1)
    }

    that is on release and play(MovieClip) actionscript commands there...but it's not working. i don;t understand why, seems simple enough. so if any one has any ideas and can point me in the right direction, it'd be much appreciated. the sooner the better too. thanks a bunch in advance!!!
    ~"Flash is soooooooooooo flashy!"

  2. #2
    Junior Member
    Join Date
    Mar 2004
    Posts
    7
    Try this:
    Code:
    on (release) {
    tellTarget("no01"){
    gotoAndPlay(1);
    }
    }
    That's how I get my clips to play on events.

  3. #3
    Member
    Join Date
    Sep 2005
    Location
    Canberra, Australia
    Posts
    37
    try this..

    on (release) {
    _root.no01.gotoAndPlay(1)
    }

    Also, it's a good idea to name your movie instances with a suffix of _mc. This will enable code hints as you write.

    make no01 into no01_mc

    after you type a . (period) a little popup menu will appear with all the different options you can use on your movieclip.

    Hope this helps.



    Monkey

  4. #4
    Amazed and Amused Mazoonist's Avatar
    Join Date
    Mar 2006
    Location
    Northern California
    Posts
    201
    I don't know what you could be doing wrong. Check to make sure you gave the object an instance name, make sure you're spelling it EXACTLY the same way in both places (properties panel and in your actionscript). I made a quick simple file that contains a movie clip and a button. On release of the button, the movie clip plays. Hope it helps.
    Attached Files Attached Files

  5. #5
    flash addict
    Join Date
    Jun 2003
    Posts
    136
    Thank you all for your suggestions...

    it seems like my problem is that I don;t have the movie clip on the stage...doi...I thought Flash could call it from the library but no, the movie file is separate from the flash file so I guess not. well, that adds a new layer to my question now.

    so what action should I take if I want the button to play the movie clip on release, keeping in mind that the movie clip has to be on the stage but it can only be seen once you press the button? i have no clue. anyone?

    (so for example, Mazoonist's file is good except i would want the red ball to not be seen unless you press the button, which plays it.)
    ~"Flash is soooooooooooo flashy!"

  6. #6
    flash addict
    Join Date
    Jun 2003
    Posts
    136

    figured it out :D

    Nevermind all~!
    Looks like I figured it out...managed to find an old .swf I did a year ago where I did a similar thing.

    just in case anyone was wondering, this is the code I planted on the butto...

    on (press) {
    this.attachMovie("art01_mc", "art01", 1);
    art01._x = 602;
    art01._y = 372;
    }

    and you need to right click the mc in your library, go to linkage, and call it the approproate name. In this case it is "art01_mc"...also, check the boxes "export for actionscript" and "export in first frame". yay~~~

    three cheers for clarity~
    ~"Flash is soooooooooooo flashy!"

  7. #7
    Member
    Join Date
    Sep 2005
    Location
    Canberra, Australia
    Posts
    37
    Quote Originally Posted by foxyflashfemme
    Code:
    on (press) {
    	this.attachMovie("art01_mc", "art01", 1);
    	art01._x = 602;
    	art01._y = 372;
    }
    To shorten this even more try this...

    Code:
    on(press){
    this.attachMovie("art01_mc", "art01", 1,{_x:602,_y:372});
    }
    To make movies visible and invisible when you want them use this...
    Code:
    myMovieClip_mc._visible = false; //This will hide the clip on the stage...
    //or
    myMovieClip_mc._visible = true; //This will show the clip...
    Monkey
    Last edited by monkey_magic; 06-11-2006 at 09:04 PM.
    -- Actionscript will set you free --

  8. #8
    flash addict
    Join Date
    Jun 2003
    Posts
    136
    Ah I see, thanks Monkey.

    yes, actually it was good that you posted that last bit about making clips invisible on stage because after I did all that work using the script I mentioned I realized that when I go to a new scene, the last movie clip i clicked to see stays on stage! it doesn't go away...*sigh* why is Flash so friggin complicated sometimes???

    but I will try your invisible script and see how that goes!!! thanks so much~

    Oh I just tried putting this code on a button to see if clicking the button would make the movie clip go away...

    on (release) {
    art01_mc._visible = false;
    }

    ...and it didn't work.

    Monkey or anyone else, would you know what code I could use to make it so when you click the button the movie clip goes away? of course, this button is not th same button I clicked to make the movie clip appear;that button which had the attachmovie actionscript. i think it would have to be a separate button, within the movie clip itself...

    if anyone knows, holla please~!
    Last edited by foxyflashfemme; 06-12-2006 at 10:28 PM.
    ~"Flash is soooooooooooo flashy!"

  9. #9
    Member
    Join Date
    Sep 2005
    Location
    Canberra, Australia
    Posts
    37
    foxyflashfemme first up, glad i could help...

    As for _visible not working... Can you tell me if it's inside another movieclip?

    Also, I should have mentioned before...
    For efficiency sake... if you attach a movie, you can also remove the movie... so instead if using _visible, you are better off using

    removeMovieClip(myMovie_mc); //one way of writing it...

    myMovie_mc.removeMovieClip(); //Another way of writing it!

    If you think you will use the movie again, use _visible otherwise use removeMovieClip();

    I need a banana..
    -- Actionscript will set you free --

  10. #10
    Wait- what now? tidenburg's Avatar
    Join Date
    Dec 2005
    Posts
    1,471
    also make sure you are not doing

    myMovie_visible

    its

    myMovie._visible
    "I'd only told them the truth. Was that so selfish? Our integrity sells for so little, but it is all we really have. It is the very last inch of us, but within that inch, we are free."

  11. #11
    flash addict
    Join Date
    Jun 2003
    Posts
    136
    Hello, hello~~!

    Yes, Tidusen, checking back to my last post I did put it in right..the visible script I mean. thanks~!

    Thanks again, Monkey. I tried the removeclip script but it's still a no go...

    you said: As for _visible not working... Can you tell me if it's inside another movieclip?

    yes, the button that I put the visible=false script on was inside a movieclip.the movieclip that I wanted to disappear once you press this button with the visible=false script.

    Actually, I decided to just do a slideshow instead of what I was trying to do so no worries...it would have been nice to figure out though just in case in the future I absolutely had to do something like this.

    I am sending you a PM of the link to where this all is in case you were wondering what I was trying to do...so if you go to the work section on the link I sent, you'll see the slideshow. what i was trying to do though was have a set of buttons that called a movie clip of each individual piece of art. slideshow much easier for now though

    oh and they don't have bananas available here yet so here's a donut for all your help... ke ke ke~
    ~"Flash is soooooooooooo flashy!"

  12. #12
    Senior Member
    Join Date
    Nov 2005
    Location
    dante's inferno
    Posts
    904
    when you put code on a button, you need to use _parent or _root in front of the clip name

    any code on a movieclip or button refers to the movieclip or buttons timeline, not the main timeline or movieclip timeline where it resides

    code:

    on (release) {
    _parent.art01_mc._visible = false;
    }




    IMS

  13. #13
    flash addict
    Join Date
    Jun 2003
    Posts
    136
    yay~!!!

    thank you IMS! it worked! yes, it needed the parent in front of it...
    ~"Flash is soooooooooooo flashy!"

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