Forums  

Go Back   Forums > Talk > General FPP Discussion

Reply
 
Thread Tools Display Modes
  #1  
Old 03-17-2008, 10:58 PM
dougeefresh dougeefresh is offline
Junior Member
 
Join Date: Mar 2008
Posts: 19
Downloads: 0
Uploads: 0
Default How to add custom functions AND access them properly?

I am a noob and this questtion may sound stupid but I would appreciate any help! I have pano.swf in embedPano.fla and some hotspots in the pano. I wrote a custom function to play a sound clip within embedPano.fla and assigned an onClick event to the hotspot in the XML file so when the hotspot's clicked, it will play a sound. When I click on the hotspot, I get unrecognized function error. Obviously, the function is not being accessed by the XML file. Can someone tell me how to approach something like this? Thanks!
Reply With Quote
  #2  
Old 03-18-2008, 08:31 AM
cheathamlane cheathamlane is offline
Senior Member
 
Join Date: Mar 2007
Location: California, USA
Posts: 773
Downloads: 0
Uploads: 0
Default

Hey dougeefresh ( :P ) --

Here's an example with full XML showing how to group and call on your custom functions. Hope it's helpful!

http://www.flashpanos.com/content/si...o-presentation
__________________
Patrick
http://patrickcheatham.com
Reply With Quote
  #3  
Old 03-18-2008, 02:54 PM
dougeefresh dougeefresh is offline
Junior Member
 
Join Date: Mar 2008
Posts: 19
Downloads: 0
Uploads: 0
Default

Hello, Patrick!

Thanks for your reply.
I took a look at the example you showed. Is it possible to insert custom Actionscript functions in place of the functions in the "standard" fpp format?
I want to call a custom function called "playSound" using loadSound.
Thanks!

Quote:
Originally Posted by cheathamlane View Post
Hey dougeefresh ( :P ) --

Here's an example with full XML showing how to group and call on your custom functions. Hope it's helpful!

http://www.flashpanos.com/content/si...o-presentation
Reply With Quote
  #4  
Old 03-18-2008, 10:11 PM
zleifr's Avatar
zleifr zleifr is offline
Senior Member
 
Join Date: May 2007
Posts: 609
Downloads: 0
Uploads: 0
Default

Hi dougeefresh,

This is quite a user name! You can not put actionscript code in the standard FPP xml format. In fact, Flash has no eval() sort of function that could take text and execute it on the fly as actionscript. Basically it has to be compiled first in order to run.

What you can do is set up a simple plugin interface in your embedpano wrapper. Here, in fact is exactly the code you need:

var pano:Object;
var id:String="embedPanoPlugin";
var version:String="1.0";

// this function is called on plugin's start
function init (panoMain:Object=null) {
panorama.addExternal(this);
}

// this function is called when new panorama is loading
function newPano(link:Object=null) {
pano = link;
}


// this function handle XML parameters
function newParams (str:String) {
var lines:Array = str.match(/[^\s\n\r;]+[^;\n\r]+/g);
for (var i:int=0;i<lines.length;i++) {
var pair:Array = lines[i].split(/[\s]*=[\s]*/);
setAttribute(pair[0], pair[1])
}
}

// function is for external calls: "external.smartscale.mode=..."
function setAttribute (name:String, value:String, time:String=null, type:String=null, onDoneFunction:String=null, onInterruptFunction:String=null, relative:int=0) {
if (name.toLowerCase() == "dosomething"){
if (value.toLowerCase() == "jump"){
goAndJump();
}
}
}

function remove () {
}


All you have to do is copy and paste that into your .fla. Write your actionscript command in the function goAndJump(). And then in the XML, do something like this:
onClick="external.embedPanoPlugin.dosomething=jump "

It should be pretty obvious how to extend this to handle more functions. AND if you need to do things with hotspots in the pano, make sure that the hotspots object is being defined in your embedPano code, and then use hotspots.execute("commands"), where commands is literal fpp commands, or you can call a function defined in the XML: hotspots.execute("global.duckandrun")

That should help,

Zephyr
__________________
Zephyr Renner - AdvancedVirtualTours.com - zleifr @t yahoo

Improving the panoramic one mighty fine plug-in at a time: http://www.flashpanos.com

Last edited by zleifr; 03-24-2008 at 10:41 PM.
Reply With Quote
  #5  
Old 03-18-2008, 10:45 PM
dougeefresh dougeefresh is offline
Junior Member
 
Join Date: Mar 2008
Posts: 19
Downloads: 0
Uploads: 0
Default

Oh, man, my head is spinning so fast....
YOU ROCK!!! This is AWESOME!
Thanks again and I will see if I can get this working.
For now, I gotta go home and rest my brain so I can fry it again tomorrow

Doug
Reply With Quote
  #6  
Old 03-20-2008, 05:40 PM
dougeefresh dougeefresh is offline
Junior Member
 
Join Date: Mar 2008
Posts: 19
Downloads: 0
Uploads: 0
Default

OK, so I once again hit a brick wall.

I created a SWF movie with the above code called "playsound.swf" and added functions that plays and stops a mp3 (very simple mp3 player). I would like to feed mp3 file path from an XML file using playsound.swf as a plugin. "mp3url" is the variable defined in the swf, which will receive and store the mp3 path from the XML file.

The XML file has:

<playsound>
name = mp3url
value = mysong.mp3
</playsound>

and under hotspots

<spot id="hotspot01" url="playsound.swf" onLoad="external.playsound.name=value" />


Needless to say, it doesn't work

What am I doing wrong?
Reply With Quote
  #7  
Old 03-24-2008, 10:50 PM
zleifr's Avatar
zleifr zleifr is offline
Senior Member
 
Join Date: May 2007
Posts: 609
Downloads: 0
Uploads: 0
Default

Hi Doogeefresh,

The code I posted will only get two pieces of text into your program. Based on those two pieces of text, you have to make the program figure out what to do.

So, in you XML file, you have:

<playsound>
name = mp3url
value = mysong.mp3
</playsound>

Which is unneccessary if you want the program to do something in response to a click. That bit of XML would be right if you want to send information to your plugin when the plugin (and tour) starts.

So focus on something like this:

onClick="external.playsound.mp3url=path/to/mysong.mp3"


Thus you need to do something like I did to check what the text is and based on that do the appropriate things:
function setAttribute (name:String, value:String, time:String=null, type:String=null, onDoneFunction:String=null, onInterruptFunction:String=null, relative:int=0) {
if (name.toLowerCase() == "mp3url"){
startPlayingANewSound(value);
}
}

So it is checking to see if the name is mp3url, and if so, it sends the value to the function which YOU WILL WRITE that takes the url of the mp3, loads, and plays it, or whatever you want to do with it.

Hope that helps,

Zephyr
__________________
Zephyr Renner - AdvancedVirtualTours.com - zleifr @t yahoo

Improving the panoramic one mighty fine plug-in at a time: http://www.flashpanos.com
Reply With Quote
  #8  
Old 03-25-2008, 12:14 AM
cheathamlane cheathamlane is offline
Senior Member
 
Join Date: Mar 2007
Location: California, USA
Posts: 773
Downloads: 0
Uploads: 0
Default

And note that the function
Code:
setAttribute (name:String, value:String, time:String=null, type:String=null, onDoneFunction:String=null, onInterruptFunction:String=null, relative:int=0)
is a built-in FPP function, designed for capturing the name/value pairs from external.somePlugin.name=value calls.

You can have it do whatever you want, but it is the only (reliable) way you'll get info from your presentation to your SWF/Plugin.
__________________
Patrick
http://patrickcheatham.com
Reply With Quote
  #9  
Old 04-02-2008, 11:18 PM
mardelcoral mardelcoral is offline
Junior Member
 
Join Date: Apr 2008
Posts: 2
Downloads: 0
Uploads: 0
Smile

Hi,
I have followed the instructions to add custom functions but it show me this error:
"Execute dos: external.embedPanoPlugin.dosomething=jump
Unrecognized object: external.embedPanoPlugin"

I have tried to understand what I am not doing well, but I don't know...

If you can help me...

Thanks in advance!

Reply With Quote
  #10  
Old 04-02-2008, 11:39 PM
zleifr's Avatar
zleifr zleifr is offline
Senior Member
 
Join Date: May 2007
Posts: 609
Downloads: 0
Uploads: 0
Default

In external.embedPanoPlugin.dosomething=jump, embedPanoPlugin needs to be the name of your plugin, which is probably not "embedPanoPlugin"

Zephyr
__________________
Zephyr Renner - AdvancedVirtualTours.com - zleifr @t yahoo

Improving the panoramic one mighty fine plug-in at a time: http://www.flashpanos.com
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 06:05 PM.


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