[FONT=Georgia]Hi ya,
Would anyone be able to offer me some support with a problem I am experiencing with AS3 Parallax scroller?
I have some frame labels set up not to have any scroll effect… But when I remove the frames that have a parralax I recieve this message as soon as I enter the label that contains the non-scrolling scene:
“TypeError: Error #1009: Cannot access a property or method of a null object reference.
at new_22jan_fla::MainTimeline/scroll_front()”
My code on the frame label that has a scrolling parallax effect is as follows:
[COLOR=SeaGreen]stop();
var speed1:Number = 20;
var speed2:Number = 10;
var mc2Width:Number = back_mc.width;
var mc2X:Number = back_mc.x;
var stageWidth:Number = stage.stageWidth;
/trace("mc2Width = "+mc2Width);
trace("stageWidth = "+stageWidth);
trace("calc = "+(stageWidth-mc2Width));/
back_mc.addEventListener(Event.ENTER_FRAME, scroll_back);
front_mc.addEventListener(Event.ENTER_FRAME, scroll_front)
function scroll_back(e:Event):void {
var xdist:Number = stage.mouseX-(stageWidth/2);
//trace("xdist = "+xdist);
mc2X += -xdist/speed1;
//trace("mc2X = "+mc2X);
if (mc2X>=0) {
//trace(“0”);
mc2X = 0;
}
if (mc2X<=-1150.8) {
//trace(stageWidth-mc2Width);
mc2X = -1150.8;
}
back_mc.x = mc2X;
}
function scroll_front(e:Event):void {
var xdist:Number = stage.mouseX-(stageWidth/2);
//trace("xdist = "+xdist);
mc2X += -xdist/speed2;
//trace("mc2X = "+mc2X);
if (mc2X>=0) {
//trace(“0”);
mc2X = 0;
}
if (mc2X<=-1150.8) {
//trace(stageWidth-mc2Width);
mc2X = -1150.8;
}
front_mc.x = mc2X;
}
[/COLOR]
[COLOR=Black]Any assistance with resolving my problem would be appreciated, thank you.
[/COLOR][/FONT]