ghughes40
05-12-2008, 11:05 PM
I have two documents (both placed in a third doc) which I'd like to share the same external .as doc as the document class, but doing so produces a ReferenceError: Error #1056.
Any idea what I am doing wrong?
I have a main movie (Main.swf) that contains two Scroll Pane components.
Each scroll pane has a separate source swf -- SkyMenu.swf and MoonMenu.swf respectively. SkyMenu and MoonMenu each contain a number of SimpleButtons. For simplicity we'll say they each have one button. SkyMenu.swf has sky1_bt and MoonMenu has moon1_bt. Those instance names are named on the stage using the property inspector.
I have created a custom class file (BgndMenuClass.as) defining the behavior of the buttons and have defined it as the document class for each of the two files (but NOT Main.swf). The code is included below.
I have checked "Automatically declare stage instances" in each file.
When I export each of the two menu files the class works.
If I have only ONE menu (either SkyMenu OR MoonMenu) in Main.swf it works fine. A soon as I add BOTH menus to Main.swf I get the the Reference Error seen below. Any help is greatly appreciated.
BgndMenuClass.as
package
{
import flash.display.MovieClip
import flash.display.SimpleButton
import flash.events.MouseEvent
import flash.text.TextField
import flash.net.LocalConnection
public class BgndMenuClass extends MovieClip
{
public var outgoing_lc:LocalConnection = new LocalConnection();
public var folderName:String;
public function BgndMenuClass()
{
trace("BgndMenu is working");
}
public function makeButt(butt_bt:SimpleButton,itemName:String)
{
butt_bt.addEventListener(MouseEvent.CLICK, itemSend);
function itemSend(event:MouseEvent):void
{
outgoing_lc.send("menu_connection", "bgndItemsExecute", itemName, folderName);
}
}
public function toggleVis(event:MouseEvent):void
{
outgoing_lc.send("menu_connection", "toggleBackVis", folderName);
}
}
}
SkyMenu.fla code:
//Folder for these items
folderName = "sky";
//Make the buttons
makeButt(sky1_bt,"sky1");
ReferenceError:
ReferenceError: Error #1056: Cannot create property sky1_bt on BgndMenuClass.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at BgndMenuClass/makeButt()
at BgndMenuClass/frame3()
Any idea what I am doing wrong?
I have a main movie (Main.swf) that contains two Scroll Pane components.
Each scroll pane has a separate source swf -- SkyMenu.swf and MoonMenu.swf respectively. SkyMenu and MoonMenu each contain a number of SimpleButtons. For simplicity we'll say they each have one button. SkyMenu.swf has sky1_bt and MoonMenu has moon1_bt. Those instance names are named on the stage using the property inspector.
I have created a custom class file (BgndMenuClass.as) defining the behavior of the buttons and have defined it as the document class for each of the two files (but NOT Main.swf). The code is included below.
I have checked "Automatically declare stage instances" in each file.
When I export each of the two menu files the class works.
If I have only ONE menu (either SkyMenu OR MoonMenu) in Main.swf it works fine. A soon as I add BOTH menus to Main.swf I get the the Reference Error seen below. Any help is greatly appreciated.
BgndMenuClass.as
package
{
import flash.display.MovieClip
import flash.display.SimpleButton
import flash.events.MouseEvent
import flash.text.TextField
import flash.net.LocalConnection
public class BgndMenuClass extends MovieClip
{
public var outgoing_lc:LocalConnection = new LocalConnection();
public var folderName:String;
public function BgndMenuClass()
{
trace("BgndMenu is working");
}
public function makeButt(butt_bt:SimpleButton,itemName:String)
{
butt_bt.addEventListener(MouseEvent.CLICK, itemSend);
function itemSend(event:MouseEvent):void
{
outgoing_lc.send("menu_connection", "bgndItemsExecute", itemName, folderName);
}
}
public function toggleVis(event:MouseEvent):void
{
outgoing_lc.send("menu_connection", "toggleBackVis", folderName);
}
}
}
SkyMenu.fla code:
//Folder for these items
folderName = "sky";
//Make the buttons
makeButt(sky1_bt,"sky1");
ReferenceError:
ReferenceError: Error #1056: Cannot create property sky1_bt on BgndMenuClass.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at BgndMenuClass/makeButt()
at BgndMenuClass/frame3()