Change "alpha value" of a Hotspot from a flash plugin

  • Hi Klaus and krpano community !

    Can you help me to solve this :

    I made a Hotspot.
    It is visible, alpha = 0, and when mouse is over, alpha is 1 so it is visible only when mouse is over the Hotspot.

    Code
    visible="true"
    fillcolor     ="0xffffff" fillalpha     ="0"
    fillalphahover="0.4"

    Now, i made a flash plugin.
    In this plugin, there is a button which make

    Code
    krpano.call("looktohotspot(myHS, 18, smooth(100,50,20);");

    It works.

    but now, i also want to show this hotspot when mouse is over the button in the flash plugin (because hotspot parameter "alpha" is set to 0).

    But it doesn't work, my hotspot is still invisble.

    I used in my flash plugin :

    Code
    krpano.call("looktohotspot(myHS, 18, smooth(100,50,20);set(hotspot[myHS].alpha,0.8);");

    The "looktohotspot" works fine, but the alpha doesn't change, it stays on "0".

    I guess i've done someting wrong ?

    Is it possible from a flash plugin to change "alpha value" of a hotspot if this hotspot is set to "alpha=0" ?
    It shoold be possible, of course, but i can't do it ...

    Thanks !

    Salut

  • Hi Vinyl,

    I think I found your problem.
    You're using a "call" action, instead you should be using a "set" action to change values of your hotspot.
    Here is the code you should be using:

    Code
    krpano.set("hotspot[myHS].alpha", "0.8");

    Ca devrait marcher.
    Salut.

  • Hi Ciryl !

    Thank you for your help.

    I'm using a"call" action because it is an action used in a flash plugin.

    For example :

    Code
    function dosometing (mouseevent:MouseEvent):void
    {
    
    
    krpano.call("looktohotspot(myHS, 18, smooth(100,50,20);");
    }

    You think i can use something else ?

    I've tried your code but it didn't work. I've tried also this based on your code :

    Code
    krpano.call("set(hotspot[myHS].alpha, 0.8);");

    but still doesn't work.

    I guess it should be possible, still looking for a solution ...

    By the way, thank you

    /Vinyl

  • Hi Michel,

    Of course, i've tried the solution given by Ciryl :

    In AS3, flash plugin, i did this :

    Code
    function showHS (mouseevent:MouseEvent):void
    {
    
    
    krpano.set("hotspot[hs_combine].alpha", "0.8");
    }

    But it didn't work.

    But there might be a solution in the link you gave me. In fact, i was reading it when you replied !

    You are right :

    Quote

    get / set / call Interface can be used from ActionScript Plugin.

    I'll try to do someting with the "set".

    If i find a solution, of course, i'll post it here !

    Thank you for your help

    /Vinyl

  • Hi Vinyl,

    actually I had a try and it worked with the code I gave you yesterday.

    Here is the full code working with my plugin.

    as3 code for your flash plugin:

    Code
    monBouton.addEventListener(MouseEvent.CLICK, maFonction);
    
    
    function maFonction(e:MouseEvent):void
    {
    		krpano.set("hotspot[nomDeMonHotspotDansLeFichierxml].alpha", "0.8");
    	}

    and you might try to include your other action in it, which become:

    Code
    monBouton.addEventListener(MouseEvent.CLICK, maFonction);
    
    
    function maFonction(e:MouseEvent):void
    {
    krpano.set("hotspot[nomDeMonHotspotDansLeFichierxml].alpha", "0.8");
    krpano.call("looktohotspot (nomDeMonHotspotDansLeFichierxml, 18, smooth(100,50,20);");
    }

    It works here, it should be working for you.
    If it still doesn't work, check that you don't misspell (mal ecrit) your hotspot name, and that your hotspot is enabled="true" and visible="true" in your xml file.

    ( si ca ne marche toujours pas, tu peux poster ici un morceau de code plus long (as3 et/ou xml) pour qu'on essaie de trouver l'erreur, ou me contacter par message )

    ps: thank you for answering on my post, I'll try by checking the path of all files

  • Hello Ciryl,

    Thank you again for your help.

    I know your code really seems correct and i believe you when you say it works.

    But it doesn't work with me. I 'm doing something wrong, sure !

    So, i made a really simple plugin to test this, here is the AS3 Code :

    First thing i've noticed, when i publish it with flash CS3, i have this error :

    Quote

    TypeError: Error #1006: value n'est pas une fonction.
    at navigation_fla::MainTimeline/maFonction()[navigation_fla.MainTimeline::frame1:13]

    This error is due to the code line 13 :

    Code
    krpano.set("hotspot[hs_combine].alpha", "0.8");

    When i remove this line, no error detected by Flash CS3.

    When i test my plugin in krpano, the action "looktohotspot" works fine, but the action "change alpha value" doesn't work. I'm going crazy with this !!

    In my XML file, here is the code for the plugin :

    and here is the code for the Hotspot :

    I will test your code with a really minimal xml file, in order to check if there is nothing wrong in my xml. I'll post here as soon as i've made the test.

    Thank you again !!

  • Hi,

    I found this : I can change the "alpha value" of a "image Hotspot" but not for a "polygonal hotspot" !!!

    Ciryl, the code was correct but doesn't work with my polygonal HotSpot" !!! It's weird !!

    Maybe Klaus will confirm that....

    Here is a simple example of my issue, nothing in it except a plugin and a hotspot :

    http://www.reflexion-graphic.com/ds-panorama/examples/buttons/buttons.html

    The hotspot is "visible" but "alpha = 0" sor you have to move over it to see the Hotspot. It is in the middle of the screen when you load the pano (over the house in the picture).

    Here is AS3 code (really simple) :

    Here is XML :

    Thanks

    Edited once, last by Vinyl (January 15, 2010 at 5:19 PM).

  • Hi Vinyl,

    Try this:


    Line 8 --- fillalpha instead of alpha.


    Line 10 --- added tween(fillalpha,0) when onout....

    note: the hotspot[hs_combine].alpha is 1 by default (no need to change his value)...

    SAlut.

  • Same as Michel, I think the problem with the polygonal hotspot is that you have to change the "fillalpha" value (and the borderalpha value as well later if the test is successfull).

    just one thing about Michel's xml code (that I haven't try):

    if you put onout="tween(filllapha,0)" it might not work, as when you put the mouse on the flash plugin (the "navigation-test" plugin in the xml), your mouse is physically outside the "hs-combine" plugin.

    just few words in french to be more clear... sorry...
    quand tu mettras le curseur sur le plugin "navigation-test", tu vas effectivement rendre visible le fillalpha du "hs_combine" (par la fonction que Michel a ecrit dans le code as3 ci-dessus) , mais etant donne que le curseur sera en meme temps en dehors du plugin "hs-combine" (puisque sur le plugin "navigation-test"), il executera egalement la fonction onout="tween(filllapha,0)" du "hs-combine" et le rendra immediatement invisible. Fais d'abord des test sans le onout, puis tu pourras aviser ton code xml par la suite.

  • Hi Cyril,

    I think you are making a little mistake here: *wink*

    Quote

    it might not work , ..... your mouse is physically outside the "hs-combine" plugin.

    Yes...Then no action appends (onout action does not append )... To make the onout action be executed you must first be onover... *rolleyes*

    Another thing... I noticed that the tween(filllapha,0) is not fully executed (he stops near 0 but not 0). Perhaps it is due to a tween already being in execution from the fillalphahover *whistling* ... so better to set(filllapha,0) instead of tween.

    SAlut.

  • Hi,

    Thank you for your help.
    Michel, i've tried your code but it doesn't work. But the idea is good... I've tested your code, it is "button 1" in my example. Sometimes, it shows the hotspot, sometimes not.

    Working on that code, i've noticed someting weird.

    There a new button in this example, call "button 2" :

    http://www.reflexion-graphic.com/ds-panorama/ex…ns/buttons.html

    (think to empty the "cache" before looking to the example in safari or firefox)

    The AS3 code is :

    When i put my mouse on that button, it seems that it executes "looktohotspot (hs_combine, 50, smooth(100,50,20);" and then it executes "looktohotspot (hs_combine, 100, smooth(100,50,20);"...

    Can you try this example ? Normally, it should execute the action when mouse is over, and a new action when mouse is out. But it executes the 2 actions all the time.

    Do you know why ?

  • Hi Vinyl,

    First, I am absolutely newbe about AS3... My last playing with actionscript was on flash 4 (long time ago)!!! and this is why I have interest on your request (to learn).

    Quote

    i've tried your code but it doesn't work. But the idea is good... I've tested your code, it is "button 1" in my example. Sometimes, it shows the hotspot, sometimes not.

    For me, button 1 works always well !!! only one case does not work.... when the view is already the same as the one from the looktohotspot (hs_combine, 18, smooth(100,50,20);.... in this case, the fillalpha seems to not be changed... in fact it is changed but it is not displayed because there is no refresh of the view...
    To reproduce the above, load your page, put the mouse inside the button 1(the view moves to the hotspot), put the mouse inside the hotspot (the hotspot becomes fillalpha 0), put again the mouse inside the button 1 (seems that nothing appends because the view is already the same as the looktohotspot (hs_combine, 18, smooth(100,50,20); and the fillalpha seems to not change and stays invisible), then move a little the pano.... The hotspot appears...
    So, I think something about refreshing the view must be also done to make sure all is actualised...
    Perhaps something like this:

    Code
    function maFonction2(e:MouseEvent):void
    {
    krpano.set("hotspot[hs_combine].fillalpha", "0.8");
    krpano.call("looktohotspot (hs_combine, 18, smooth(100,50,20);");
    krpano.call("updatescreen()");
    }

    note line 5...

    About the second problem... I have not really an idea... Just intuition and a little google search...

    I think the problem is that your test2 button has 2 different displaying state... and then the target is not correct on the function called by the MOUSE_OUT Event...

    Here the references I have found:
    http://livedocs.adobe.com/flash/9.0/Acti….html#MOUSE_OUT

    The target is not always the object in the display list that registered the event listener. Use the currentTarget property to access the object in the display list that is currently processing the event.

    http://www.republicofcode.com/tutorials/flash/as3events/ (look inside Event Targets and Event Propagation)

    The MovieClip myMenu_mc has three children, these are my1_btn, my2_btn, and my3_btn. The event listener function registered with myMenu_mc refers to e.target instead of e.currentTarget so that it refers to the actual button clicked and not the display object container that hosts them.

    Hope this can help...

    SALut.

  • Hi Vinyl,

    Perhaps you can try to set ButtonName.mouseChildren = false;

    Here some references I have found:
    http://www.flcodr.com/viewSnippet.php?snippetID=156
    http://flashdevz.wordpress.com/2008/08/23/as3-mousechildren/
    http://www.thoughtprocessinteractive.com/blog/the-power…nd-mouseenabled

    Hope this can help....

    SAlut.

  • Hi vinyl,

    I have tried the above test2.mouseChildren = false; but it seems to not solve the problem...

    I have tried to make the button with a simple square (so no childrens)... and it is the same...
    I noticed that when I test the movie into Flash CS4 (control --> test movie) the window output "trace" the events correctly !!!

    • when mouse_over ---> krpano.call("looktohotspot (hs_combine, 50, smooth(100,50,20);")
    • when mouse_out ---> krpano.call("looktohotspot (hs_combine, 100, smooth(100,50,20);");

    Then, it seems that the code is correct...

    I have tried with trace() instead of looktohotspot() :

    And the button works correctly in krpano....

    So, I am thinking that it is a krpano bug with the looktohotspot () action... *confused*

    Perhaps KLAUS can confirm this...


    Also, about the krpano.set("hotspot[hs_combine].fillalpha", "0.8"); problem....
    I have tried the code I gave here and it solve the problem... For me, it work always correctly now...

    Hope this can help... Let me know *wink* ...

    SAlut.

  • To start out, I know NOTHING about as3. However, can you add an invisible standard hotspot and try to look to it as a test? I believe the look to hotspot will only work with a standard hotspot. However this is just a theory at the moment.

Participate now!

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