Hello, here is what I have for the plugin and feel it should be working.
I used the samples as a guide to create this one.
My goal is to have crosshairs in the middle of the screens and show the vlookat and hlookat.
That's all I am looking to do.
Can someone point me in the right direct on this.
Where am I going wroing?
Code
package {
import flash.display. * ;
import flash.display.Shape;
import flash.events. * ;
import flash.text. * ;
import flashx.textLayout.formats.Float;
// SWF Metadata
[SWF(width = "400", height = "400", backgroundColor = "#000000")]
public class crosshairs extends Sprite {
private var krpano: krpano_as3_interface = null;
private var parsePath: Function = null;
public var pluginpath: String = null;
public var plugin_object: Object = null;
public var bg: Shape = null;
public var txt: TextField = null;
public var txt_width: int = 256;
public var txt_height: int = 256;
public var vlookat: Number = 0;
public var hlookat: Number = 0;
var format: TextFormat = new TextFormat(); function crosshairs() {
format.font = "_sans";
format.size = 14;
format.align = "center";
var txt: TextField = new TextField();
if (stage == null) {
this.addEventListener(Event.ADDED_TO_STAGE, this.startPlugin);
this.addEventListener(Event.REMOVED_FROM_STAGE, this.stopPlugin);
} else {
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
txt.textColor = 0xffffff;
txt.selectable = false;
txt.htmlText = "<b>Plugin</b> for KRPano" + "\n\n" + "";
txt.autoSize = "center";
txt.setTextFormat(format);
addChild(txt);
var resize: Function = function (event: Event): void {
txt.x = (stage.stageWidth - txt.width) / 2;
txt.y = (stage.stageHeight - txt.height) / 2;
return;
}
stage.addEventListener(Event.RESIZE, resize);
resize(null);
}
return;
}
private
function startPlugin(): void {
this.krpano = krpano_as3_interface.getInstance();
krpano.addPluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent);
this.krpano.addPluginEventListener(this, krpano_as3_interface.PLUGINEVENT_UPDATE, this.updatePlugin);
addEventListener(Event.ENTER_FRAME, this.enterFrameHandler);
return;
}
private
function enterFrameHandler(e: Event): void {
var sh: Number = 400; //stage.stageHeight;
var sw: Number = 400; //stage.stageWidth;
var lineH: Shape = new Shape();
lineH.graphics.beginFill(0xFF6600);
lineH.graphics.drawRect(0, sh / 2, sw, 2);
lineH.graphics.endFill();
this.addChild(lineH);
var lineV: Shape = new Shape();
lineV.graphics.beginFill(0xFF6600);
lineV.graphics.drawRect(sw / 2, 0, 2, sh);
lineV.graphics.endFill();
this.addChild(lineV);
}
private
function registerEvent(evt: DataEvent): void {
pluginpath = evt.data;
plugin_object = krpano.get(pluginpath); // get the whole krpano plugin object
// register custom attributes with their default value (note - only lowercase attributes are possible!!!)
plugin_object.registerattribute("vlookat", "");
plugin_object.registerattribute("hlookat", "");
// create the as3 textfield itself
txt = new TextField();
txt.htmlText = "";
txt.multiline = true;
txt.wordWrap = true;
txt.border = false;
txt.background = false;
txt.condenseWhite = true;
txt.width = txt_width;
txt.height = txt_height;
addChild(txt);
}
private
function updatePlugin(event: DataEvent): void {
switch (event.data) {
case "vlookat":
this.vlookat = this.plugin_object.vlookat;
break;
case "hlookat":
this.hlookat = this.plugin_object.hlookat;
break;
}
txt.text = "h:" + this.hlookat.toString() + " / v:" + this.vlookat.toString();
}
private
function stopPlugin(): void {
removeEventListener(Event.ENTER_FRAME, this.enterFrameHandler);
this.krpano.removePluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, this.registerEvent);
this.krpano.removePluginEventListener(this, krpano_as3_interface.PLUGINEVENT_UPDATE, this.updatePlugin);
this.plugin_object = null;
this.krpano = null;
return;
}
}
}
Alles anzeigen
Thanks,
Jon
Edit: if I am missing some info that would help, let me know...