Assigning different tasks to the button in different scenes

  • Hello.
    I have a button, keep="true" and different assignments to the click event. I want to keep it true in Scene_1, Scene_2 and Scene_3, keep false in Scene_4', Scene_5 and Scene_6, keep true in Scene_7, Scene_8 and Scene_9 and give the click event a new assignment.
    Is there a practical way to do this?

    Button of scene 1, scene 2 and scene 3:

    Code
    <plugin name="Link1"
    url="%SWFPATH%/ikon/link.png"
    keep="true"
    enabled="true"
    align="leftbottom"	
    scale="0.45" 
    x="3" y="240"
    scale.mobile="0.45" bgalpha="0.20"
    visible="true"
    onclick="openurl('http://demo1111.com', );"	/>


    Button of scene 7, scene 8 and scene 9:

    Code
    <plugin name="Link1"
    url="%SWFPATH%/ikon/link.png"
    keep="true"
    enabled="true"
    align="leftbottom"
    scale="0.45"
    x="3" y="240"
    scale.mobile="0.45" bgalpha="0.20"
    visible="true"
    onclick="openurl('http://demo2222.com', );" />



    I'm using the same button names. I place it in the same location.

    I want this button to appear in certain scenes and not in certain scenes. I can do this by recreating it within each scene. But I am looking for a more practical method.
    I also want to assign different click properties to this button.
    Thanks in advance to those who can help.

  • Hi,

    Have you tried getting the current scene name?

    Code
    set(currentscene, get(global.xml.scene) );
    If(currentscene.name == scene_1,
    ,
    )

    if you add an attribute to the scene something like

    Code
    <scene name="scene_1" ... linkedurl="https//demo1111.com"</scene>


    you could even define your hotspot like :


    Code
    <hotspot ...onclick="set(currentscene, get(global.xml.scene) ); openurl(get(currentscene.linkedurl));"

    (not tried it, just an idea)

  • Hi,

    another approach could be:

    set in each scene a 'tag' or lets call it 'demo':

    Code
    <scene name="scene_1" ... demo="http://demo1111.com"</scene>
    bla bla
    <scene name="scene_7" ... demo="http://demo2222.com"</scene>

    There are more ways of doing this of course.
    hope it helps

    Tuur
    *thumbsup*

  • It worked well. Thank you.

    I use the same technique in the info button. One fact sheet is valid for several scenes. The information text is too long, writing it separately for each scene makes it longer.
    I want an info button to be valid in the cases where I specify it, and invalid in the others. What do you think is the answer to this simple question? :)

  • Code
    <action name="DoDemo">
    		set(plugin[Link1].visible,true);
    		demo='http://demo1111.com'; 
    		calc(plugin[Link1].onclick, 'openurl(demo,_blank);');
    	</action>


    How can I define the variable inside the action?
    What is correct coding?

  • Quote

    How can I define the variable inside the action?


    see my previous example.
    What you try to do makes no sense to me.

    You can do:
    <events name="demo" keep="true" onnewscene="DoDemo();" />

    and in action
    calc(demo, scene[get(xml.scene)].demo);
    calc(plugin[Link1].onclick, 'openurl(' + demo + ',_blank);');

    but that is the same as:
    calc(plugin[Link1].onclick, 'openurl(' + scene[get(xml.scene)].demo + ',_blank);');

    Quote

    I use the same technique in the info button. One fact sheet is valid for several scenes. The information text is too long, writing it separately for each scene makes it longer.
    I want an info button to be valid in the cases where I specify it, and invalid in the others. What do you think is the answer to this simple question? :)

    You can put the text in <data ...

    <data name="html_bla">
    blablblablablablablabla
    </data>

    and use the same technic, construct with calc, to pick up the right data.

    like: calc(plugin[Link1].html, 'data:html_' + scene[get(xml.scene)].txt);

    Tuur *thumbsup*

  • Hi,

    another approach could be:

    set in each scene a 'tag' or lets call it 'demo':

    Code
    <scene name="scene_1" ... demo="http://demo1111.com"</scene>
    bla bla
    <scene name="scene_7" ... demo="http://demo2222.com"</scene>

    There are more ways of doing this of course.
    hope it helps

    Tuur
    *thumbsup*

    How do I define the second variable here?
    [code]<scene name="scene_1" ... demo2="scene[get(xml.scene)].name"</scene>


    I want to get a stage name. I will use a link to share this scene.
    openurl(' + demo1 + demo2 + ',_blank);

    Thank you for your help

Participate now!

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