How to get hotspot to trigger function with a parameter in flash?

  • I am trying to create a plugin so that whenever a hotspot is clicked, it triggers a function in the plugin which loads a specific external swf onto the screen (interactive close up).

    For example:

    Code
    <hotspot name="Plaque"
    	         ...
    	         onclick="plugin[adventure].openSWF();"
    		>
    	</hotspot>


    Code
    function openSWF(parameter:String)
    { 
              //Load and display external swf with name "parameter"
    }


    Q: Can I pass any parameters into .openSwf(), or do I have to create a unique function for each hotspot? For example, can I use .openSwf("parameter") and then have the flash function load an external swf with name "parameter"? Is there another, easier way to do this?

    Thanks for the help!

  • to bind a krpano event like onclick/onhover etc to a flash function you can do something like this:

    Code
    <hotspot onclick="event.someflashfunction(aparameter)" />

    in flash:

    Code
    krpano = krpano_as_interface.getInstance();
    krpano.set("event.someflashfunction", aFlashFunction());
    
    
    function aFlashFunction(aparam:String):void
    {
       trace(aparam) //traces aparameter
    }

    Another option:
    to load an external swf, you can use the build in krpano xml actions.

    Code
    <hotspot onclick="set(plugin[aplaceholder].url, url_to_.swf") />
    <plugin url=""  x="0" y="0" align="center" />
  • Still having problems...

    The code:

    Code
    krpano.set("event.someflashfunction", aFlashFunction());


    keeps telling me that I have an incorrect number of arguments for aFlashFunction(). I am not sure what to put as the argument since it is defined in the XML file.

    Edit: When compiling in Flash, the output displays "set(event.openNode,null);" when I place an argument in aFlashFunction(dummy).

    Also, is there a way to enable a debugger for the krpano.swf, I can't view any "trace" statements given off by flash.

    Edited once, last by chadibanez (May 3, 2011 at 5:01 AM).

  • Sorry it should be:
    krpano.set("event.someflashfunction", aFlashFunction);
    function aFlashFunction(aparam:String):void
    {
    trace(aparam) //traces aparameter
    }

    (with the () after aFlashFunction)
    and to trace you could do:

    krpano.trace(0, "a trace from flash");
    or
    krpano.call("trace(0, a trace from flash)");

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!