close panorama

AS3 Flash Plugin Development (old) Version 1.0.7
Select Version:


  • for developing own flash applications or plugins for the
    krpano Viewer there is a Actionscript 3 interface for it
  • it can be used from Flash CS3 or from the Flex SDK (MXMLC)
  • click here to get / see the current version of it:
    krpano_as3_interface.as


Usage:

  • copy the krpano_as3_interface.as to your project folder
  • and import it with:
    import krpano_as3_interface;
  • to get a interface interface:
    var krpano:krpano_as3_interface;
    krpano = krpano_as3_interface.getInstance();
  • with this interface object it's possible to access krpano values and / or register plugin specfic events



krpano_as3_interface - Functions:

  • getInstance():krpano_as3_interface
    • returns a krpano_as3_interface object
    • must be called to get a interface
    • using it is only possilbe when it is loaded into krpano as plugin or hotspot
  • set(variable:String, value:*):void
    • the set interface - to change krpano variables
    • it's the same interface like for XML or Javascript - see get / set / call Interface
  • get(variable:String):*
    • the get interface - to read krpano variables
    • the return values are typed - Boolean, Number, Strings, Objects ...
    • it's the same interface like for XML or Javascript - see get / set / call Interface
  • call(actions:*):void
  • trace(messagetype, message):void
    • traces a message to the krpano log
      • messagetype - the type of the message:
        - krpano_as3_interface.DEBUG or 0
        - krpano_as3_interface.INFO or 1
        - krpano_as3_interface.WARNING or 2
        - krpano_as3_interface.ERROR or 3
      • press 'O' to open this log
      • enable the debugmode by calling:
        trace(0xFF,"debugmode on");
        or with:
        <krpano debugmode="true">
        - to make the log window larger
        - and also to show debug messages
  • addPluginEventListener
    	(plugin:Sprite, type:String, listener:Function):void
    removePluginEventListener
    	(plugin:Sprite, type:String, listener:Function):void



krpano_as3_interface - Events:

  • krpano_as3_interface.PLUGINEVENT_REGISTER
    • this event is called after the plugin is loaded and ready for usage in the viewer
    • as paramater a DataEvent object is passed with the name / fullpath of the plugin
      this name / path can be used to get / set attributes of the plugin object or also to get the pluin object itself, e.g.
      function registerEvent(event:DataEvent):void
      {
          var plugin_path   : String = event.data;			
          var plugin_object : Object = krpano.get(plugin_path);
      }
      

  • krpano_as3_interface.PLUGINEVENT_RESIZE
    • this event is called after the plugin was resized by changing the width or height attributes
    • as paramater a DataEvent object is passed with the new size as String in the format "WIDTHxHEIGHT" (the two values separted by a "x"), e.g.:
      function resizeEvent(dataevent:DataEvent):void
      {
          var size:String = dataevent.data;
              	
          plugin_width  = parseInt(size);
          plugin_height = parseInt(size.slice(size.indexOf("x")+1));
      }

  • krpano_as3_interface.PLUGINEVENT_UPDATE
    • this event is called when an attribute of a plugin/hotspot was changed
    • as paramater a DataEvent object is passed with the name of the changed attribute, e.g.:
      function updateEvent(dataevent:DataEvent):void
      {
          var updatedattriubte:String = dataevent.data;
              	
          if ( updatedattriubte == "color" )
          {
             newcolor = plugin_object.color;
          }
      }




Plugin / Object / Node - Functions:

  • registerattribute(attributename:String, defaultvalue:*):void
    • this function registers a attribute to the plugin / object / node and sets it default value
    • if the attribute was already defined in the xml, the value from the xml is kept
    • NOTE - this function has one special behavior:
      when the type of the defaultvalue is Boolean and the attribute was already defined in the XML (normally as String) the type is converted to Boolean!
      this allowes normal checking for true and false instead of Strings "true" and "false"!

  • createarray(arrayname:String):void
    • create an array as subnode or when the array already exsits it resets it to empty
    • this is used for dynamic subnodes, when the array is not defined in the xml

  • getattributes():Array
    • return the names of all attributes of the plugin / object / node




More information / Examples
  • have a look at the plugin sources included in the download package
    (for starting - the "tutorial" plugin sources)
  • the most of the sources are for the free AS3 MXMLC compiler included in the Flex SDK
  • it is also possible to use this sources in Flash CS3 with some little modifications