Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 01-07-2008, 09:02 PM   #1
Gamef13
Actionscript Newbie
 
Join Date: Jan 2008
Posts: 27
Send a message via MSN to Gamef13
Question Scrolling Help!

This is Probably a VERY stupid question but i want to make a scrolling background and im inputing the code into the movieclip. I went at it like this:
Code:
onClipEvent(load){
	var sspeed = 3;
}
onClipEvent(enterFrame){
	function(){
		do{
			_x -= sspeed;
		}while(_x >= 0);
	}
}
basicly i want the screen to scroll by the stage until the _x variable is less than a set number. It didnt scroll when i did this though. Can anyone help?
Gamef13 is offline   Reply With Quote
Old 01-07-2008, 09:11 PM   #2
ASWC
Super Moderator
 
ASWC's Avatar
 
Join Date: Dec 2007
Location: Greenville, SC
Posts: 6,528
Default

onClipEvent(load){
var sspeed = 3;
}
onClipEvent(enterFrame){

if(this._x >= 0){
this._x -= sspeed;
}

}
ASWC is offline   Reply With Quote
Old 01-07-2008, 09:14 PM   #3
Yahivin
Such a how'd he do 'dat
 
Join Date: Dec 2007
Location: San Diego
Posts: 32
Default

Edit: Beaten to the punch.

Additionally, is the x position of the background much great than zero to begin with?

Last edited by Yahivin; 01-07-2008 at 09:15 PM. Reason: Too slow to post
Yahivin is offline   Reply With Quote
Old 01-07-2008, 09:15 PM   #4
Gamef13
Actionscript Newbie
 
Join Date: Jan 2008
Posts: 27
Send a message via MSN to Gamef13
Default

Wow worked perfectly thanks. This is the first game i have ever worked on and so far its coming along well.
Gamef13 is offline   Reply With Quote
Old 01-07-2008, 10:52 PM   #5
Gamef13
Actionscript Newbie
 
Join Date: Jan 2008
Posts: 27
Send a message via MSN to Gamef13
Default

Srry for double post but i have another question for you all. In continuation to my first question, i have two scrolling backgrounds so that when one scrolls off the screen the other will come onto the screen. So my first scrolling background scrolls across and the second scrolling background is off the sight to the left. So i want to know how when my first background's _x value reaches -300 i want the second to start rolling into veiw from the right to the left side of the screen. This is probably confusing so plz ask for more details if needed.
Gamef13 is offline   Reply With Quote
Old 01-08-2008, 12:15 AM   #6
Yahivin
Such a how'd he do 'dat
 
Join Date: Dec 2007
Location: San Diego
Posts: 32
Default

A simple way would be to set up the first one at the correct position way off-screen to the right and have it scrolling closer so that it come on screen when the other one leaves.

For example if your first background starts at _x = 300, then your second one could start at _x = 900 scroll it in the same way.
Yahivin is offline   Reply With Quote
Old 01-08-2008, 12:17 AM   #7
Gamef13
Actionscript Newbie
 
Join Date: Jan 2008
Posts: 27
Send a message via MSN to Gamef13
Default

ya but it woundt be a loop. how can i progam it to do this continually?
Gamef13 is offline   Reply With Quote
Old 01-08-2008, 12:23 AM   #8
Yahivin
Such a how'd he do 'dat
 
Join Date: Dec 2007
Location: San Diego
Posts: 32
Default

The way I've done it is having a containing object with both backgrounds. Then do something like:

Code:
onClipEvent(enterFrame){
	bg1._x -= sspeed;
        bg2._x -= sspeed;

        if(bg1._x < -300) {
            bg1_x += 600;
        }

        if(bg2._x < -300) {
            bg2_x += 600;
        }
}
Yahivin is offline   Reply With Quote
Old 01-08-2008, 12:27 AM   #9
Gamef13
Actionscript Newbie
 
Join Date: Jan 2008
Posts: 27
Send a message via MSN to Gamef13
Default

Perfect thx
Gamef13 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
stopping scrolling for a movie clip?? zns72 ActionScript 2.0 0 06-18-2007 02:15 PM
simple scrolling help quovadimus02 ActionScript 1.0 (and below) 2 09-03-2005 09:26 PM
help with text scrolling darth Other Flash General Questions 0 09-03-2004 04:18 PM
scrolling line of images mairoLT ActionScript 2.0 8 12-11-2003 06:20 AM
scrolling lists generator object ? spoonyg Server-Side Scripting 0 01-04-2002 03:41 AM


All times are GMT. The time now is 06:36 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.