hello all,
I have this function on the first frame of my timeline:
var c:Number = -1;
function changeColor()
{
if(c<4){
c++
}else{
c=0;
}
var final_color:Array = new Array();
final_color[0] = 0x999999; //gray
final_color[1] = 0xFF0000; //red
final_color[2] = 0x0066CC; //blue
final_color[3] = 0xFF66CC; //pink
final_color[4] = 0x00CC66; //green
final_color[5] = 0x999999; //gray
var colorInfo:ColorTransform=menu_mc.company_txt.transform.colorTransform;
var colorInfoEx:ColorTransform=menu_mc.exhibit_txt.transform.colorTransform;
var colorInfoCn:ColorTransform=menu_mc.contact_txt.transform.colorTransform;
if(currentFrame==2){
var colorInfoAb:ColorTransform=about_mc.tf_txt.transform.colorTransform;
var alphaOverAb:Tween=new Tween(about_mc.tf_txt,"alpha",Strong.easeInOut,0,1,5,true);
alphaOverAb.addEventListener(TweenEvent.MOTION_CHANGE,tweenToFinalAb);
function tweenToFinalAb(event:TweenEvent):void
{
colorInfoAb.color = Color.interpolateColor(final_color[c],final_color[c+1],event.position);
about_mc.tf_txt.transform.colorTransform=colorInfoAb;
}
}
if(currentFrame==3){
var colorInfoXb:ColorTransform=exhibits_mc.ex_txt.transform.colorTransform;
var colorInfoNx:ColorTransform=exhibits_mc.next_txt.transform.colorTransform;
var colorInfoPs:ColorTransform=exhibits_mc.pause_txt.transform.colorTransform;
var colorInfoPr:ColorTransform=exhibits_mc.prev_txt.transform.colorTransform;
var alphaOverEx:Tween=new Tween(exhibits_mc.ex_txt,"alpha",Strong.easeInOut,0,1,5,true);
alphaOverEx.addEventListener(TweenEvent.MOTION_CHANGE,tweenToFinalEx);
function tweenToFinalEx(event:TweenEvent):void
{
colorInfoXb.color = Color.interpolateColor(final_color[c],final_color[c+1],event.position);
exhibits_mc.ex_txt.transform.colorTransform=colorInfoXb;
colorInfoNx.color = Color.interpolateColor(final_color[c],final_color[c+1],event.position);
exhibits_mc.next_txt.transform.colorTransform=colorInfo;
colorInfoPs.color = Color.interpolateColor(final_color[c],final_color[c+1],event.position);
exhibits_mc.pause_txt.transform.colorTransform=colorInfo;
colorInfoPr.color = Color.interpolateColor(final_color[c],final_color[c+1],event.position);
exhibits_mc.prev_txt.transform.colorTransform=colorInfo;
}
}
if(currentFrame==4){
var colorInfoCt:ColorTransform=cnt_mc.ct_txt.transform.colorTransform;
var alphaOverCt:Tween=new Tween(cnt_mc.ct_txt,"alpha",Strong.easeInOut,0,1,5,true);
alphaOverCt.addEventListener(TweenEvent.MOTION_CHANGE,tweenToFinalCt);
function tweenToFinalCt(event:TweenEvent):void
{
colorInfoCt.color = Color.interpolateColor(final_color[c],final_color[c+1],event.position);
cnt_mc.ct_txt.transform.colorTransform=colorInfoCt;
}
}
var alphaOver:Tween=new Tween(menu_mc.company_txt,"alpha",Strong.easeInOut,0,1,5,true);
alphaOver.addEventListener(TweenEvent.MOTION_CHANGE,tweenToFinal);
function tweenToFinal(event:TweenEvent):void
{
colorInfo.color = Color.interpolateColor(final_color[c],final_color[c+1],event.position);
menu_mc.company_txt.transform.colorTransform=colorInfo;
colorInfoEx.color = Color.interpolateColor(final_color[c],final_color[c+1],event.position);
menu_mc.exhibit_txt.transform.colorTransform=colorInfo;
colorInfoCn.color = Color.interpolateColor(final_color[c],final_color[c+1],event.position);
menu_mc.contact_txt.transform.colorTransform=colorInfo;
}
}
setInterval(changeColor,6000);
you can see that I am using the conditional if(currentFrame==x) to apply to the mc’s not on frame1
This works fine except when I navigate off frame 1 and then between frames 2-4 - I get a
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MethodInfo-62()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at fl.transitions::Tween/setPosition()
at fl.transitions::Tween/update()
at fl.transitions::Tween/set time()
at fl.transitions::Tween/nextFrame()
at fl.transitions::Tween/onEnterFrame()
(actually I get quite a few of these)
what am I doing wrong??
Thanks