set(laye[name].x.normal,90)doesn't work

  • hi, i try to make one action include if....set(layer[name].x.nromal,90); set(layer[name].x.mobile,85)
    but it doesn't work,should i rewrite the layer[name] x with device check?

  • I would say that attribute device check is performed when viewer is creating objects in memory and that's why you should apply simple device check and redefine attributes you need to change. (hope it was not only up to syntax error nromal instead of normal)

  • thanks umalo
    i just set one ui_setting for the ui check
    when some bottons false than the image of bottons will no show and the others will arrange in the other way.
    the code just like
    <ui_settings info="true"
    tel="true"
    showmap="true"
    />
    and set one events onxmlcomplete="ui_startup();
    the ui_startup action like this
    <action name="ui_startup">
    if(ui_settings.info == false,

    set(layer[info].visible,false);
    set(layer[tel].x,70);
    set(layer[showmap].x,140);

    );
    if(ui_settings.tel ==false,
    set(layer[tel].visible,false);
    );
    if(ui_settings.showmap ==false,
    set(layer[showmap].visible,false);
    );

    </action>
    it works in the pc viewers, but i also set position of the layer[info]and the others with x.normal and x.mobile ,when i put x.normal and x.mobile into the action, it doesn't work.
    how to do

  • the layer was set by this
    <layer name="tel" url="%SWFPATH%/skin/vtourskin.png" crop="0|576|64|64" align="leftbottom" scale.normal="1" scale.mobile="0.8" x.normal="+140" x.mobile="112" y="0" keep="true" />

  • Explore the code from Klaus in vtrouskin related to button arrangement and learn on how to do code with less IF as possible. One solution I prepared where you decide what buttons to include via ui settings as rest is done by the code:
    Link to button arrangement demo


    Code:

    Working package download

  • Hi,

    just as note - these xml device attribute checks like '.normal' or '.tablet' are only possible in static xml declarations.

    They define if during xml parsing if that given attribute will be set or skipped.

    For dynamic action code expressions should be used, e.g. this way:

    Code
    if(device.normal, set(layer[name].x,90), set(layer[name].x,85));

    or by using calc and the ternary operator:

    Code
    set(layer[name].x, calc(device.normal ? 90 : 85));

    or:

    Code
    calc(layer[name].x, device.normal ? 90 : 85);

    The result is the same in all three examples.

    Note - 'normal' and 'mobile' and are exclusive to each other - that means when normal is true, mobile is always false and inverse.

    Best regards,
    Klaus

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!