RM3.0
08-27-2009, 12:45 AM
var btnInstance:Array = new Array();
for(var i = 0; i < 3; i++)
{
var test_mc:testMC = new testMC;
addChild(test_mc);
test_mc.x = 275;
btnInstance[i] = test_mc;
btnInstance[i].buttonMode = enabled;
btnInstance[i].text01.selectable = false;
}
//Labels
btnInstance[0].text01.text = "First Button";
btnInstance[1].text01.text = "Second Button";
btnInstance[2].text01.text = "Third Button";
//Positions
btnInstance[0].y = 64;
btnInstance[1].y = 128;
btnInstance[2].y = 192;
//Actions
btnInstance[0].addEventListener(MouseEvent.MOUSE_OVER, btnInAnim);
btnInstance[1].addEventListener(MouseEvent.MOUSE_OVER, btnInAnim);
btnInstance[2].addEventListener(MouseEvent.MOUSE_OVER, btnInAnim);
function btnInAnim(event:MouseEvent):void
{
var AnimTarget = event.target;
AnimTarget.gotoAndPlay(2);
AnimTarget.removeEventListener(MouseEvent.MOUSE_OV ER, btnInAnim);
AnimTarget.addEventListener(MouseEvent.MOUSE_OUT, btnOutAnim);
}
function btnOutAnim(event:MouseEvent):void
{
var AnimTarget = event.target;
AnimTarget.gotoAndPlay(9);
AnimTarget.removeEventListener(MouseEvent.MOUSE_OU T, btnOutAnim);
AnimTarget.addEventListener(MouseEvent.MOUSE_OVER, btnInAnim);
}
I have this code on my Flash File to make instances of three movie clips as buttons. The animation works for the buttons, but rolling over the text field gives the following error:
ReferenceError: Error #1069: Property gotoAndPlay not found on flash.text.TextField and there is no default value.
at LoopArrayExercise_fla::MainTimeline/btnInAnim()
I know why there's an error (it says it plain as day), but the only way I can think to fix it would be to break apart the text....of course, breaking apart the text would make the text uneditable. So, I wanted to see if anyone had any ideas on what could be done to rectify this.
A secondary problem I wanted to fix, is how the text field seems to block the button animation. (If I roll over or out of any section of the button that's not covered by the text field, the animation plays. Anywhere inside the text field is unresponsive.) I have a feeling fixing the primary problem would fix the secondary problem though...
for(var i = 0; i < 3; i++)
{
var test_mc:testMC = new testMC;
addChild(test_mc);
test_mc.x = 275;
btnInstance[i] = test_mc;
btnInstance[i].buttonMode = enabled;
btnInstance[i].text01.selectable = false;
}
//Labels
btnInstance[0].text01.text = "First Button";
btnInstance[1].text01.text = "Second Button";
btnInstance[2].text01.text = "Third Button";
//Positions
btnInstance[0].y = 64;
btnInstance[1].y = 128;
btnInstance[2].y = 192;
//Actions
btnInstance[0].addEventListener(MouseEvent.MOUSE_OVER, btnInAnim);
btnInstance[1].addEventListener(MouseEvent.MOUSE_OVER, btnInAnim);
btnInstance[2].addEventListener(MouseEvent.MOUSE_OVER, btnInAnim);
function btnInAnim(event:MouseEvent):void
{
var AnimTarget = event.target;
AnimTarget.gotoAndPlay(2);
AnimTarget.removeEventListener(MouseEvent.MOUSE_OV ER, btnInAnim);
AnimTarget.addEventListener(MouseEvent.MOUSE_OUT, btnOutAnim);
}
function btnOutAnim(event:MouseEvent):void
{
var AnimTarget = event.target;
AnimTarget.gotoAndPlay(9);
AnimTarget.removeEventListener(MouseEvent.MOUSE_OU T, btnOutAnim);
AnimTarget.addEventListener(MouseEvent.MOUSE_OVER, btnInAnim);
}
I have this code on my Flash File to make instances of three movie clips as buttons. The animation works for the buttons, but rolling over the text field gives the following error:
ReferenceError: Error #1069: Property gotoAndPlay not found on flash.text.TextField and there is no default value.
at LoopArrayExercise_fla::MainTimeline/btnInAnim()
I know why there's an error (it says it plain as day), but the only way I can think to fix it would be to break apart the text....of course, breaking apart the text would make the text uneditable. So, I wanted to see if anyone had any ideas on what could be done to rectify this.
A secondary problem I wanted to fix, is how the text field seems to block the button animation. (If I roll over or out of any section of the button that's not covered by the text field, the animation plays. Anywhere inside the text field is unresponsive.) I have a feeling fixing the primary problem would fix the secondary problem though...