A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: Continously Looping Background

Hybrid View

  1. #1
    Junior Member
    Join Date
    May 2005
    Posts
    13

    Continously Looping Background

    I want to have a continously looping background in my movie in such a way that there is no gap in the start and end of background movieclip when the timeline jumps from the end frame to the starting one!!

  2. #2
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    Create a movie clip slightly larger then your background.
    Bring a second copy of the movie clip onto the stage and place it just to the side of the first one.
    Then use action script to move the two movie clips over.
    As one leaves the background area, use action script to relocate it on the other side of the other movie clip. and so on and so on

  3. #3
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    Tricky technique, till you've done it once. Here's an old example, just modify it to your use.
    Attached Files Attached Files

  4. #4
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    I modified the script where the background Movieclip has 4 frames with a different background image to give it some more interst. The if statement on frame1 of the timeline randomly sets the background's frame.

    I also increased the frame rate, as this makes things much smoother.

    As in Geezer's script, you of course need to add a mask above the background layer. I just put a frame so you can see what is going on better.

  5. #5
    Quote Originally Posted by DallasNYC
    I modified the script where the background Movieclip has 4 frames with a different background image to give it some more interst. The if statement on frame1 of the timeline randomly sets the background's frame.

    I also increased the frame rate, as this makes things much smoother.

    As in Geezer's script, you of course need to add a mask above the background layer. I just put a frame so you can see what is going on better.
    I tried using your .fla to create something similar but there's still a gap between the end of the mc2 and beginning of mc1....
    What am I doing wrong??
    I am posting my fla in case you wouldn't mind taking a look at it....

    Thanks in advance for any tip,

    FayeC
    Attached Files Attached Files
    FayeC
    FayeC.com

  6. #6
    Junior Member
    Join Date
    Mar 2005
    Posts
    18
    I am kinda confused here cuz i am a new person at this, how do u use the action script? Could one of u guys walk me through, step by step, of how to do this looping background? that would be helpful

    Thanks guys

  7. #7
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    http://www.flashkit.com/tutorials/Ga...-610/index.php

    I didn't go thru the whole tutorial, but it looks like a good one.

    In the example that Geezer gave you, he isnt using any actionScript at all. He mearly has a movie clip that tweens from up to down. made a second copy of it, and placed it directly above the first. and put a mask over it all.

  8. #8
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    In the example that Geezer gave you, he isnt using any actionScript at all.
    I like it simple.

  9. #9
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    Its true, I'm so hook on action script,
    iSometimesEvenFindMyselfCammelHumpingNotesToMyself .

  10. #10
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    Your background image is centered on its orgin point.
    Open up your backgound movie clip and click on the bitmap.
    In your properties panel, you will see that x and y are -395,-52.
    You can do one of two things.

    1) change the x and y to 0,0 and rearrange your clips on the maintime line.
    (actually the y coordinate makes no difference in this example)

    or

    2) you can change the action script to account for the -395: 795-395=400
    Code:
    _root.bg_1.onEnterFrame = function(){
    	trace(this._x);
    	this._x-=1;
    	if (this._x == -400) {
    		this._x += 790*2;
    	}
    }

  11. #11
    Quote Originally Posted by DallasNYC
    Your background image is centered on its orgin point.
    Open up your backgound movie clip and click on the bitmap.
    In your properties panel, you will see that x and y are -395,-52.
    You can do one of two things.

    1) change the x and y to 0,0 and rearrange your clips on the maintime line.
    (actually the y coordinate makes no difference in this example)

    or

    2) you can change the action script to account for the -395: 795-395=400
    Code:
    _root.bg_1.onEnterFrame = function(){
    	trace(this._x);
    	this._x-=1;
    	if (this._x == -400) {
    		this._x += 790*2;
    	}
    }
    Thank you! I knew it had something to do wuith the positioning of the mc but just couldn't figure what or why.....
    Thanks....now off to finish up the movies.....

    FayeC
    FayeC
    FayeC.com

  12. #12
    Quote Originally Posted by DallasNYC
    Your background image is centered on its orgin point.
    Open up your backgound movie clip and click on the bitmap.
    In your properties panel, you will see that x and y are -395,-52.
    You can do one of two things.

    1) change the x and y to 0,0 and rearrange your clips on the maintime line.
    (actually the y coordinate makes no difference in this example)

    or

    2) you can change the action script to account for the -395: 795-395=400
    Code:
    _root.bg_1.onEnterFrame = function(){
    	trace(this._x);
    	this._x-=1;
    	if (this._x == -400) {
    		this._x += 790*2;
    	}
    }
    I must have screwed it up somehow.....I changed what you said and the first round is fine then after that there si a huge gap between the two mcs every time.....
    I can be contacted offlist at ftarzwell at fayec dot com in case you prefer.
    Although I think this is a good learning tool for the other =s who will eventually ask the same question....
    What do you use to calculate the value of x in that mc?

    FayeC
    Attached Files Attached Files
    FayeC
    FayeC.com

  13. #13
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    your bg_2 x coordinate is at 783. Since you are subtracting 5 each time. And the if statement is absolute, x==400, the second clip will never meet the condition, and will continue to scroll to the left.

    You can change the x coordinate to 785 of bg_2 and the script will work.
    or
    I realize you are trying to make the border slightly smaller to get even bands, so you can probally clean up your image in a graphics editor.
    or
    with the bg_2 at 783, I tried using 'if (this._x<-400)' and it sort of work too, but it looked like the border differed slightly each time.

  14. #14
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    There is something sinister about wanting to make this harder than it has to be.

  15. #15
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    Yes, of Course.. If all you want to do is scroll the same image. Then putting two images with tweens works fine. And no action script involved at all. Very Simple indeed.

    I like the action script method because you can then start to use different images on each pass. In fact with a little more math, you can scroll different size images. But, there's no reason to use it, unless that is your intent.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center