switch with two actions?

  • Hi,

    I have a button, that I want to use as a toggle: add a plugin and remove the same plugin. For this functionality I wrote two actions.

    But how can implement this? onclick="switch(action(one),action(two));" dont work.

    I think also in 1.0.8 there is no plugin attribute like plugin.isadded or so.

    Its no problem with two button, but I think only one button would better tu use.

    Thanks in advance
    Karl

  • Hi,

    Quote

    I have a button, that I want to use as a toggle: add a plugin and remove the same plugin. For this functionality I wrote two actions.

    But how can implement this? onclick="switch(action(one),action(two));" dont work.

    a way would be to declare two onclick attributes (e.g. onclickA and onclickB)
    and to call them from the real "onclick" event and set in onclickA and onclickB
    the normal "onclick" to the other one,
    e.g.:

    Code
    <plugin ...
            onclickA="action(one); set(onclick, onclickB() );"
            onclickB="action(two); set(onclick, onclickA() );"
            onclick="onclickA();"
            />

    but other there are also other possiblites,
    e.g. by using a "state" (action1or2 here) variable and if(),

    Code
    <plugin ...
            action1or2="1"
            onclick="if(action1or2 == 1, action(one), action(two)); switch(action1or,1,2);"
            />
    Quote

    I think also in 1.0.8 there is no plugin attribute like plugin.isadded or so.

    the "onloaded" event could be used to get noticed when the plugin was loaded and added,
    there are the following attributes about the current loading state of a plugin or hotspot,
    they could be used too:

    • plugin[name].loaded
      • "false" when not loaded or while loading
      • "true" when loaded and ready for usage
    • plugin[name].loading
      • "false" when not loaded or when loading has finished
      • "true" while loading

    best regards,
    Klaus

  • thank you for your promptly answer. both approaches work very well.

    By the way: not only your software, also your support including the response time are super.

    Greetings
    Karl

  • hii i use this code to hide my buttons but i want that the main button that do this mission will

    be changed with 2 different png (hide & show).


    i try evrything with no success


    sh

  • Hi,

    what was the problem?
    can you show your not working code?

    e.g.

    Code
    onclick="switch(url, image1.png, image2.png);"

    should work, but therefore the image1.png and image2.png must be in the same folder
    as the swf,

    to make the paths relative to the xml use such code:

    Code
    <plugin ...
    url="%CURRENTXML%/image1.png"
    ...
    onclick=switch(url, %CURRENTXML%/image1.png, %CURRENTXML%/image2.png);"
    ...
    />

    best regards,
    Klaus

Participate now!

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