PDA

View Full Version : scrolling background



fzappa90
03-28-2005, 04:34 PM
what action scripting do i need to add to buttons that allow my background to scroll left and right and loop around. here's an example i found

http://www.worldofwassco.com/arcade/index.htm

any help will be greatly appreciated.

p

NTD
03-28-2005, 07:30 PM
Hi,

You can create a scroller with something like this....



speed = 5;
_root.mcName.onEnterFrame = function() {
//create mouse scroll postions
if (_root._xmouse>Stage.width/2) {
_root.speed = 5;
&#125; else if &#40;_root._xmouse<Stage.width/2&#41; &#123;
_root.speed = -5;
&#125;
//create scroll
this._x += speed;
if &#40;this._x>Stage.width&#41; &#123;
this._x = 0;
&#125; else if &#40;this._x<0&#41; &#123;
this._x = Stage.width;
&#125;
&#125;


You could add another if statement to control the scroll from a button....


myScroll=false;
if&#40;myScroll&#41;&#123;
_root.mcName.onEnterFrame = function&#40;&#41; &#123;
if &#40;_root._xmouse>Stage.width/2&#41; &#123;
_root.speed = 5;
&#125; else if &#40;_root._xmouse<Stage.width/2&#41; &#123;
_root.speed = -5;
&#125;
this._x += _root.speed;
if &#40;this._x>Stage.width&#41; &#123;
this._x = 0;
&#125; else if &#40;this._x<0&#41; &#123;
this._x = Stage.width;
&#125;
&#125;
&#125;

myButton.onRelease=function&#40;&#41;&#123;
myScroll=true;
&#125;


hope it helps
NTD