PDA

View Full Version : Plugin integration question


barbi
12-08-2008, 08:33 AM
I have developed a complex plugin which has several buttons on its UI. Users should be able to click on an image hotspot displayed by FPP, this hotspot will hide itself in this case and my plugin gets displayed as a static spot. If one of the buttons of the plugin is clicked, it should hide itself and show the image hotspot again.
This theoretically sounds good, but I'm unable to achieve this functionality.

This is how I get the plugin shown if you click on the pluginOpen image.

<spot id="myplugin" static="1" visible="0" url="myplugin.swf" />
<spot id="pluginOpen" pan="..." tilt="..." url="img.png"
onClick="visible=0; myplugin.visible=1"
/>

If you click on a button which is a part of myplugin.swf, it can cause the plugin to be hidden by running this simple AS3 code: this.visible = false;
But this means that myplugin.swf stays invisible if I click on the pluginOpen again. Is there an event passed to myplugin.swf when its visibility is changed in FPP?

nidrig
12-08-2008, 08:57 AM
Hi,

It seems you're confusing a couple of things.

1. a plugin, in the way Denis meant it, are these loaded at the start (autorotator, limits, and so on).
2. the "myplugin.swf" you're using is called a "smart plugin", because it's loaded from a hotspot

Thus, in your case, you're loading a swf within a hotspot (embedded).

In your plugin, when you type this.visible=false, you're hiding the myplugin swf. In your xml file, when you type myplugin.visible=1, you're trying to make the spot "myplugin" visible, which obviously won't make the child swf (myplugin) visible if its visible state has been set to false.

You need to use LocaConnection to "talk" and "listen" to fpp from your swf. Or write it as a "real" plugin, and use external.myplugin.whatever calls to address it.

Look at Patrick excellent tutorial about plugin architecture in fpp:

http://flashpanos.com/tutorials/zephyr/understanding-basic-flash-panorama-player-plugin-architecture

Good luck!

barbi
12-08-2008, 02:57 PM
Ok, let's call it a smart plugin, besides you gave me a good idea!

myplugin.swf was extended with:

var hotspot:Object;
var hotspots:Object;
var onCloseCommand:String = "";

loaderInfo.addEventListener(Event.INIT,initHandler );

// initialize this hotspot plugin
function initHandler(event:Event)
{
if (loaderInfo.loader != null)
{
hotspot = (loaderInfo.loader as Object).hotspot;
if(hotspot.getParam("onClose"))
onCloseCommand = hotspot.getParam("onClose");
hotspots = (loaderInfo.loader as Object).hotspots;
}
}

//this is called if the close button of myplugin.swf is clicked
function onClose(event:MouseEvent):void
{
if(onCloseCommand != "")
hotspots.execute(onCloseCommand);
}

and in the xml:

<spot id="myplugin" static="1" visible="0" url="myplugin.swf"
onClose="myplugin.visible = 0; pluginOpen.visible=1" />
<spot id="pluginOpen" static="1" scaleX="1" scaleY="1"
salignX="0.5" salignY="-0.5" align="RT"
url="img.png"
onClick="pluginOpen.visible=0; myplugin.visible=1" />
</global>