View Full Version : 1119: Access of possibly undefined property myLoader....
bigmaxsstudio
February 20th, 2008, 11:44 AM
Here's the code where I keep getting the error. This is being written with the mc that handles button function. It worked before I added this.parent myLoader... - Thanks
stop();
function buttonClick(event:MouseEvent):void
{
gotoAndStop(event.target.name);
home.enabled = true;
services.enabled = true;
projects.enabled = true;
links.enabled = true;
contact.enabled = true;
event.target.enabled = false;
this.parent.myLoader.load(new URLRequest(event.target.name + ".swf"));
}
home.addEventListener(MouseEvent.CLICK, buttonClick);
services.addEventListener(MouseEvent.CLICK, buttonClick);
projects.addEventListener(MouseEvent.CLICK, buttonClick);
links.addEventListener(MouseEvent.CLICK, buttonClick);
contact.addEventListener(MouseEvent.CLICK, buttonClick);
McGuffin
February 20th, 2008, 12:57 PM
Welcome :) Well, the error means it can't find the myLoader property of this.parent... the code looks fine, you need to consider the object that "this.parent" is targeting and whether or not this is correct.
mick007x
November 11th, 2008, 12:37 PM
I have exactly the same issue (I'm using the Lynda.com Flash CS3 Professional book) - were you able to resolve your issue? Can you give me any insight as to your solution?
Thanks
Here's the code where I keep getting the error. This is being written with the mc that handles button function. It worked before I added this.parent myLoader... - Thanks
stop();
function buttonClick(event:MouseEvent):void
{
gotoAndStop(event.target.name);
home.enabled = true;
services.enabled = true;
projects.enabled = true;
links.enabled = true;
contact.enabled = true;
event.target.enabled = false;
this.parent.myLoader.load(new URLRequest(event.target.name + ".swf"));
}
home.addEventListener(MouseEvent.CLICK, buttonClick);
services.addEventListener(MouseEvent.CLICK, buttonClick);
projects.addEventListener(MouseEvent.CLICK, buttonClick);
links.addEventListener(MouseEvent.CLICK, buttonClick);
contact.addEventListener(MouseEvent.CLICK, buttonClick);
birdwing
November 11th, 2008, 01:31 PM
If guessing that myLoader is a movie clip right?
If it is then you forgot to set an instance name.. click it and in the properties tab set its instance name to myLoader (remember its case sensetive)
IF its not a movie clip and it is actually a loader than you forgot to declare the loader
so add this:
var myLoader:Loader = new Loader();
somewhere above your code..
If that doesn't work than someone else might have an idea those are two fixes that I see based on what i know of your code.
mick007x
November 11th, 2008, 02:03 PM
Thanks for your reply birdwing:
The myLoader code is contained in a movie clip - its a menu setup so that the myLoader instance on the main Timeline will load a file with the same name as the instance name of the button that is clicked. The code you suggested is on the main Timeline - but for some reason the error message keeps coming up. I have checked that every button has an instance name, which agrees to the frame label name, which agrees with the file name +.swf. The idea is that this technique allows the use of one function for all the buttons. Any other suggestions?
If guessing that myLoader is a movie clip right?
If it is then you forgot to set an instance name.. click it and in the properties tab set its instance name to myLoader (remember its case sensetive)
IF its not a movie clip and it is actually a loader than you forgot to declare the loader
so add this:
somewhere above your code..
If that doesn't work than someone else might have an idea those are two fixes that I see based on what i know of your code.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.