Hi I am new to the forum and to AS3… hope you can help me.
I am building a site in Flash CS3 using AS3.
I have a main.fla with single frame that has some core/ static elements positioned on it.
The AS of the first frame calls a MC called ‘opening_mc’: code:
import flash.display.Loader;
import flash.display.MovieClip;
import fl.transitions.Tween;
import fl.transitions.easing.*;
var opening_Mc:MovieClip = new opening_mc();
addChildAt(opening_Mc,0);
opening_Mc.x = 900;
opening_Mc.y = 150;
opening_Mc.visible = true;
Within ‘opening_mc’ are 7 separate MCs…(open_1_mc, open_2_mc, open_3_mc…etc) butted together to create a long horizontal strip (each is 900px long - using this to get over 2880px limit). Each has been placed on the stage and given an instance the same as the MC name and also a class has been exported for each in the linkage panel(Open1Mc, Open2Mc, Open3Mc…etc).
Within the MC ‘opening_mc’ there is a second MC called ‘open_nav_mc’ again with a single frame. This MC has a group/MC of buttons on the stage in a MC called ‘nav_btn_group’ containing 7 buttons (open_nav_1_btn,open_nav_2_btn…etc) and a simple box (select_box)
The following code is in the first frame of the MC ‘open_nav_mc’: code:
import flash.display.Loader;
import flash.display.MovieClip;
import fl.transitions.Tween;
import fl.transitions.easing.*;
select_box.x = 386;
nav_btn_group.addEventListener(MouseEvent.MOUSE_OVER, onNav_btnOver);
nav_btn_group.addEventListener(MouseEvent.MOUSE_OUT, onNav_btnOut);
nav_btn_group.addEventListener(MouseEvent.CLICK, onNav_btnClick);
function onNav_btnOver(evt:MouseEvent):void{
evt.target.alpha = 0.5;
}
function onNav_btnOut(evt:MouseEvent):void{
evt.target.alpha = 1;
}
function onNav_btnClick(evt:MouseEvent):void{
switch (evt.target.name){
case "open_nav_1_btn":
trace("one");
var select_boxXTween: Tween = new Tween(select_box, "x", Regular.easeOut, select_box.x, 0, 1, true);
var open_1_mcXTween: Tween = new Tween(this.opening_mc.open_1_mc, "x", Regular.easeOut, this.opening_mc.open_1_mc.x, 0, 1, true);
break;
case "open_nav_2_btn":
trace("two");
var select_boxXTween: Tween = new Tween(select_box, "x", Regular.easeOut, select_box.x, 129, 1, true);
//var open_2_mcXTween: Tween = new Tween(this.open_2_mc, "x", Regular.easeOut, this.open_2_mc.x, 0, 1, true);
break;
case "open_nav_3_btn":
trace("three");
var select_boxXTween: Tween = new Tween(select_box, "x", Regular.easeOut, select_box.x, 258, 1, true);
//var open_3_mcXTween: Tween = new Tween(this.open_3_mc, "x", Regular.easeOut, this.open_3_mc.x, 0, 1, true);
trace("hi there");
break;
case "open_nav_4_btn":
trace("four");
var select_boxXTween: Tween = new Tween(select_box, "x", Regular.easeOut, select_box.x, 386, 1, true);
//var open_4_mcXTween: Tween = new Tween(this.open_4_mc, "x", Regular.easeOut, this.open_4_mc.x, 0, 1, true);
break;
case "open_nav_5_btn":
trace("five");
var select_boxXTween: Tween = new Tween(select_box, "x", Regular.easeOut, select_box.x, 514, 1, true);
//var open_5_mcXTween: Tween = new Tween(this.open_5_mc, "x", Regular.easeOut, this.open_5_mc.x, 0, 1, true);
break;
case "open_nav_6_btn":
trace("six");
var select_boxXTween: Tween = new Tween(select_box, "x", Regular.easeOut, select_box.x, 642, 1, true);
//var open_6_mcXTween: Tween = new Tween(this.open_6_mc, "x", Regular.easeOut, this.open_6_mc.x, 0, 1, true);
break;
case "open_nav_7_btn":
trace("seven");
var select_boxXTween: Tween = new Tween(select_box, "x", Regular.easeOut, select_box.x, 771, 1, true);
//var open_7_mcXTween: Tween = new Tween(this.open_7_mc, "x", Regular.easeOut, this.open_7_mc.x, 0, 1, true);
break;
}
}
The sliding of the ‘select_box’ works perfectly when one of the buttons is pressed. However, what I want to do is to control the ‘x’ position MCs making up the horizontal strip (open_1_mc, open_2_mc, open_3_mc…etc) using a AS3 tween.
I keep getting a:
'TypeError: Error #1010: A term is undefined and has no properties. at OpenNavMc/onNav_btnClick()
I suspect this has something to do with the referencing of the specific MC in ‘opening_mc’. I have checked that all MCs have instances and class definitions… but I cannot seem to sort out the problem.
Any help would be much appreciated.
Thx