Copy link to clipboard
Copied
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
//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
one way to do what you want is to place a dummy movieclip on the layer where you want your bg's to appear. assign it an instance name (eg, bgParent) and use:
bgParent.addChild(s1);
bgParent.addChild(s2);
Copy link to clipboard
Copied
one way to do what you want is to place a dummy movieclip on the layer where you want your bg's to appear. assign it an instance name (eg, bgParent) and use:
bgParent.addChild(s1);
bgParent.addChild(s2);
Copy link to clipboard
Copied
Wouldn't the (s1), (s2) cause an issue?
Copy link to clipboard
Copied
not as long as they're defined and created before trying to add them. ie, replace your addChild() code with the code i showed.
Copy link to clipboard
Copied
Thank you!
I was able to get it working.
Much appreciated.
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now