kaitco
05-27-2009, 12:42 AM
I am using this tutorial (http://www.pixelhivedesign.com/tutorials/Endless+Scrolling+Background/) to create a header with a scrolling background and a static image set above that background.
I have got the background to scroll properly, but I cannot get the second static content to appear in the movie. The instructions in the tutorial to "Attach Content Dynamically" do not give the same kind of step-by-step information as the reset of the tutorial, so I am not sure how to add the static content.
I think my main problem is that I do not understand the theory behind how "attachMovie" works, so I do not know where to add what code and how to add it.
Here is the ActionScript I have got so far:
animator = createEmptyMovieClip('animator',1);
scrollpic_1 = animator.attachMovie('scrollpic_mc','scrollpic_1',1);
scrollpic_2 = animator.attachMovie('scrollpic_mc','scrollpic_2',2);
scrollpic_1._x = -scrollpic_1._width/2;
scrollpic_2._x = scrollpic_2._width/2;
speed = 1;
cloudWidth = 2105;
animator.onEnterFrame = function(){
scrollpic_1._x -= speed;
scrollpic_2._x -= speed;
if(scrollpic_1._x <= -scrollpic_1._width) scrollpic_1._x = cloudWidth;
if(scrollpic_2._x <= -scrollpic_2._width) scrollpic_2._x = cloudWidth;
}
this.attachMovie("titlepic_mc", "pic", 2);
where "titlepic_mc" is the movie clip identifier of the static image I plan to hover over the scrolling image.
Ideally, the bold code would add the movie clip at a depth higher than the code before it, but I cannot see it. I have tried removing all the ActionScript before the bold piece and still cannot see at least the static image, proving to me that I do not understand how attachMovie is supposed to work.
Can anyone tell me where I have gone wrong with the ActionScript for this?
Many thanks!
I have got the background to scroll properly, but I cannot get the second static content to appear in the movie. The instructions in the tutorial to "Attach Content Dynamically" do not give the same kind of step-by-step information as the reset of the tutorial, so I am not sure how to add the static content.
I think my main problem is that I do not understand the theory behind how "attachMovie" works, so I do not know where to add what code and how to add it.
Here is the ActionScript I have got so far:
animator = createEmptyMovieClip('animator',1);
scrollpic_1 = animator.attachMovie('scrollpic_mc','scrollpic_1',1);
scrollpic_2 = animator.attachMovie('scrollpic_mc','scrollpic_2',2);
scrollpic_1._x = -scrollpic_1._width/2;
scrollpic_2._x = scrollpic_2._width/2;
speed = 1;
cloudWidth = 2105;
animator.onEnterFrame = function(){
scrollpic_1._x -= speed;
scrollpic_2._x -= speed;
if(scrollpic_1._x <= -scrollpic_1._width) scrollpic_1._x = cloudWidth;
if(scrollpic_2._x <= -scrollpic_2._width) scrollpic_2._x = cloudWidth;
}
this.attachMovie("titlepic_mc", "pic", 2);
where "titlepic_mc" is the movie clip identifier of the static image I plan to hover over the scrolling image.
Ideally, the bold code would add the movie clip at a depth higher than the code before it, but I cannot see it. I have tried removing all the ActionScript before the bold piece and still cannot see at least the static image, proving to me that I do not understand how attachMovie is supposed to work.
Can anyone tell me where I have gone wrong with the ActionScript for this?
Many thanks!