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.

Similar Messages

  • 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);

  • 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 :)

  • 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.

  • Timeline Buttons Inside of ScrollPane

    Hey Adobe-ers.
    I created a scrollpane which contains several different buttons.  Each button does a simple timeline navigation, but won't function inside of the scrollpane.  I just need each button to 'gotoframeandstop'.  How can I make these buttons work in a scrollpane?
    Thanks!

    You can assign the code to the buttons from the main timeline so that targeting the main timeline for the gotoAndStop() commands is direct (sp is the scrollpane instance name in this example)....
    MovieClip(sp.content).wesley.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_93);
    function fl_ClickToGoToAndStopAtFrame_93(event:MouseEvent):void
         gotoAndStop(17);
    Or you could try targeting the main timeline from where the code is now...
    wesley.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_93);
    function fl_ClickToGoToAndStopAtFrame_93(event:MouseEvent):void
         MovieClip(root).gotoAndStop(17);

  • 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 buttons or Movieclips in animations

    Hi,
    Plz Plz plz help me,
    I have a flash with animations playing one after another.
    Say animation 1 finishes and i have a button which says Play Next named as playNext when i add the below code
    playNext.addEventListener(MouseEvent.CLICK,functio  n(){gotoAndPlay("indexFade");});
    on the last frame or the first frame ater stop it says
    ReferenceError: Error #1065: Variable btnChallange is not defined.
    at FB_index_fla::MainTimeline/FB_index_fla::frame1()
    can anyone help me on this, its very urgent.
    Plz

    Hi Thanks for quick reply,
    If you have a look in the attached file i have button btnChallange i am trying to add event to it but i don't know its giving error
    ReferenceError: Error #1065: Variable btnChallange is not defined.
        at FB_index_fla::MainTimeline/FB_index_fla::frame81()
    Please its am morning here if you reply this message i will be very thankful to you

  • Accessing MovieClip function of a MC inside a ScrollPane

    I have a MC that is too tall for my stage and want to place it inside a ScrollPane. The probelm is accessing functions inside the MC. I have tried scrollpane.content.mc.function but that doesn't work. How do you access a mc inside tghe scrollpane?

    >
    >
    No virus found in this incoming message.
    Checked by AVG - www.avg.com
    Version: 8.5.375 / Virus Database: 270.13.19/2245 - Release Date: 07/18/09 05:57:00
    >
    This code sits on the first frame of the swf being loaded into the
    ScrollPane:
    function setStepComplete(ss:Number,fs:Number):void{
        if(ss == fs){
            setCheckMark(ss);
        }else {
            for(var i=ss;i<=fs;i++){
                setCheckMark(i);
    function setCheckMark(chknum:Number):void{
        with (pdiform) {
            switch(chknum){
                case 0:
                    step0.gotoAndStop(2);
                    break;
                case 1:
                    step1.gotoAndStop(2);
                    break;
                case 2:
                    step2.gotoAndStop(2);
                    break;
    This is the code you suggested, sitting on the second frame; the
    ScrollPane is on the first frame (no stops()).
    MovieClip(sp_pdiform.content).setStepComplete(0,0);

  • 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

  • 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?

  • HELP : onPress event for a movieclip inside of ScrollPane

    I have a ScrollPane and this ScrollPane loads an item from
    the Library. And this library item contains moviecilp and I'm
    trying to add 'onPress' event to this movieclip by..
    MovieName.onPress = function()
    trace("Pressed");
    But, since this movie is inside of ScrollPane the onPress
    event never occurs.
    Please let me know how to an event to a movieclip that
    resides inside of ScrollPane.
    Thanks in advance.

    As Luigil said, there is a path problem.
    First you must find the right path.
    create in level0 the var test1:String;
    //Put this on Frame 1 of your loaded MC:
    _level0.test1 = this; //now you can see the right path
    cheers

  • 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,

  • Buttons inside moveiclip not accessible

    Hi,
    I am making this website, which contains a load file, which contains a movieclip holder, which holds all the different parts of the website.
    Now within the portfolio.swf, which is within mcholdr, inside load.swf, there are several images, which are buttons. On clicking one image, I have code which dims, i.e. reduces _alpha for all the buttons and disables them. Now when I test portfolio.swf alone, this code works, but when I access portfolio.swf through load.swf, the code is not working.
    The code within each image button inside portfolio.swf is:
    while (i<=29) {
            _root.folioholdermc["img"+i]._alpha = 20;
            _root.folioholdermc["img"+i].enabled = false;
            i++;
    img1 to img20 are the image buttons. They are placed within folioholdermc, which in inside portfolio.swf.
    Structure with portfolio.swf alone : Main timeline ------> folioholdermc -------> img1 to img20
    Now through load.swf is : Main timeline --------> mc_load -----------> portfolio.swf (loaded with MovieClipLoader)
    I tried everything from
    _root.mc_load.folioholdermc[img....
    folioholdermc[img.....
    Nothing works. Is this a path problem??? How do I access these buttons?? I want to use the loop, as there are many buttons, so a simple img1._alpha will not work, as I will have to type this out for each button. How can I get the same effect using the loop??
    Thanks

    If I'm interpretting your posting correctly, it ilikely you have an issue using _root references.  Unless specified otherwise, if you load an swf file that uses _root references, those _root references will target the main file's _root.  To get around this you probably need to implement _lockroot in the files that you are loading.    Look it up in the AS2 help files.  In your case it may be as simple as adding the following to the main timeline of the file(s) you load...
    this._lockroot = true;

  • Email Link inside a Scrollpane

    So i have a scrollpane with a movieclip in it. Inside the movieclip i put static text that says "Email Eric" and linked it with mailto:[email protected] but when i test the movie it won't work. So basically i need to know how to link an email to something inside a scrollpane. Any help would be much appreciated. Thanks for your time in advance. I know someone will come thru for me. They always do!

    ok....so i made a whole new flash document to make sure i wasnt doing anything wrong
    scrollpane instance name = ericScroll
    movie clip that scrolls thru scrollpane = content
    so i laid out all my stuff going to be a in the movieclip scroll and then put text and made it a movieclip and it's instance name is = email
    then i selected all my info including email link and other item to be content and made it all a movieclip(content)
    i have 2 layers
    site & actions
    first frame i made a button the goes to frame 17 where my scrollPane lies. on that frame in my actions i have this code
    scrollPane.setStyle("borderStyle","none");
    scrollPane.drawFocus = false;
    ericScroll.spContentHolder.email.onRelease = function() {
    trace("A");
    getURL("mailto:[email protected]");
    s then when i test movie i click the button that takes me to the scrollpane ....scroll down....press the button and nothing

Maybe you are looking for