Copy link to clipboard
Copied
Can anyone assist me with some Action Script errors
I created a simple menu with subs using frame labels.
The code on the main timeline of the loader page is:
var myLoader:Loader = new Loader();
myLoader.load(new URLRequest("main.swf"));
addChild(myLoader);
The code on the menu navigation movie clip is:
stop();
function buttonClick(event:MouseEvent):void
{
gotoAndStop(event.target.name);
information.enabled = true
portfolio.enabled = true
event.target.enabled = false;
this.parent.myLoader.load(new URLRequest(event.target.name + ".swf"));
}
information.addEventListener(MouseEvent.CLICK, buttonClick);
portfolio.addEventListener(MouseEvent.CLICK, buttonClick);
function subClick(event:MouseEvent):void
{
this.parent.myLoader.load(new URLRequest(event.target.name + ".swf"));
}
ww_btn.addEventListener(MouseEvent.CLICK, subclick);
uni_btn.addEventListener(MouseEvent.CLICK, subclick);
The buttons all have instance names but I keep getting the following errors
1119: Access of possibly undefined property myLoader through a reference with static type flash.display:DisplayObjectContainer.
on the line - this.parent.myLoader.load(new URLRequest(event.target.name + ".swf"));
1120: Access of undefined property subclick.
on the lines - ww_btn.addEventListener(MouseEvent.CLICK, subclick);
uni_btn.addEventListener(MouseEvent.CLICK, subclick);
I want to use Flash to build websites and am having difficulty with the navigation and loading external files.
Many thanks in advance to anyone that can help,
Lanky
Copy link to clipboard
Copied
Try replacing: this.parent.myLoader
with: MovieClip(parent).myLoader
Also, I am not sure, but you made need to create a new loader instance as well. A Loader can only have one child, and I don't know if you can use the same one twice... but you could try. The help docs may explain this.
As far as subclick goes, you need to choose your spelling... the function is named subClick