Forums  

Go Back   Forums > Talk > General FPP Discussion

Reply
 
Thread Tools Display Modes
  #11  
Old 04-03-2008, 09:19 PM
virgil_disgr4ce virgil_disgr4ce is offline
Junior Member
 
Join Date: Apr 2008
Posts: 11
Downloads: 0
Uploads: 0
Default

Hi all. I'm glad for this thread as I'm also trying to execute some custom commands. I've made a new .fla called confinoPlugin in my plugins dir using almost your exact code:

Code:
var pano:Object;
var id:String="confinoPlugin";
var version:String="1.0";

// this function is called on plugin's start
function init (panoMain:Object=null) {
	panoMain.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() == "trace"){
		trace(value);
	}
}

function remove () {
}
And included the plugin in my xml file. So I have:

Code:
layer_2  = ../panorama/plugins/confinoPlugin.swf
...
<box id="hand1" url="../panorama/hotspots/hand1.png" pan="128.00" tilt="0.00" distance="0.88" depth="0" scale="0.77" onClick="external.confinoPlugin.trace=hand"/>
But I still get:
Execute stove: external.confinoPlugin.trace=stove
Unrecognized object: external.confinoPlugin

So I'm not sure yet what I'm missing. Do I need to add anything else to the xml? Thanks so much for your help!
Reply With Quote
  #12  
Old 04-04-2008, 03:24 AM
zleifr's Avatar
zleifr zleifr is offline
Senior Member
 
Join Date: May 2007
Posts: 609
Downloads: 0
Uploads: 0
Default

I think there is some confusion. The code I posted is to be used in an embedPano.fla style wrapper that loads FPP in it, and the init function must be called to add the parent wrapper .swf into the list of plugins in FPP. HOWEVER, it is not a plugin, and is not loaded as a plugin in the XML. The benefit of this is to be able to receive calls to newPano, and setAttribute just like a plugin would, so that information can be passed from user actions defined in the XML to an embedPano style wrapper.

If all you want is to call a function in the XML, you can do that with a normal plugin, loaded as a plugin, just by using hotspots.execute("global.myXMLfunction"), assuming the function is in the global node. And if you want to have a user's action call an actionscript function in a plugin, all you need to do is use external.pluginName.name=value. And then in the setAttribute function of your plugin, which receives the name=value pair, you can use something like if, else statements on the name to figure out which actionscript function to direct execution to, and have the value as an additional piece of information if needed.

So, to recap, the code I posted is to be used in an embedPano.fla style parent .swf that subsequently loads FPP into it. And the init() function must be called after FPP has been loaded in order to open communications between the parent wrapper and FPP AS THOUGH IT WERE a plugin, since FPP is not usually expecting to be loaded as a child .swf, and has no built in provisions for communicating with a parent .swf like it does with a plugin (child) .swf.

Hopefully that will clarify some of the problems.

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
  #13  
Old 04-06-2008, 08:12 PM
virgil_disgr4ce virgil_disgr4ce is offline
Junior Member
 
Join Date: Apr 2008
Posts: 11
Downloads: 0
Uploads: 0
Default

I am still confused, and I still can't get this to work. I included the code directly in my wrapper, and I call init (which I changed to panoramaInit) on my panorama like so:

Code:
panorama.loadPanorama("xml_file=../panorama/kitchen/kitchen.xml");
panoramaInit(panorama);
All the other code is exactly the same as I posted above, and I still get the same error:

Code:
Execute stove: external.confinoPlugin.trace=stove
Unrecognized object: external.confinoPlugin
Do I have to manually call newPano, newParams, or setAttribute anywhere? I know I'm missing some fundamental concept or piece of information. Is there any documentation on this functionality?

Thanks so much for your help!
Reply With Quote
  #14  
Old 04-06-2008, 10:37 PM
cheathamlane cheathamlane is offline
Senior Member
 
Join Date: Mar 2007
Location: California, USA
Posts: 773
Downloads: 0
Uploads: 0
Default

I think it is required that there be a functioned named "init", so you should add it back, or just use it as is...

[ps: can you post your FLA?]
__________________
Patrick
http://patrickcheatham.com
Reply With Quote
  #15  
Old 04-06-2008, 11:39 PM
virgil_disgr4ce virgil_disgr4ce is offline
Junior Member
 
Join Date: Apr 2008
Posts: 11
Downloads: 0
Uploads: 0
Default

I'm calling init() explicitly... it doesn't appear to be called by FPP. Everything executes correctly except for the actual hotspot onClick; init() is called correctly, as is newPano, and I figured out that newParams handles plugin-specific parameters in the XML.

So it appears the problem is specifically that my hotspots' onClick="external.confinoPlugin.trace=test" isn't right or isn't being understood. The problem is Unrecognized object: external.confinoPlugin -- I don't understand yet why this isn't being recognized.

I'd love to post my FLA but it's part of a huge project x_x

Any more insights?
Reply With Quote
  #16  
Old 04-07-2008, 01:31 AM
cheathamlane cheathamlane is offline
Senior Member
 
Join Date: Mar 2007
Location: California, USA
Posts: 773
Downloads: 0
Uploads: 0
Default

My experience is that init() is used by FPP, and not including it can hamstring your plugin. In most of the stock FPP plugins, Denis's comment states that init() is required.

I won't really be able to talk anymore about what you're doing in the abstract w/o seeing an actual FLA or online implementation -- too tough to troubleshoot otherwise.

One thing I would do is create a plugin whose only function is to be a test -- strip it away from the rest of your huge project.

Cheers,
__________________
Patrick
http://patrickcheatham.com
Reply With Quote
  #17  
Old 04-07-2008, 04:18 AM
virgil_disgr4ce virgil_disgr4ce is offline
Junior Member
 
Join Date: Apr 2008
Posts: 11
Downloads: 0
Uploads: 0
Talking

OK, I went ahead and modeled my exact situation in a duplicate of the embedPano.fla example file. If you drop this in the FPP examples directory it should work immediately upon compiling with existing v2 files. I have added zleifr's plugin (or pseudo-plugin) code and added manual init() calls; the only other change to the stock code is using embedded xml instead of the default call.

So when you run it and choose the "garden" panorama, there will be a nice floating "+" hotspot. I want to be able to execute my custom actionscript function when you click on that.

Hopefully with this example we can figure this out once and for all!! Thanks so much for your attention and patience, I really appreciate it
Attached Files
File Type: zip embedPano_external_as.fla.zip (8.6 KB, 28 views)
Reply With Quote
  #18  
Old 04-09-2008, 08:47 PM
virgil_disgr4ce virgil_disgr4ce is offline
Junior Member
 
Join Date: Apr 2008
Posts: 11
Downloads: 0
Uploads: 0
Default

Any ideas guys? I know I'm close!!! I could really use just a little more help Thanks!!
Reply With Quote
  #19  
Old 04-10-2008, 04:53 PM
cheathamlane cheathamlane is offline
Senior Member
 
Join Date: Mar 2007
Location: California, USA
Posts: 773
Downloads: 0
Uploads: 0
Default

Quote:
Originally Posted by virgil_disgr4ce View Post
Any ideas guys? I know I'm close!!! I could really use just a little more help Thanks!!
Hey there:

You cannot have your embedPano also be a Plugin.

Your container (embedPano) SWF loads FPP into it. FPP then loads hotspots and plugins into itself. So, when using an embedPano style setup you end up with:
Container SWF
FPP (pano.swf)
Panorama(s)
Plugins
Hotspots
What you will need to do is make an embedPano container for your FPP presentation and create a separate plugin. All the below code from your embedPano wrapper should be in its own FLA/SWF (say, "confinoPlugin.fla"):

Code:
var pano:Object;
var id:String="confinoPlugin";
var version:String="1.0";

// this function is called on plugin's start
function init (panoMain:Object=null) {
	panoMain.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() == "trace"){
		trace(value);
	}
}

function remove () {
}
So that the XML portion of your embedPano FLA looks like this:

Code:
// you can store XML's for panoramas directly in code:
var xml_1:XML = 
<panorama>
<parameters> 
	panoName=images/snow
	layer_1=files/fps.swf
	layer_2=files/hotspots.swf
        layer_100 = files/confinoPlugin.swf
	panHome=100
</parameters>
<hotspots>
	<global>
		<box id="test" url="images/black_p.png" pan="128.00" tilt="0.00" distance="0.88" depth="0" scale="0.77" onClick="external.confinoPlugin.trace=test" />
	</global>
</hotspots>
</panorama>;
Beyond looking at the larger issue of putting Plugin-style code inside an embedPano wrapper, I haven't tested your code, so there may be other issues -- but I think really it's just a matter of separating out your thought/workflow.
__________________
Patrick
http://patrickcheatham.com

Last edited by cheathamlane; 04-10-2008 at 04:55 PM. Reason: typo
Reply With Quote
  #20  
Old 04-10-2008, 05:40 PM
zleifr's Avatar
zleifr zleifr is offline
Senior Member
 
Join Date: May 2007
Posts: 609
Downloads: 0
Uploads: 0
Default

Make sure you don't call panoMain.addExternal(this); more than once. If you call it twice, FPP will actually unload, and de-register your pseudo-plugin. And I think it will call the remove function in the plugin for the plugin to remove anything it has added itself. You might put a trace call in the remove function and if it gets called you will know.

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 10:47 PM.


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