You are not logged in.

1

Sunday, March 30th 2014, 3:55am

pass variable to one function

I, i have to do a function with some variable, and i have to pass this variable with the call of function, how i have to do?

Example:

function abc{
if (x=true){
open image z
} else {
trace y
}

abc(true,image.jpg,hello);

what is the correct function for to do this?
Thanks.

Posts: 1,082

Location: Russia, Kaliningrad

  • Send private message

2

Sunday, March 30th 2014, 8:51am

Hi!

Source code

1
2
3
4
5
6
7
<action name="abc">
	if(%1 == true,
		set(layer[image_z].url,%2);
	,
		trace(%3);
	);
</action>



and call action abc(true,images/image.jpg,Hello);
where %1 - true, %2 - images/image.jpg, %3 - Hello

Regards
Andrey
VRAP - desktop VR content player based on krpano.
Common tasks in one place in one click! Discussion thread
DOWNLOAD for MAC
DOWNLOAD for WIN

3

Wednesday, April 2nd 2014, 8:57pm

Hi, thanks, i have changed the code, is right?
Thanks.

<action name="popup">
if(%1 == true,
set(layer[bg].visible,true);
,
set(layer[popupimage2%].visible,true);
,
tween(layer[popupimage2%].alpha,1.0,0.5);
);
if(1% == false,
tween(layer[popupimage2%].alpha,0,0.5,default,set(visible,false));
,
set(layer[bg].visible,false);

</action>

popup(true,7);

Umalo

Professional

Posts: 1,051

Location: Osijek, Croatia, EU

  • Send private message

4

Thursday, April 3rd 2014, 9:53am

This is not correct syntax you wrote. Follow example from Andrey. You can also use if(%1,.....

IF(condition,
trace(action if condition true);
,
trace(action if condition false);
);

5

Thursday, April 3rd 2014, 3:07pm

Ok now i have understand, bur have another problem..

with this is working:

<action name="popup">
if(%1 == true,
set(layer[bg].visible,true);
set(layer[popupimage1].visible,true);
tween(layer[popupimage1].alpha,1.0,0.5);
,
tween(layer[popupimage1].alpha,0,0.5,default,set(visible,false));
set(layer[bg].visible,false);
);
</action>

but if i try to add 2% to the "popupimage" string for to pass the variable with the name of layer, it is not working

<action name="popup">
if(%1 == true,
set(layer[bg].visible,true);
set(layer[popupimage2%].visible,true);
tween(layer[popupimage2%].alpha,1.0,0.5);
,
tween(layer[popupimage2%].alpha,0,0.5,default,set(visible,false));
set(layer[bg].visible,false);
);
</action>

How i can add some numbers to the string "popupimage" and have popupimage1, popupimage2, popupimage7.....
Thanks.

Umalo

Professional

Posts: 1,051

Location: Osijek, Croatia, EU

  • Send private message

6

Thursday, April 3rd 2014, 3:53pm

txtadd(imagetopopup,'popupimage',%2);
tween(layer[get(imagetopopup)].alpha,0,0.5);

7

Thursday, April 3rd 2014, 4:22pm

Thanks. now is perfect!!
For everyone that have to open more image from hotspot, i have used this method.

The code is this:

<layer name="bg" type="container" keep="true" visible="false" bgcolor="0x000000" bgalpha="0.8" align="lefttop" width="100%" height="100%"/>

<action name="popup">
txtadd(imagetopopup,'popupimage',%2);
if(%1 == true,
set(layer[bg].visible,true);
set(layer[get(imagetopopup)].visible,true);
tween(layer[get(imagetopopup)].alpha,1.0,0.5);
,
tween(layer[get(imagetopopup)].alpha,0,0.5,default,set(visible,false));
set(layer[bg].visible,false);
);
</action>

<layer name="popupimage1" url="images/myimage1.jpg" align="center" width="70%" height="prop" visible="false" alpha="0" onclick="popup(false,1);" />
<layer name="popupimage2" url="images/myimage2.jpg" align="center" width="70%" height="prop" visible="false" alpha="0" onclick="popup(false,2);" />

hotspot name="q1" url="skin/info-icon.png" ath="-95.582" atv="2.619" scale="0.7" onhover="showtext(Info opera, style1);" onclick="popup(true,1);" />
hotspot name="q2" url="skin/info-icon.png" ath="-95.582" atv="2.619" scale="0.7" onhover="showtext(Info opera, style1);" onclick="popup(true,2);" />

8

Thursday, April 3rd 2014, 4:40pm

Now, the last suggestion, how i can open a movie in popup instead of image?
Thanks.