Hello.
I've tried to make a volume slider but my AS isn't good. I've looked at the slider in the camera controls plugin and tried to follow that but it's not working - can some please have a look for me?
Code
// import krpano as3 interface.as
// - should be in the same folder or in the class path
import krpano_as3_interface;
import fl.controls.Slider;
import fl.controls.SliderDirection;
import fl.events.SliderEvent;
// create krpano as3 interface object - krpano
var krpano:krpano_as3_interface = krpano_as3_interface.getInstance();
// path to the plugin attributes
var pluginpath:String = null;
var controlsinterface : Object = null;
// empty functions? - then it wasn't included in the viewer
if (krpano.get == null)
{
// run plugin swf standalone - no interfaces - add dummy functions
function dummy_get(v:String):String
{
if (v != "progress.loaddone") // avoid progress timer traces
trace("get(" + v + ");");
return "";
}
function dummy_set(v:String,val:String):void
{
trace("set("+v+","+val+");");
}
function dummy_call(action:String):void
{
trace("call("+action+");");
}
krpano.get = dummy_get;
krpano.set = dummy_set;
krpano.call = dummy_call;
}
if (stage)
{
// run standalone
// no automatic scaling
stage.scaleMode = StageScaleMode.NO_SCALE;
// align on top left corner
stage.align = StageAlign.TOP_LEFT;
startup_plugin(null);
}
else
{
// run as plugin in krpano
this.addEventListener(Event.ADDED_TO_STAGE, startup_plugin);
this.addEventListener(Event.REMOVED_FROM_STAGE, stop_plugin);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
function startup_plugin(event:Event):void
{
krpano.addPluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent);
get_initial_values();
}
///////////////////////////////////////////////////////////////////////////////////////////////////
function stop_plugin(event:Event):void
{
}
///////////////////////////////////////////////////////////////////////////////////////////////////
function registerEvent(evt:DataEvent):void
{
// register event - "data" is the path to the plugin
pluginpath = evt.data;
// interface to radar plugin object
controlsinterface = krpano.get(pluginpath);
// register attributes / set default values
if (!controlsinterface.zoom_refresh_fps)
controlsinterface.zoom_refresh_fps = Number( 2 );
zoom_refresh_timer.delay = 1000.0/controlsinterface.zoom_refresh_fps;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// This function updates the objects in the plugin with the values from the panorama
function get_initial_values():void
{
zoom_refresh_tick(null);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// VOLUME SLIDER
this.slider_volume.direction = SliderDirection.VERTICAL ;
this.slider_volume.liveDragging = true;
this.slider_volume.addEventListener(Event.CHANGE, volume_changed);
function volume_changed(event:Event):void
{
var vol:int = slider_volume.maximum - slider_volume.value + slider_volume.minimum;
krpano.set("plugin[soundinterface].voume", vol);
}
function update_volume_slider(vol:int):void
{
var pos:int = slider_volume.maximum - vol + slider_volume.minimum;
slider_volume.value = pos;
}
Display More