• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Explorer ,
Sep 11, 2012 Sep 11, 2012

Copy link to clipboard

Copied

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.

TOPICS
ActionScript

Views

1.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Sep 13, 2012 Sep 13, 2012

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

Votes

Translate

Translate
LEGEND ,
Sep 11, 2012 Sep 11, 2012

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 11, 2012 Sep 11, 2012

Copy link to clipboard

Copied

Hi Ned,

Here is the new code but I am still getting the error message wheter I put the code in the main timeline or the movie clip.

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 11, 2012 Sep 11, 2012

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 11, 2012 Sep 11, 2012

Copy link to clipboard

Copied

Here is the line that is the problem.

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

This is the whole thing.

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

function film1(event:MouseEvent):void{

          gotoAndStop("shorts");

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 12, 2012 Sep 12, 2012

Copy link to clipboard

Copied

What is the complete error message that you are getting?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 12, 2012 Sep 12, 2012

Copy link to clipboard

Copied

Symbol 'VideoMask', Layer 'action 1120: Access of undefined property mcVideoMask.  mcVideoMask.sback1_btn.addEventListener(MouseEvent.CLICK,film1);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 12, 2012 Sep 12, 2012

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 12, 2012 Sep 12, 2012

Copy link to clipboard

Copied

Screen shot 2012-09-12 at 8.15.36 PM.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 12, 2012 Sep 12, 2012

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 12, 2012 Sep 12, 2012

Copy link to clipboard

Copied

Screen shot 2012-09-12 at 10.38.19 PM.png

Screen shot 2012-09-12 at 10.40.47 PM.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 13, 2012 Sep 13, 2012

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 13, 2012 Sep 13, 2012

Copy link to clipboard

Copied

Ok I think I got something working. I put the code in the MC timeline with the additions suggested by esdebon and I realized that the mask I had made was not showing up as a MC so I made it one and gave it an instance name. Now I gat a type error though.Screen shot 2012-09-13 at 2.31.32 PM.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 13, 2012 Sep 13, 2012

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 13, 2012 Sep 13, 2012

Copy link to clipboard

Copied

LATEST

The first one did it. Thank you, I really appreciate all the help guys.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 11, 2012 Sep 11, 2012

Copy link to clipboard

Copied

function film1(event:MouseEvent):void{

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

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 11, 2012 Sep 11, 2012

Copy link to clipboard

Copied

Still does the same thing. But thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines