Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Issue with overlap looping background animation

Engaged ,
May 09, 2013 May 09, 2013

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

TOPICS
ActionScript
798
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 09, 2013 May 09, 2013

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);

Translate
Community Expert ,
May 09, 2013 May 09, 2013

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);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 09, 2013 May 09, 2013

Wouldn't the (s1), (s2) cause an issue?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 09, 2013 May 09, 2013

not as long as they're defined and created before trying to add them.  ie, replace your addChild() code with the code i showed.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 10, 2013 May 10, 2013

Thank you!

I was able to get it working.

Much appreciated.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 10, 2013 May 10, 2013
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines