Forums  

Go Back   Forums > Talk > General FPP Discussion

Reply
 
Thread Tools Display Modes
  #1  
Old 08-04-2009, 11:09 PM
Pat S Pat S is offline
Junior Member
 
Join Date: Jul 2009
Posts: 20
Downloads: 0
Uploads: 0
Default Assigning custom functions to variables and using them with onClick

I want to be able to have a pano load function_name into variable_name when the pano is loaded (with another_function) and use variable_name later with an onClick. This is what I'm doing. How should I be doing it correctly?

Are there illegal characters in function names (specifically the minus sign and underscore)?

<global>
function_name=="
pano.pan=-358;
pano.tilt=-13;
pano.zoom=0.8;
"
another_function="loadPano(panoName=bob&variable_n ame=global.function_name());"
</global>


<spot id="home"
onClick="variable_name);"
/>
Reply With Quote
  #2  
Old 08-05-2009, 12:19 AM
LepLep LepLep is offline
Senior Member
 
Join Date: Jun 2008
Posts: 185
Downloads: 0
Uploads: 0
Default

try this
Code:
another_function="loadPano(panoName=bob);variable_name=function_name;"
__________________
midnight sun in Troms? - 360 panorama or northern lights over Troms? - 360 panorama
anonymous tourist:"but why there is only one sun?"
Reply With Quote
  #3  
Old 08-05-2009, 03:43 AM
Pat S Pat S is offline
Junior Member
 
Join Date: Jul 2009
Posts: 20
Downloads: 0
Uploads: 0
Default

It still doesn't work.

My understanding is when you refer to a function (after it's been created) you need to add () behind it to denote that it's a function. Is that correct?

When something within the <global> tag refers to something else within the <global> tag is it not necessary to add global. in front of it?

Do you have to define a variable somewhere before you can add data to it or does merely using it with an equals sign and what you're putting in it create it on the fly?

When you use a variable you use the name by itself without anything else (e.g., the () for a function), right?

If a variable is created inside the <global> tag does that mean that variable is a global variable and needs global. in front of it?
Reply With Quote
  #4  
Old 08-05-2009, 05:31 AM
LepLep LepLep is offline
Senior Member
 
Join Date: Jun 2008
Posts: 185
Downloads: 0
Uploads: 0
Default

Quote:
My understanding is when you refer to a function (after it's been created) you need to add () behind it to denote that it's a function. Is that correct?
in AS3 - yes, in xml - no
Code:
If a variable is created inside the <global> tag does that mean that variable is a global variable and needs global. in front of it?
no, anyway it will work

my advice for beginners - use both anyway to make it more clear whats going on

you cannot really "add data"

you can just juggle with predefined in global "functions"

maybe post some xml so i could make it more clear
__________________
midnight sun in Troms? - 360 panorama or northern lights over Troms? - 360 panorama
anonymous tourist:"but why there is only one sun?"
Reply With Quote
  #5  
Old 08-05-2009, 07:02 AM
Pat S Pat S is offline
Junior Member
 
Join Date: Jul 2009
Posts: 20
Downloads: 0
Uploads: 0
Default

I'm no beginner! I've been doing it since Saturday and that's 4 whole days. In that time I've gone from raw-beginner to XML-clueless. =8^)

I really appreciate your help.

This is a greatly trimmed version of what I'm doing (there are actually 10 panos). The idea is I want a home key to return the current pano to it's opening view. I'm trying to do that by having each pano load the function (for that pano's opening view pan/tilt/zoom) into the variable panorama_opening_view and then use that in the onClick in the <spot>. Try as I might I can't even get the onClick to work with onClick="pan=-333;tilt=0;zoom=0.8;" or even onClick="pan=-333"

I know I'm missing something really small and you'll probably spot it in 6 or 7 seconds.

Code:
<hotspots>
	<global
		panorama_opening_view-1="
			pano.pan=-333;
			pano.tilt=0;
			pano.zoom=0.8;
		"
		go_1="loadPano(panoName=panoramas/toni_-1&pan=-333&tilt=0&zoom=0.8&panorama_opening_view=panorama_opening_view-1());"
	>

		<spot id="home" scale="1" static="1" alpha="0"
			alt="opening view"
			onClick="panorama_opening_view"
		/>
	</global>
</hotspots>
Reply With Quote
  #6  
Old 08-05-2009, 07:38 AM
LepLep LepLep is offline
Senior Member
 
Join Date: Jun 2008
Posts: 185
Downloads: 0
Uploads: 0
Default

this should do the job
Quote:
panoramaOpeningView1="
pano.pan=-333;
pano.tilt=0;
pano.zoom=0.8;
"
go1="loadPano(panoName=panoramas/toni1&panHome=-333&tiltHome=0&zoomHome=0.8);panoramaOpeningView1; "
__________________
midnight sun in Troms? - 360 panorama or northern lights over Troms? - 360 panorama
anonymous tourist:"but why there is only one sun?"
Reply With Quote
  #7  
Old 08-05-2009, 07:58 AM
Pat S Pat S is offline
Junior Member
 
Join Date: Jul 2009
Posts: 20
Downloads: 0
Uploads: 0
Default

But that doesn't load the pan/tilt/zoom into a variable for use with the opening view <spot>

I have the panos opening at the correct pan/tilt/zoom now but I need to be able to assign those values (they're different each time a pano is loaded) to a variable so the opening view <spot> will move to the correct position for the currently loaded pano.
Reply With Quote
  #8  
Old 08-05-2009, 08:07 AM
HansNyberg HansNyberg is offline
Senior Member
 
Join Date: Oct 2007
Posts: 611
Downloads: 0
Uploads: 0
Default

You just do it at each of your hotspots.
<spot id="f3" url="navigation/3.jpg" static="1" staticX="134.00" staticY="-10.00" align="LB" alpha="0.8" salign="LB" depth="73"
onClick="pano.leash=free; loadPano(?panoName=images/3&zoomHome=0.7&panHome=-30&tiltHome=-40&zoomHome=0.65,200,fade)"/>

Hans
Reply With Quote
  #9  
Old 08-05-2009, 08:20 AM
allSaints's Avatar
allSaints allSaints is offline
Senior Member
 
Join Date: Aug 2008
Location: Stockholm, Sweden
Posts: 945
Downloads: 0
Uploads: 0
Default

Pat,

I think you have to lower your expectations.

The XML file is just a configuration file - it's not a fullblown script language. There are no variables. There are no conditionals. The only thing you can do is name blocks of keyword assignments (here called functions). And remember that the pan, tilt and zoom, etc... are properties of one of the objects involved and therefore has to specified as such: pano.pan, pano.tilt, etc...

Tommy
Reply With Quote
  #10  
Old 08-05-2009, 08:24 AM
Pat S Pat S is offline
Junior Member
 
Join Date: Jul 2009
Posts: 20
Downloads: 0
Uploads: 0
Default

That only starts the pano at the correct pan/tilt/zoom (I'm doing that now). What I want to be able to do is have a "opening view" hotspot that moves the currently loaded pano to it's correct opening pan/tilt/zoom after the site visitor have moved/zoomed it. The pan/tilt/zoom values are different for each pano, so when a pano is loaded it needs to assign those values to a variable and that variable can be used in an onClick with the "opening vew" hotspot.

I have a function for each pano that has the pan/tilt/zoom values for that pano and I'm trying to have the pano assign (use whatever term is correct) the function to the variable when the pano loads. Then when the "opening view" hotspot is clicked it will execute the variable which has the function's pan/tilt/zoom in it and I'll be a happy camper.

Yeah, right ...
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 04:03 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.