Accessing buttons inside frame a movieClip

I understand that putting all code on the main timeline of
the main movie is the best way to do things; A button in my main
movie allows users to view a movieClip – this MC contains 2
frames: in frame 1 a ‘continue’ button takes users to
frame 2 of same movieClip – frame 2 has a close button
– this is the one that doesn’t work. It seems that
anything after the initial frame isn’t recognised when the
code is on main (root) timeline. This can’t be right?
For clarification, this is my code:
myMovieClip._visible = false;
/////////////////FUNCTIONS//////////////////
function fViewInfo() {
myMovieClip._visible = true;
function clearAll() {
_root.myMovieClip.gotoAndStop("frame1");
_root.myMovieClip._visible = false;
/////////////////BUTTON ACTIONS//////////////
viewInfo.onRelease = fViewInfo;
myMovieClip.continue_btn.onRelease = function() {
myMovieClip.gotoAndStop("frame2");
myMovieClip.close_btn.onRelease = clearAll;

couple of things i'd check:
1) in myMovieClip, is there only ONE item per layer? two
items = bad juju, no workey.
2) make sure you have a hit area defined for the button.
seems dumb, but let's be sure... never know...
3) realize that once you move off of frame 1, there is no
code working. so park some code on frame 2 that will handle what
you want to happen. although, i'd handle it a bit differently by
altering the button itself to have 2 frames (minimum) that act like
a toggle from 'continue' to 'close'. much better that way and you
can still handle all your code in frame 1.
the code i'd put on the button (a movie clip) would look like
this (2 frames total):
on frame 1 (the one that says 'continue'):
stop();
this.onRelease = function()
doSomeStuff(); // this actually does some stuff, like play
or some other function
gotoAndStop(2); // go to the frame that has 'close' on it
on frame 2 (the one that says 'close):
stop();
this.onRelease = function()
doSomeOtherStuff(); // this actually does some stuff, like
play or some other function
//gotoAndStop(1); // optional return to frame 1 if you want
to make a toggle behaviour...
i hope this helps. if not... um... try to explain in other
words and i'll try again.
NB :)

Similar Messages

  • Accessing Button inside Movieclip/ScrollPane

    Hello all,
    I'm trying to understand how to build a button inside a movieclip.  I have a template that has movieclips within movieclips, and when I create a button (all using AS2) the button will work if I test the scene, but in the whole flash movie it does not work.  I also have some buttons located inside a ScrollPane that also do not call correctly.
    For my button I am using this code:
    facebookbtn.on (release) {
    getURL("http://www.facebook.com/","_blank","GET");
    ^ This is placed on the button "facebookbtn". I also tried using: _root.bgPages.pg1.facebookbtn.on (release), to no avail.
    For the one inside a ScrollPane I am attempting to call a javascript function:
    on(release){
         import flash.external.ExternalInterface;
         ExternalInterface.call("GroupDelegate","dayone1");
    ^ This also does not work, with or without the button name before on(release).
    I'm putting the FLA file here so that if anyone has the time, could help me with this quick problem. Thanks!
    FLA: Download FLA

    Do not place code inside objects with code on(blah2x). It will lead to unpredictable behaviors and besides it is bad practice. Centralize all your code on one frame in the timeline. Use this format on the main timeline:
    import mx.utils.Delegate; //declare at top only ONCE
    YourButton.onRelease = Delegate.create(this, YourFunctionCall);
    or
    YourButton.onRelease = function()
       //do your stuff here
    Do the same thing with the ExternalInterface. You can put the import at the top along with Delegate.

  • Access button inside MC on stage

    I have a movieclip on the stage (MC_01) that has a button in it (btn_tip_ows). I need to to get it to work from the main timeline.
    If I place the button on the main timeline, the following works.
    btn_tip_ows.addEventListener(MouseEvent.ROLL_OVER, rOverowstip);
    btn_tip_ows.addEventListener(MouseEvent.ROLL_OUT, rOutowstip);
    function rOverowstip(event:MouseEvent):void {
    Tweener.addTween(mc_tip_ows,{alpha:1, time:.5, transition:"easeInOutQuad"});
    function rOutowstip(event:MouseEvent):void {
    Tweener.addTween(mc_tip_ows,{alpha:0, time:.5,  transition:"easeInOutQuad"});

    I still get the error 1120. This is what I have:
        On stage: MC_01 and mc_tip_ows
        btn_tip_owsis inside MC_01
    mc_tip_ows can go inside MC_01 if needed.
    My current code:
    mc_tip_ows.alpha=0;
    MC_01.btn_tip_ows.addEventListener(MouseEvent.ROLL_OVER, rOverowstip);
    MC_01.btn_tip_ows.addEventListener(MouseEvent.ROLL_OUT, rOutowstip);
    function rOverowstip(event:MouseEvent):void {
    Tweener.addTween(mc_tip_ows,{alpha:1, time:.5, transition:"easeInOutQuad"});
    function rOutowstip(event:MouseEvent):void {
    Tweener.addTween(mc_tip_ows,{alpha:0, time:.5,  transition:"easeInOutQuad"});
    Thank You for any help.

  • Access a button inside a movieclip

    Hey...
    Im pretty new to flash, I have a problem that have taken hours, only not to getting sorted out, so i'll try my luck here...
    I've basicly made a rollover menu which is nested inside a movieclip. the movieclip is put on 1 st. frame on the main timeline and I want the buttons inside the movie clip to take the user to a different frame on the main timeline, but no matter what I do it's just not working...
    here is some of he solutions i have tried to do:
    function work1(e:Event)
    //MovieClip(parent.parent).gotoAndStop("work1")
    //gotoAndStop("work1")
    //this.gotoAndStop("work1")
    //parent(gotoAndStop("work1"))
    //MovieClip(this.parent).gotoAndStop("work1")
    //MovieClip(parent.gotoAndStop("work1"))
    //this(gotoAndStop("work1"))
    //main.gotoAndStop("work1")
    //root.gotoAndStop("work1")
    //MovieClip(root).gotoAndPlay("work1")
    //MovieClip(stage).gotoAndPlay("work1")
    //MovieClip(root.parent.parent).gotoAndStop("work1");
    work1_btn.addEventListener(MouseEvent.CLICK, work1);
    hope someone can help...

    sure, there are a zillion ways, that timeout function was more to demonstrate the problem than offer a valid solution...
    Personally, with what you're doing, here's my first inclination for handling it:
    Just add this bit, dumping that other stuff:
    stage.addEventListener(MouseEvent.CLICK, clickHandler);
    function clickHandler(event:MouseEvent):void{
         if (event.target is SimpleButton&&event.target.name!=null){
              gotoAndPlay(event.target.name);
    That assumes you've given those buttons the same name as the frame you want them to go to. In your example, rename that first button as work1, and that code will send you to the frame with that name on click. That code will handle all the buttons, assuming you name the frame and button instances the same (like button work2 would take you to a frame named work2 etc).
    Since it's a stage click handler, it can handle any click. Here's the breakdown:
    //adding a global click listener.
    stage.addEventListener(MouseEvent.CLICK, clickHandler);
    //what to do with the click
    function clickHandler(event:MouseEvent):void{
         //here we're just checking to see what's clicked (from your example, they are SimpleButtons)
         //and then the && means 'and'  we're making sure that button has a name.
         if (event.target is SimpleButton&&event.target.name!=null){
              //goto the frame with the same name as the button
              gotoAndPlay(event.target.name);
    HTH,
    -Ted

  • Button inside MovieClip don't work...?!

    Hello,
    I\m traying to create AIR for Android app & I have 2 MovieClips in the main timeline the first in frame 35 and the second in frame 99 with the name of quary_mc. Inside the second movieclip there is a button with the name of sID_btn. When i addEventListener in frame 1 of the  main timeline it display:
    Error #1009: Cannot access a property or method of null object reference
    This is the code:
    quary_mc.sID_btn.addEventListener(MouseEvent.CLICK, displayData);
    function displayData(evt:MouseEvent):void
              trace("Hello");
    Regards,

    You will be unable to add the event listener to the button until frame 99 when it actually exists.
    Alternatively, you can just add the button on frame 1 at an alpha of 0 and then set it to 1 at frame 99. However, it will still get mouse input so you will need to set quary_mc.visible = false on frame 1 and quary_mc.visible = true on frame 99 to solve that issue.

  • MovieClip buttons inside a MovieClip button inside another MovieClip button

    I am trying to make a Portfolio of my study abroad experience and can get something right about the movie clip buttons inside each other. I have a button to click on titled "travel" and a window shows up with more movieclip buttons to organize different locations of pictures. I can click on the button to have to slide of pictures but nothing happens. I have the "turnOffAllButtons"  coding and  also have the coding for stay clicked, but I can't get the 3rd set to show up. what am i not doing?
    I don't have any errors or output comments showing up

    I have it working now. what I did, I make a slideshow setup (gotoAndStop(1);) in a specific frame and the code I put in for the next, didnt work.
    this is was I have now, without the "turnOffAllButtons" coding:
    Main Button (actions Layer):
    stop();
    travelButton_mc.buttonMode=true;
    travelButton_mc.addEventListener(MouseEvent.ROLL_OVER, colorizetravelButton);
    function colorizetravelButton(givenEvent:MouseEvent){
      if (givenEvent.currentTarget.currentFrame != 50)
      travelButton_mc.gotoAndPlay(2);
    travelButton_mc.addEventListener(MouseEvent.ROLL_OUT, decolorizetravelButton);
    function decolorizetravelButton(givenEvent:MouseEvent){
      if (givenEvent.currentTarget.currentFrame != 50)
      travelButton_mc.gotoAndPlay(21);
    travelButton_mc.addEventListener(MouseEvent.CLICK, loadtravelLocations);
    function loadtravelLocations(givenEvent:MouseEvent){
      travelButton_mc.gotoAndStop(50);
      travelLocations_mc.gotoAndPlay(1);
    Inside the travelLocations_mc I have currently one button to show a slide of pictures, this is the second layer of buttoncode:
    stop();
    scotlandButton_mc.buttonMode=true;
    scotlandButton_mc.addEventListener(MouseEvent.ROLL_OVER, colorizescotlandButton);
    function colorizescotlandButton(givenEvent:MouseEvent){
      if (givenEvent.currentTarget.currentFrame != 50)
      scotlandButton_mc.gotoAndPlay(2);
    scotlandButton_mc.addEventListener(MouseEvent.ROLL_OUT, decolorizescotlandButton);
    function decolorizescotlandButton(givenEvent:MouseEvent){
      if (givenEvent.currentTarget.currentFrame != 50)
      scotlandButton_mc.gotoAndPlay(21);
    scotlandButton_mc.addEventListener(MouseEvent.CLICK, loadscotlandInfoPage);
    function loadscotlandInfoPage(givenEvent:MouseEvent){
      scotlandButton_mc.gotoAndStop(50);
      scotlandInfoPage_mc.gotoAndPlay(1);
    I turned the alpha up so you can see the mc that loads
    I currently have a keyframe at 60 with a code of stop(); so the travelLocations_mc will still
    does this make sense?

  • Bug - Button inside scrollable frame

    Hi,
    I got a button bug in my folio.
    I made a scrollable frame with buttons inside it and the buttons controls a multistate.
    When I tap the buttons they don't perform the action, it just change the color (click state).
    It only performs the action when I tap again the same button.
    What can I do to fix this issue?
    Thanks.

    Hi Bob,
    I am using ID CC 2014 and testing on an iPad.
    In my article, I made two objects a MSO and a scrollable frame with some buttons inside it.
    My scrollable frame has buttons only and allows the user to slide these buttons horizontally.
    The buttons has an action to change the states of my MSO (go to state).
    The problem is when I test this folio on my iPad, If I tap any button, the state of my MSO keeps the same and the button goes to the Click State.
    I can only access other state of my MSO clicking a second time on the same button.
    So the button keeps on the Click State and my MSO change to the State that was scheduled.
    What can I do to fix it?
    Thanks.

  • Buttons inside a movieclips won't work...

    I have a movieclip that has several buttons inside it. When I use this code:
    mc.onRollOver = function()
         // do stuff
    The buttons won't work anymore..

    Hello there Mr. Ned Murphy,
    Is there any other way to make buttons inside a movieclip work?
    The scenario of my project is having a panel for control buttons, progress bar, sound buttons(on/off). When the cursor is rollover the panel, it will animate going up to reveal buttons which hidden below, for the shortcut of every scenes.
    This is what I got.
    control_panel_mc->2 frames w/ stop(); on each->2 layers->1st layer(bottom)panel contains buttons->2nd layer(contains button w/ a "swapdepths very important")
    and on the 2nd frame 2nd layer theres no button w/ a swapdepths and on the actionscript I have that code: mc.onRollOut = function{ //do something };
    Any other suggestion please...
    Thanks and more power,

  • Button inside movieclip on stage

    What do I have to do to get the button to work? I view the swf and there is no active button.
    I need the button inside the clip to be active. I can't find the answer. Thank you.

    no i put a button from the library inside the clip to see if i could access a button once movie played and i couldnt see the states of that library version if I viewed the scene I could.
    I was going to create my own button, which I will, but I don't think I will be able to get to it once publised and I'm frustrated.
    I think I have run into this before, it's been a while. Is it an enable thing?

  • Control button inside movieclip with AS

    If I got a mc with a button inside, how do write the script
    to control that button from the main timeline?
    My script (that doesn't work) looks like this:
    mymovieclip.mybutton.onRelease = function() {
    gotoAndStop(2);

    Sorry, my mistake, it should go to frame 2 inside
    mymovieclip.
    Script should be like this:
    mymovie.mybutton.onRelease = function() {
    mymovie.gotoAndStop(2);

  • Buttons inside of scrollable frames

    I have a series of photographs that act as buttons that go to a page number. In one article, I've grouped together these buttons and put them inside of a scrollable frame. They work fine.
    Now, in another article (both of these articles are part of the same FOLIO) these buttons just go to MSOs. The MSOs have pan and zoom enabled (a lot of interactivity going on). I've cut and paste these buttons inside of a frame and made it scroll, but the buttons are non functional. Why are buttons functional in one frame and non functional in another?

    An update to the DPS tools that addresses the issues with iframe/HTML and buttons in release 25 is now available. Updated tools can be downloaded by following the link for the appropriate InDesign and OS version at http://www.adobe.com/go/learn_dps_install_en.
    Neil

  • Buttons not working within movieclip inside scrollpane

    hey I have a couple buttons that work outside of the ScrollPane but dont work within it. This is my exact code, how do i get them to work?
    scrollPane.source = myContent;
    scrollPane.setSize(173,500);
    K1Button.addEventListener(MouseEvent.CLICK, playVid);
    function playVid(e:MouseEvent):void{
    myVideoPlayer2.myFLV2.source = "video/K.mp4";
    myVideoPlayer2.myFLV2.play();
    T1Button.addEventListener(MouseEvent.CLICK, playVid2);
    function playVid2(e:MouseEvent):void{
    myVideoPlayer2.myFLV2.source = "video/T.flv";
    myVideoPlayer2.myFLV2.play();

    still cant get this any ideas?
    cant seem to get the buttons within the content movieclip to work.
    they are supposed to play a video when clicked.
    they do exhibit the rollover glow action, just not the down action of playing the movie.
    if i take them outside the scrollpane they work fine.

  • Problems with button inside draggable movie clip

    I am building a click through presentation that has some small text in it. To maintain the design and allow for readability, I have added a zoom feature.
    Here is the structure of the movie,
    Stage - contains pages movie clip and forward/reverse click buttons for changing pages
         pages_mc - contains 24 frames, one page per frame and buttons
    There is a button at the _root level that uses a tweener to scale the pages_mc up to 170%. When this is clicked, it allows the pages to be dragged around the screen so you can look at different sections. When you click the button again, it returns the pages back to their original size stops drag.
    My problem is, on the pages, there are buttons with links to external sites. Once startDrag has been invoked, I cannot touch the buttons inside the movie clip. Is there a way to make these buttons work?
    I need the finished quickly so any assistance is welcome.
    Code below
    magUp_btn.onRelease = function() {
    this._visible = false;
    TweenLite.to(pages_mc, .25, {_x:-250, _y:-193, _xscale:170, _yscale:170});
    TweenLite.to(magUp_mc, .75, {_alpha:0});
    TweenLite.to(magDown_mc, .75, {_alpha:25});
    magDown_btn._visible = true;
    pages_mc.onPress = function(){
    this.startDrag();
    pages_mc.onRelease = function(){
    this.stopDrag();
    pages_mc.onReleaseOutside = function(){
    this.stopDrag();
    pages_mc.useHandCursor = false;
    TweenLite.to(instr_mc, 1, {_alpha:100});
    magDown_btn.onRelease = function() {
    TweenLite.to(pages_mc, .25, {_x:0, _y:0, _xscale:100, _yscale:100});
    TweenLite.to(magUp_mc, .75, {_alpha:25});
    TweenLite.to(magDown_mc, .75, {_alpha:0});
    this._visible = false;
    magUp_btn._visible = true;
    pages_mc.onPress = function(){
    this.stopDrag();
    TweenLite.to(instr_mc, 1, {_alpha:0});
    I don't know how to turn drag off when I zoom out without using the onPress command, but I know that this is probably what is getting in the way of the button working?
    Thanks!

    One option is to make the background of the pages be the draggable parts rather than the movieclips that contain the pages and buttons.  That way, the buttons could be atop the background and not have their access blocked.
    Instead of coding the pages_mc, you would essentially have the background coded for the drag...
    pages_mc.bkgnd.onPress = function(){
        startDrag(this._parent);

  • Moving to a frame in Movieclip timeline from the main timeline

    I am in the learning process. Working with FlashCS5 and AS3.
    Please bear with me if the issue appears to be too simple for you. Placed a movieclip(mcassessJohn) on the main timeline and moved to the frame labelled "johnFeedback" in the movieclip timeline using the following actionscript code.
    mcassessJohn.addEventListener(MouseEvent.CLICK, onJohnClick);
    function onJohnClick(evt:MouseEvent):void {
       mcassessJohn.gotoAndPlay("johnFeedback");
    This works fine. However problem starts when I place a button "questionJohn" in the movieclip(mcassessJohn) time line at frame "johnFeedback" and try to move to another frame by clicking the button and using the following actionscript code;
    questionJohn.addEventListener(MouseEventClick,onClick);
    function onClick(evt:MouseEvent):void {
      gotoAnd Play("johnFeedback");
    Placed the above code in actions layer in the movieclip timeline at frame "johnFeedback". I had placed the button also in the movieclip timeline at Frame "johnFeedback in layer buttons. No compiler error.No runtime error. Just nothing happens when I click on the button "questionJohn".
    Would appreciate if you can let me know where I am going wrong.

    Thats because if u assign the listeners to a parent movieclip it will not pickup listener assigned to its child.
    A work around is put a invisible btn inside mcassessJohn movieclip on frame 1 and assign onJohnClick function to that.
    And one more thing, i think u r trying to perform same operation on both the btns
    http://www.darshanrane.com

  • Access Button contained in a movie clip

    This is for beginners or those not familiar or having
    diffculty with getting embedded buttons to work.
    This is a how to on using actionscript in your main time line
    that listens for events for button(s) located inside of a
    movieclip.
    I spent hours trying to figure out why I could not access my
    button that was inside of a movie clip from the main ROOT or
    _level0 of my scene. When I placed the AS inside the movieclip that
    the button was inside of, the button worked but when I put the same
    code, no changes, on the main timeline nothing happened.
    myMovie_mc.myButton_btn.onRelease = function() {
    trace("The Button Works!");
    Your can also use onPress, onRollOver or any of the button
    actions you would if you created the AS on the button itself.
    myMovie_mc.myButton_btn.onRelease = function() {
    function() part of the code can also be function():Void
    First you tell flash where the button is located. Starting
    from the main timeline you start with the name of the movie. This
    is where I had trouble and why my buttons did not work. This part
    of the code is the INSTANCE name NOT the label you named the movie
    that displays in the library.
    CREATE AN INSTANCE NAME on the movie clip. Select the movie,
    in the properties bar you will see a field where you place the
    instance name. I always end the name with _mc, or _btn to tell me
    that it is a movie or a button so when I go back through the AS I
    know what that object is that is being referenced.
    myMovie_mc <-- This is the INSTANCE NAME of the movie clip
    myButton_btn <-- This is the name of the button INSTANCE
    NAME that resides inside the myMovie_mc movie clip
    onRelease <-- This is the event listened for, it could
    also be onPress, onRollOver or any other button events
    = function() <-- This is needed and tells flash that this
    code is treated as a function so that when the event happens, in
    this case onRelease, the code inside the { } is executed. This
    could also be = function():Void
    All the parts before the set to symbol or the = sign needs to
    be seperated with a period, though NOT between the event listened
    for and the set to symbol or = sign.
    myMovie_mc.myButton_btn.onRelease = function():Void
    Put your code here that you want performed when button is
    Released...
    The reason my code didn't work was because I did not give an
    instance name to the movie clip. You must give instance names to
    ANYTHING you call within AS code. Including buttons, MC's, symbols
    etc... or else nothing will happen.
    Now, if you are having same problem I had, the AS worked on
    the same time line level as the button was on but NOT when placed
    in parent or main time line, you now know how to fix it.
    This works in AS2, Flash8 and Flash9. I don't have AS3 yet
    but the code should work in AS3 also.
    Hope this helps someone, I searched for this info in the
    forums and could NOT find it. I stumbled upon my error after many
    hours of trial and error. So next time if I have this problem
    again, a forum search will bring this post up in the results. LOL
    Thanks.

    Nice post. One small addition to this is that you can also
    just specify a function name instead of using "=function() {".
    For example:
    myMovie_mc.myButton_btn.onRelease = myFunction;
    function myFunction():Void
    Put your code here that you want performed when button is
    Released...
    This could be used in a couple of ways. First, the way you
    mentioned in your post. Second, you can use this method to have the
    program simulate a button press (even if the user does not click on
    the button). Since the function will execute even if you just call
    it like: myFunction();
    Just my 2 cents.
    Tim

Maybe you are looking for

  • Lid closing does not suspend after update today

    ...and again: after todays update lid close does not longer trigger suspending my t420s. The last times(!) the cure came always with another update. Please do it again It saves a lot of time. Thx ahead

  • Changing the Column Name in Criteria is not reflected on the Column Selecto

    When we rename the column name in the Criteria, it is not being reflected on the Column Selector drop down list.

  • Problems with JNDI lookup for java:comp/env/ejb

    Hi all, I'm using OC4J 9.0.3 and I have problems when looking up for the local EJB context. I have a SLSB which refers to another SLSB via a JNDI mapping like shown below. Both services are deployed within one EAR file. (snippets of ejb-jar.xml and o

  • Azure - Setting up development environment

    Hi  I am looking at doing a proof of concept for moving our companies current web site/app to azure. Our site makes use of redirecting to sub domains so am i right in thinking that to debug in development i would have to host it locally on IIS so i c

  • AIR Runtime on Android Emulator

    Greets, I've a problem with AIR Runtime on Android Emulator: after I installed the runtime apk  (everything goes fine) i try to install the helloworld.apk compiled with Flash CS5 + Andr ext. Well, i receive this message "INSTALLED FAILED INVALID APK"