Skip to main content
Participant
Sep 26, 2022 9:19 PM UTC
Question

Movieclip doesn't move correctly with Actionscript

I noticed that a movieclip made from a graphic and moved by Actionscript wasn't ending up in the right place. I found that incrementing the position, with mc.x = mc.x += 0.15 sometimes increments the position correctly, but at other times the position only gets incremented by 0.10. With an increment of 0.15, there's a reproducible pattern of fail-correct-fail-correct-fail..., but it increments the position correctly every time for an increment of 0.35. With yet other values of the increment I see patterns like consistently failing every fourth time around a loop but incrementing correctly the other three. 

 

And even with an increment of 0.15, it seems to suddenly start incrementing correctly every time after the first few hundred times through a loop,

 

There's no problem correctly moving a movieclip I create within Actionscript. It seems to be an issue with movieclips created from imported graphics.

 

Has anyone else run into this? THX.

    This topic is closed to new replies. Start a new post to keep the conversation going.

    5 replies

    kglad
    Community Expert
    Community Expert
    Sep 26, 2022 10:09 PM UTC

    try somewhat less screwy looking code.  i'm not sure that will fix the problem, but:

     

    mc.x+=0.15 is shorthand for:

     

    mc.x = mc.x+0.15

     

    now, i can't see any error in using:

     

    mc.x=mc.x=mc.x+.015;

     

    which is what you're using, but it's certainly superfluous and my be triggering a rare issue.  (rare because no one else is using mc.x =  mc.x = whatever)

     

    so change:

     

    mc.x = mc.x += 0.15;

     

    to 

     

    mc.x += 0.15;

     

    and see if that resolves the problem.

    Translate
    Randy16B8Author
    Participant
    Sep 27, 2022 1:55 AM UTC

    Sorry. Typed it wrong. The code actually is mc.x += 0.15. But I also tried a more literal mc.x = mc.x + 0.15 and also mx.c = mc.x + const where const was defined to be 0.15. None of those variations changed anything.

    Translate
    kglad
    Community Expert
    Community Expert
    Sep 27, 2022 12:20 PM UTC

    have your tested with several graphics, and if so, is the problem reproducible with each?

    Translate