Skip navigation
LooneyAnimator
Currently Being Moderated

Trying to create a button inside a movie clip that will go back to Scene 1

Sep 11, 2012 1:48 PM

Tags: #problem #flash #code_snippets #movieclip #ac3 #actionscript3

I am trying to create a button inside a movie clip that will go back to Scene 1.

 

Here is my code

 

stop();

 

 

sback1_btn.addEventListener(MouseEvent.CLICK,film1);

 

 

function film1(event:MouseEvent):void{

          gotoAndStop("shorts");

}

 

I keep getting Access of undefined property error.

 

Can anyone help?

 

Thank you.

 
Replies
  • Currently Being Moderated
    Sep 11, 2012 2:08 PM   in reply to LooneyAnimator

    If the code you show is on the main timeline, then you need to add the name of the movieclip  in front of that listener in order to target the button.

     

    mcName.sback1_btn.addEventListener(MouseEvent.CLICK,film1);

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 11, 2012 3:42 PM   in reply to LooneyAnimator

    First, go into your Flash Publish Settings and select the option to Permit Debugging.  Then run the file and copy the entire error message and place it in your next response. 

     

    In the error you might see a line number following the first frame numnber that is mention.  That will be the line of the code that has the problem.

     

    If it happens to be the line of code you show, then my first suspiscion would be that you have not assigned the instance names to the objects (via the Properties panel where it says "<Instance Name>").

     

    If you have named things properly, do you happen to animate things into place?  If that's the case, then you need to assign the instance names in all keyframes.

     

    If you don't animate things into lace and the naming is okay, then is the button on a frame other than frame 1 of the movieclip such that it doesn't exist when that line of code is executing?

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 11, 2012 4:29 PM   in reply to LooneyAnimator

    function film1(event:MouseEvent):void{

              MovieClip(root).gotoAndStop("shorts");

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 12, 2012 5:17 AM   in reply to LooneyAnimator

    What is the complete error message that you are getting?

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 12, 2012 11:28 AM   in reply to LooneyAnimator

    How have you assigned the instance name mcFideoMask? Can you show a screenshot that incudes the Properties panel with that name assigned to the object you say is named mcVideoMask and showing the code in the Actions panel and the timeline with that same frame?

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 12, 2012 6:07 PM   in reply to LooneyAnimator

    I don't see the properties panel with the <Instance Name> for the mcVideoMask showing.  You need to have that object selected on the stage for the Properties panel to show that.

     

    Seeing that timeline tween in the timeline leads me to repeat something I said earlier....  If you have named things properly, do you happen to animate things into place?  If that's the case, then you need to assign the instance names in all keyframes.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 13, 2012 4:24 AM   in reply to LooneyAnimator

    Here's what the pictures tell me.  The code your are trying to assign to the button is inside the VideoMask object, so here are your options. 

     

    Try moving that code the the main timeline into frame 2.

     

    OR

     

    Go back to having your code the way you started, with the change that Esdebon offered.

     

    In both cases, you need to make sure you have assigned the instance name to the button in every keyframe of its tmeline, especially frame 1.  Objects will inherit the names you assign in preceding sequencial frames regardless of what you name them later, so you need to make sure you assign the name in frame 1 or else that lack of a name will be inherited in frame 15.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 13, 2012 3:07 PM   in reply to LooneyAnimator

    try

     

    sback1_btn.addEventListener(MouseEvent.CLICK,film1);

     

    function film1(event:MouseEvent):void{

              MovieClip(root).gotoAndStop("shorts");

    }

     

     

    or

     

     

    MovieClip(root).VideoMask.sback1_btn.addEventListener(MouseEvent.CLICK ,film1);

     

    function film1(event:MouseEvent):void{

              MovieClip(root).gotoAndStop("shorts");

    }

     

     

    The problem is the path

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points