Issue with overlap looping background animation
I recently found a great snippet AC code which allows for a smooth looping animation.
The only problem is that the looping animation will sometimes show on top of all my other layers even though the layer it in the middle. Since this is an Action Script I'm safe to assume that I need something in here to tell it to stay near the middle, somehow.
I've tried to correct this but continue to receive random pausing and figured I would ask the community.
This is my current setup
Starts on Scene1, then goes to next Scene 2 after 25 frames
- Presentation Layer (25 frames long)
- Looping Grid (Action Script Below) *Overlaping all layers
- Static Background (Never moves) *Needing the animation just above this layer
//The speed of the scroll movement.
var scrollSpeed:uint = 2;
//This adds two instances of the movie clip onto the stage.
var s1:ScrollBg = new ScrollBg();
var s2:ScrollBg = new ScrollBg();
addChild(s1);
addChild(s2);
//This positions the second movieclip next to the first one.
s1.x = 0;
s2.x = s1.width;
//Adds an event listener to the stage.
stage.addEventListener(Event.ENTER_FRAME, moveScroll);
//This function moves both the images to left. If the first and second
//images goes pass the left stage boundary then it gets moved to
//the other side of the stage.
function moveScroll(e:Event):void{
s1.x -= scrollSpeed;
s2.x -= scrollSpeed;
if(s1.x < -s1.width){
s1.x = s1.width;
}else if(s2.x < -s2.width){
s2.x = s2.width;
}
}
If anyone could help me figure out why this is happening, I would be most greatful and appreciative.
If I need to show my work I can provide a link if requested.
Thank you,
TDR
