Problem tweening between relative and absolute position values

  • Hi there,

    I am using tween to move a few items around the screen. In particular, I'm moving items from just outside the window inside, and back out again.

    When the item sits "outside" the top frame of the window, it's y position is "minus elementheight" relative to the top edge. I then tween it two thirds down the screen, so the position y is set to 67%. When I then tween it back outside the frame (so again back to -elementheight) then at the very beginning of the tween animation the element "teleports" itself to 67px from the top edge, and then smoothly slides out from there. So it looks like tween is not using the relative percentage-value but the value in pixels as start-point for the animation...

    Is it possible that there is a bug with the tween function, or is it just me? Interestingly enough, this happens both in the HTML5 and Flash viewer.

    Cheers,

    Florian

  • Hi,

    the tween action can only change values!

    an automatic conversion of a percent value to an absolute is not possible in this case - to make that, the tween action would need to have informations about the sizes to which the value is relative and these informations are not available - the tween action just changes the value or the given variable, but it doesn't 'know' that the variable was from a <plugin> element and that the value is relative to the size of the parent element...

    best regards,
    Klaus

  • Hi,

    when you know that your value is a percent value (but that could be also checked automatically by checking if the value contains a % character), you could try to recalculate it manually,

    when a parent is set, then the pixelwidth/pixelheight values should be used as base size and when not the stagewidth/stageheight values,

    then just multiple the percent value with that base values and divide by 100,
    e.g.

    Code
    mul(width, stagewidth);
    div(width, 100);

    best regards,
    Klaus

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!