1 Reply Latest reply on Apr 19, 2010 11:14 PM by Harry Kunz

    Accessing Button inside Movieclip/ScrollPane

    acheung456

      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

        • 1. Re: Accessing Button inside Movieclip/ScrollPane
          Harry Kunz Level 4

          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.