You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Wednesday, January 13th 2010, 5:25pm

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.

Source code

1
2
3
visible="true"
fillcolor     ="0xffffff" fillalpha     ="0"
fillalphahover="0.4"


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

Source code

1
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 :

Source code

1
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

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

2

Wednesday, January 13th 2010, 5:47pm

Hi Vinyl,

I have no idea.. But looking your code, I am thinking of this possibility:

Source code

1
krpano.call("looktohotspot(myHS, 18, smooth(100,50,20); set(myHS.alpha,0.8);");


Hope this can help.

SAlut.

3

Wednesday, January 13th 2010, 6:05pm

Hi Michel,

Thanks for your help !

I've tried :

Source code

1
krpano.call("set(myHS.alpha,0.8);")


But it still doesn't work. *confused*

I'm wondering if it is possible to change "alpha value" of a hotspot from a flash plugin.

Salut !

Cyril

Beginner

Posts: 11

Location: Tokyo

  • Send private message

4

Thursday, January 14th 2010, 4:36pm

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:

Source code

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


Ca devrait marcher.
Salut.

5

Thursday, January 14th 2010, 6:08pm

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 :

Source code

1
2
3
4
5
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 :

Source code

1
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

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

6

Thursday, January 14th 2010, 6:11pm

Hi Vinyl,

I think Cyril can be right... look here: http://krpano.com/docu/programming/#getsetcall

So, give a try to Cyril code...

Source code

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


SAlut.

7

Thursday, January 14th 2010, 6:23pm

Hi Michel,

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

In AS3, flash plugin, i did this :

Source code

1
2
3
4
5
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 :

Quoted

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

Cyril

Beginner

Posts: 11

Location: Tokyo

  • Send private message

8

Friday, January 15th 2010, 8:49am

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:

Source code

1
2
3
4
5
6
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:

Source code

1
2
3
4
5
6
7
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

9

Friday, January 15th 2010, 1:52pm

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 :

Source code

1
2
3
4
5
6
7
8
9
10
11
import krpano_as3_interface;

var krpano:krpano_as3_interface = krpano_as3_interface.getInstance();

test.addEventListener(MouseEvent.MOUSE_OVER, maFonction);

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


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

Quoted

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 :

Source code

1
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 :

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
	        	        <plugin name="navigation-test"
 	        url="navigation-hs-test.swf"
	        keep="true" preload="false"
 	        visible="true" enabled="true" handcursor="true" capture="true" children="true"
	        zorder="0"
 	        alpha="1.00" blendmode="screen"
 	        smoothing="true"
 	        align="bottom" edge=""
 	        x="-350" y="10" ox="" oy=""
 	        width="" height=""
 	        rotate="0"
	        parent=""
	        mask=""
	        onloaded=""
	        onover=""
	        onhover=""
	        onout=""
	        ondown=""
	        onup=""
	        onclick=""
	        />


and here is the code for the Hotspot :

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
	<hotspot name="hs_combine"
	         keep="true"
	         visible="true" enabled="true" handcursor="true" capture="true" children="true"
 	         zorder="0"
	         fillcolor     ="0xffffff" fillalpha     ="0" borderwidth     ="0.0" bordercolor     ="0xffffff" borderalpha     ="0.00"
			 fillcolorhover="0xB50E22" fillalphahover="0.4" borderwidthhover="1.0" bordercolorhover="0xB50E22" borderalphahover="0.50"
	         fadeintime="0.150" fadeouttime="0.300" fadeincurve="1.100" fadeoutcurve="0.700"
	         onover="set(plugin[titre-combine].visible,true);"
	         onhover=""
	         onout="set(plugin[titre-combine].visible,false);"
	         ondown=""
	         onup=""
	         onclick="action(move);action(show_test);"
	         flying="0"
		>
		<point ath="-22.7204" atv="  7.5905" />
		<point ath="-22.8656" atv="  7.5838" />
		
		<point ath="-22.9137" atv="  7.8785" />
		<point ath="-22.8170" atv="  7.7414" />
	</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 !!

10

Friday, January 15th 2010, 5:08pm

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) :

Source code

1
2
3
4
5
6
7
8
9
10
import krpano_as3_interface;
var krpano:krpano_as3_interface = krpano_as3_interface.getInstance();

test.addEventListener(MouseEvent.MOUSE_OVER, maFonction2);

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


Here is XML :

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
	<!-- test -->
	
		<hotspot name="hs_combine"
	         keep="true"
	         visible="true" enabled="true" handcursor="true" capture="true" children="true"
 	         zorder="0"
	         fillcolor     ="0xffffff" fillalpha     ="0" borderwidth     ="0.0" bordercolor     ="0xffffff" borderalpha     ="0.00"
			 fillcolorhover="0xB50E22" fillalphahover="0.5" borderwidthhover="1.0" bordercolorhover="0xB50E22" borderalphahover="0.50"
	         fadeintime="0.150" fadeouttime="0.300" fadeincurve="1.100" fadeoutcurve="0.700"
	         onover=""
	         onhover=""
	         onout=""
	         ondown=""
	         onup=""
	         onclick=""
	         flying="0"
		>
		<point ath="-41.3950" atv=" 15.2905" />
		<point ath=" -4.9729" atv=" 20.0814" />
		<point ath=" -5.8322" atv=" 25.8963" />
		<point ath=" -2.0872" atv=" 25.9983" />
		<point ath=" -4.8294" atv=" 41.2939" />
		<point ath="-56.1649" atv=" 25.9471" />
	</hotspot>
	
		        	
test 
-->
	        
	        	        <plugin name="navigation-test"
 	        url="navigation-hs-test.swf"
	        keep="true" preload="false"
 	        visible="true" enabled="true" handcursor="true" capture="true" children="true"
	        zorder="0"
 	        alpha="1.00" blendmode="screen"
 	        smoothing="true"
 	        origin="lefttop" edge=""
 	        x="" y=""
 	        width="" height=""
 	        rotate="0"
	        parent=""
	        mask=""
	        onloaded=""
	        onover=""
	        onhover=""
	        onout=""
	        ondown=""
	        onup=""
	        onclick=""
	        />


Thanks

This post has been edited 1 times, last edit by "Vinyl" (Jan 15th 2010, 5:19pm)


michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

11

Friday, January 15th 2010, 5:35pm

Hi Vinyl,

I think the problem is you are trying to set alpha=X when fillalpha value is already 0, so nothing to view... try to set fillalpha and borderalpha instead of alpha...

SAlut

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

12

Friday, January 15th 2010, 7:19pm

Hi Vinyl,

Try this:

Source code

1
2
3
4
5
6
7
8
9
10
import krpano_as3_interface;
var krpano:krpano_as3_interface = krpano_as3_interface.getInstance();

test.addEventListener(MouseEvent.MOUSE_OVER, maFonction2);

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

Line 8 --- fillalpha instead of alpha.

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
	<hotspot name="hs_combine"
	     	keep="true"
	     	visible="true" enabled="true" handcursor="true" capture="true" children="true"
 	     	zorder="0"
	     	fillcolor 	="0xffffff" fillalpha 	="0.00" borderwidth 	="0.0" bordercolor 	="0xffffff" borderalpha 	="0.00"
	     	fillcolorhover="0xb50e22" fillalphahover="0.50" borderwidthhover="1.0" bordercolorhover="0xb50e22" borderalphahover="0.50"
	     	fadeintime="0.150" fadeouttime="0.300" fadeincurve="1.100" fadeoutcurve="0.700"
	     	onover=""
	     	onhover=""
	     	onout="tween(fillalpha,0)"
	     	ondown=""
	     	onup=""
	     	onclick=""
	     	flying="0"
		>
		<point ath="-41.3950" atv=" 15.2905" />
		<point ath=" -4.9729" atv=" 20.0814" />
		<point ath=" -5.8322" atv=" 25.8963" />
		<point ath=" -2.0872" atv=" 25.9983" />
		<point ath=" -4.8294" atv=" 41.2939" />
		<point ath="-56.1649" atv=" 25.9471" />
	</hotspot>
.....

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.

Cyril

Beginner

Posts: 11

Location: Tokyo

  • Send private message

13

Saturday, January 16th 2010, 5:49am

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.

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

14

Saturday, January 16th 2010, 9:22pm

Hi Cyril,

I think you are making a little mistake here: ;-)

Quoted

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.

Cyril

Beginner

Posts: 11

Location: Tokyo

  • Send private message

15

Sunday, January 17th 2010, 6:23am

oups, I didn't know that!
sorry...

16

Monday, January 18th 2010, 1:13pm

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-pano…ns/buttons.html

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

The AS3 code is :

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
test2.addEventListener(MouseEvent.MOUSE_OVER, maFonction);

function maFonction(e:MouseEvent):void
{
krpano.call("looktohotspot (hs_combine, 50, smooth(100,50,20);");
}

test2.addEventListener(MouseEvent.MOUSE_OUT, maFonction2);

function maFonction2(e:MouseEvent):void
{
krpano.call("looktohotspot (hs_combine, 100, smooth(100,50,20);");
}


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 ?

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

17

Monday, January 18th 2010, 4:34pm

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).

Quoted

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:

Source code

1
2
3
4
5
6
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.

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

18

Tuesday, January 19th 2010, 8:58pm

Hi Vinyl,

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

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
test2.mouseChildren = false;
test2.addEventListener(MouseEvent.MOUSE_OVER, maFonction);

function maFonction(e:MouseEvent):void
{
krpano.call("looktohotspot (hs_combine, 50, smooth(100,50,20);");
}

test2.addEventListener(MouseEvent.MOUSE_OUT, maFonction2);

function maFonction2(e:MouseEvent):void
{
krpano.call("looktohotspot (hs_combine, 100, smooth(100,50,20);");
}


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…nd-mouseenabled

Hope this can help....

SAlut.

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

19

Thursday, January 21st 2010, 2:05am

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() :

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
test2.addEventListener(MouseEvent.MOUSE_OVER, maFonction);

function maFonction(e:MouseEvent):void
{
krpano.call("trace(The mouse is OVER);");
}

test2.addEventListener(MouseEvent.MOUSE_OUT, maFonction2);

function maFonction2(e:MouseEvent):void
{
krpano.call("trace(The mouse is OUT);");
}
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 ;-) ...

SAlut.

20

Thursday, January 21st 2010, 2:25am

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.

Similar threads