PDA

View Full Version : [FMX] Help with scroller script



FLyons
April 4th, 2004, 12:31 PM
This scroller doesn't scroll all the way, it has something to do with the script. The scroller shows about half of the images. I'm a newbie action script coder, I'm just not getting why the script is messed up. I got the script from some flash scroller sample [actionscript-toolbox.com]. If anyone could take a look at the RESIDENTIAL link [members.rogers.com/flyons] and tell me what i'm doing wrong it would be appreciated.
PS. I can email the fla file (it's too large to attach).

Thanks

afxtwn
April 4th, 2004, 01:06 PM
Hi

I'm a newbie to but i got something you could try. Have you made sure that the x dimensions of your image scroller have been added to the distance?


onClipEvent (enterFrame)
{
var distance=_root._xmouse-xcenter;
_x+=(distance*speed);
if (_x > 0) _x=-300;
if (_x < -300) _x=0;
}

So if your movie clip is 600 px wide, change 300 to 600?

If you've already done that then i'm not sure whats wrong :thumb:

FLyons
April 5th, 2004, 05:46 PM
Hi AFXTWN, I did that, perhaps I'm not doing it right...
Here is the code that i'm using:
onClipEvent (load) {
nScreenWidth = 689; //dimension of screen
nMaxSpeed=15;
function moveLeft(nPixels){
this._x -= nPixels;
if(this._x <0-nScreenWidth){
this._x=0;
}
}
function moveRight(nPixels){
this._x += nPixels;
if(this._x > 0){
this._x = 0-nScreenWidth;
}
}
}
onClipEvent (enterFrame) {
if(_root._xmouse < nScreenWidth/2 && _root._xmouse >0){
moveRight(nMaxSpeed - _root._xmouse*nMaxSpeed/(nScreenWidth/2));
}else{
if(_root._xmouse > nScreenWidth/2 && _root._xmouse < nScreenWidth){
moveLeft(_root._xmouse*nMaxSpeed/(nScreenWidth/2)-nMaxSpeed);
}
}
}

Where in this code do I state the length of the scroll image (1360px long)?

afxtwn
April 5th, 2004, 05:56 PM
This script is different from the one i'm looking at, but have you tried changing the nScreenWidth number?

Have a look at http://www.kirupa.com/developer/mx/infinite.htm <-- i think thats an easier way of doing what you want to do.

FLyons
April 5th, 2004, 07:49 PM
Yeah, I like this new scroller, I'll try to modify mine to use this code...thanks

FLyons
April 6th, 2004, 01:20 PM
This script is different from the one i'm looking at, but have you tried changing the nScreenWidth number?

Have a look at http://www.kirupa.com/developer/mx/infinite.htm <-- i think thats an easier way of doing what you want to do.

FLyons
April 6th, 2004, 01:21 PM
Thanks AFXTWN, the new code works beautifully!

afxtwn
April 6th, 2004, 01:26 PM
Glad to help :pleased:

I recommend having a look at each of the tutorials on the kirupa site, they are all awesome, and if theres anything you wanna do, chances are you can learn it from one of the tut's!