I have a Flash project with several labeled frames. The user will be doing a lot of moving about those frames, so I wanted to simplify my navigational interface code-wise. There are six buttons, I have attached functions to them like so:
Actionscript Code:
topnavbt.addEventListener(MouseEvent.MOUSE_DOWN,lookUp);
function lookUp(event:MouseEvent):void
{
gotoAndStop(FrameLabel(uparea));
}
ritnavbt.addEventListener(MouseEvent.MOUSE_DOWN,lookRight);
function lookRight(event:MouseEvent):void
{
gotoAndStop(FrameLabel(rightarea));
}
botnavbt.addEventListener(MouseEvent.MOUSE_DOWN,lookDown);
function lookDown(event:MouseEvent):void
{
gotoAndStop(FrameLabel(downarea));
}
lftnavbt.addEventListener(MouseEvent.MOUSE_DOWN,lookLeft);
function lookLeft(event:MouseEvent):void
{
gotoAndStop(FrameLabel(leftarea));
}
fornavbt.addEventListener(MouseEvent.MOUSE_DOWN,walkForward);
function walkForward(event:MouseEvent):void
{
gotoAndStop(FrameLabel(forwardarea));
}
baknavbt.addEventListener(MouseEvent.MOUSE_DOWN,walkBack);
function walkBack(event:MouseEvent):void
{
gotoAndStop(FrameLabel(backarea));
}
So then I needed to define variables on the first frame that hold the frame label data:
Code:
var uparea: FrameLabel;
var downarea: FrameLabel;
var leftarea: FrameLabel;
var rightarea: FrameLabel;
var forwardarea: FrameLabel;
var backarea: FrameLabel;
Now, on each frame, I want to define which frames (or frame labels in this case) are around the user's current position. I tried this:
Actionscript Code:
uparea = 'skylights';
downarea = 'frontdoor';
leftarea = 'leftdoor';
rightarea = 'rightdoor';
//There is no forwardarea, the button won't be there on this frame anyway
//There is no backarea, the button won't be there on this frame anyway
However, Flash tells me "1067: Implicit coercion of a value of type String to an unrelated type flash.display:FrameLabel."
If I try to use:
Actionscript Code:
uparea = FrameLabel('skylights');
downarea = FrameLabel('frontdoor');
leftarea = FrameLabel('leftdoor');
rightarea = FrameLabel('rightdoor');
//There is no forwardarea, the button won't be there on this frame anyway
//There is no backarea, the button won't be there on this frame anyway
...instead, I get "TypeError: Error #1034: Type Coercion failed: cannot convert "skylights" to flash.display.FrameLabel."
I can't seem to wrap my head around what these errors are saying, but I'm sure there's a simple solution I'm missing. I think I just don't know how to define the frame label correctly. Any help would be appreciated.