Tweened values of MovieClips

Let me preface this with the fact that I am in the process of learning actionscript and OOP so I am not well versed in all of the references and classes and objects available to me, nor do I always understand the easiest way to do something and out of ignorance will make things complicated.

So I have used intermittent tween values before but in a much simpler case.

Right now I have coded a few functions and am trying to use mouse events to control the tweening of some text with the functions and function instantiated arrays that are stuffed with alpha values. I am apparently missing something because the text will not tween fade out using my functions. So I’m guessing the error is in my function but I’m not sure exactly what I’m doing wrong.


import fl.motion.AnimatorFactory;
import fl.motion.MotionBase;
import flash.filters.*;
import flash.geom.Point;
import fl.transitions.easing.*;
import fl.transitions.*;
import flash.events.*;

var glwFltrColor:uint = 0xFFFFFF;

var glwFltrAlphaEnd:Number = 0.6;
var glwFltrBlurXEnd:Number = 30;
var glwFltrBlurYEnd:Number = 6;

var glwFltrStrength:Number = 2;
var glwFltrQuality:int = 2;
var glwFltrInner:Boolean = false;
var glwFltrKnockout:Boolean = false;
var navGlow:GlowFilter=new GlowFilter(glwFltrColor, glwFltrAlphaEnd, glwFltrBlurXEnd, glwFltrBlurYEnd, glwFltrStrength, glwFltrQuality, glwFltrInner, glwFltrKnockout);

text0.alpha = text1.alpha = text2.alpha = text3.alpha = text4.alpha = text5.alpha = text6.alpha = 0;

navBar.nav0.addEventListener(MouseEvent.CLICK, navClick0, false, 0, true);
navBar.nav1.addEventListener(MouseEvent.CLICK, navClick1, false, 0, true);
navBar.nav2.addEventListener(MouseEvent.CLICK, navClick2, false, 0, true);
navBar.nav3.addEventListener(MouseEvent.CLICK, navClick3, false, 0, true);
navBar.nav4.addEventListener(MouseEvent.CLICK, navClick4, false, 0, true);
navBar.nav5.addEventListener(MouseEvent.CLICK, navClick5, false, 0, true);
navBar.nav6.addEventListener(MouseEvent.CLICK, navClick6, false, 0, true);

navBar.addEventListener(MouseEvent.MOUSE_OVER, navOver0, false, 0, true);
navBar.addEventListener(MouseEvent.MOUSE_OUT, navOut0, false, 0, true);

function navOver0(evt:MouseEvent):void {
	evt.target.buttonMode=true;
	evt.target.filters=[navGlow];
}
function navOut0(evt:MouseEvent):void {
	evt.target.buttonMode=false;
	evt.target.filters=[];
}

function alphaIndex(ary:Array):int {
	for (var i:int = 0; i<ary.length; i++) {
		if (ary[i] > 0) {
			var j:int = i;
		}
	}
	return j;
}

function fOutText(indexVal:int, alphaVal:int):void {
	switch (indexVal) {
		case 0:
			var textFoutTwn0:Tween=new Tween(text0,"alpha",Strong.easeIn,alphaVal,0,.25,true);
			break;
		case 1:
			var textFoutTwn1:Tween=new Tween(text1,"alpha",Strong.easeIn,alphaVal,0,.25,true);
			break;
		case 2:
			var textFoutTwn2:Tween=new Tween(text2,"alpha",Strong.easeIn,alphaVal,0,.25,true);
			break;
		case 3:
			var textFoutTwn3:Tween=new Tween(text3,"alpha",Strong.easeIn,alphaVal,0,.25,true);
			break;
		case 4:
			var textFoutTwn4:Tween=new Tween(text4,"alpha",Strong.easeIn,alphaVal,0,.25,true);
			break;
		case 5:
			var textFoutTwn5:Tween=new Tween(text5,"alpha",Strong.easeIn,alphaVal,0,.25,true);
			break;
		case 6:
			var textFoutTwn6:Tween=new Tween(text6,"alpha",Strong.easeIn,alphaVal,0,.25,true);
			break;
		default:
			trace("nada");
			break;
	}
}

function navClick0(evt:MouseEvent):void {
	trace("navClick0");

	var textAlpha:Array = new Array([text0.alpha, text1.alpha, text2.alpha, text3.alpha, text4.alpha, text5.alpha, text6.alpha]);
	fOutText(alphaIndex(textAlpha), textAlpha[alphaIndex(textAlpha)]);
	var textFinTwn:Tween=new Tween(text0,"alpha",Strong.easeIn,0,1,.5,true);
}

function navClick1(evt:MouseEvent):void {
	trace("navClick1");

	var textAlpha:Array = new Array([text0.alpha, text1.alpha, text2.alpha, text3.alpha, text4.alpha, text5.alpha, text6.alpha]);
	fOutText(alphaIndex(textAlpha), textAlpha[alphaIndex(textAlpha)]);
	var textFinTwn:Tween=new Tween(text1,"alpha",Strong.easeIn,0,1,.5,true);
}

function navClick2(evt:MouseEvent):void {
	trace("navClick2");
... etc

Do the switch cases actually get activated?

Yes, but it will only hit case 0… Which makes me think something is wrong with the alphaIndex fxn.

Will cases only check string values? I’ll try some casting because I just realized 'int’s do not have decimal places (right?), so the alphaVal should be cast as a Number. But other than that I can’t think of how to fix the alphaIndex fxn :inspector:

EDIT:
Well I think I just declared the Array incorrectly (for the way I was using it). I think I declared a multidim array with my alpha values array as the first item in my array… I instantiated it correctly and now it seems to be working. :shrug: