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.
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
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);
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);
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?
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");
}
Copy link to clipboard
Copied
What is the complete error message that you are getting?
Copy link to clipboard
Copied
Symbol 'VideoMask', Layer 'action 1120: Access of undefined property mcVideoMask. mcVideoMask.sback1_btn.addEventListener(MouseEvent.CLICK,film1);
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
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.
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
Copy link to clipboard
Copied
The first one did it. Thank you, I really appreciate all the help guys.
Copy link to clipboard
Copied
function film1(event:MouseEvent):void{
MovieClip(root).gotoAndStop("shorts");
}
Copy link to clipboard
Copied
Still does the same thing. But thanks.