:) I just read about wraping using modulus on Grant Skinner's blog:

sprite.x = (sprite.x + 5) % stage.stageWidth;

And then get where was that checkWrap methods :]
Still I'm interested in the onT methods...I don't think I will get them before 
Grant's next post.

the article about using modulus:
http://www.gskinner.com/blog/archives/2008/05/core_as3_modulu.html

L

Jesse Graupmann a écrit :
Maybe converting the actual time elapsed to a constant rate of motion could
help... who knows?


stage.align = "TL";
stage.scaleMode = "noScale";

function checkWrap ( o:DisplayObject ):void
{
        if ( o.x > stage.stageWidth ) o.x = 0;
}

var speed:Number = 1;
var tick:Number = 30;
var lastTick2:Number = getTimer();
var lastTick3:Number = getTimer();
var t:Timer = new Timer(tick);
var t2:Timer = new Timer(tick);

t.addEventListener( TimerEvent.TIMER, onT );
t2.addEventListener( TimerEvent.TIMER, onT2 );
stage.addEventListener( Event.ENTER_FRAME, onT3 );
t.start();
t2.start();


function onT( e:TimerEvent ):void
{
        //      timer
        mc.x += speed;
        checkWrap ( mc );
}


function onT2( e:TimerEvent ):void
{
        //      timer + speed
        mc2.x += (( getTimer() - lastTick2 ) / tick ) * speed;
        lastTick2 = getTimer();
        checkWrap ( mc2 );
}


function onT3( e:Event ):void
{
        //      enter frame + speed
        mc3.x += (( getTimer() - lastTick3 ) / tick ) * speed;
        lastTick3 = getTimer();
        checkWrap ( mc3 );
}


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jonathan
howe
Sent: Friday, May 23, 2008 3:53 AM
To: Flash Coders List
Subject: Re: [Flashcoders] Tweening text more smoothly - AS3

Apologies if this has already been mentioned... I discarded some of the
original posts.

If you are using a timer with a delay that does divide evenly to your frame
rate, it stands to reason that some screen updates the item will have
traveled more pixels than others.

Example: Frame rate 24 fps roughly equals .042  updates per second:

Frame 1 (.000) : Timer fires at .02, .04
Frame 2 (.042) : Timer fires at .06, .08
...
Frame 10 (.380) : Timer fires at .38, .40, .42
Frame 11 (.422) : Timer fires at .44, .46

So in this example, every ten frames/screen updates you're jumping an extra
pixel. Therefore either keeping framelength % updatedelay = 0, or forcing
screen update with updateAfterEvent() might solve the problem.

Again, sorry if someone already mentioned this.

-jonathan


On Fri, May 23, 2008 at 5:59 AM, EECOLOR <[EMAIL PROTECTED]> wrote:

You could create a bitmap using BitmapData.draw. Add that to your display
list, set cacheAsBitmap to true and things should run smootly.

Not sure if it works, but it is just another suggestion.


Greetz Erik

On 5/22/08, Vayu Robins <[EMAIL PROTECTED]> wrote:
Hej.

I am wondering if there is anything that could be done to improve the
panning/scrolling/tweening of the news items at the bottom of the this
page:

http://flashkompagniet.dk/flash/main.php

I am running a timer at 20 milliseconds Timer(20, 0);

And the news items are being moved a 1px everytime the timer event is
dispatched.

I dont think they are runnning very smoothly.  Is that just me or does
anyone else see that too.

Can anything be done?

Thanks
Vayu


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders





_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to