Sie sind nicht angemeldet.

1

Donnerstag, 14. Juli 2011, 21:07

First Simple Plugin - need help [SOLVED]

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?



Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
  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;
        }
    }
}

Thanks,
Jon

Edit: if I am missing some info that would help, let me know...

Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »jchambers« (16. Juli 2011, 08:21)


2

Samstag, 16. Juli 2011, 08:20

I got it working thanks to jmulder's post.

read/update attributes plugin AS3

Thanks Mulder!

3

Samstag, 15. Oktober 2011, 02:18

combobox

Hi,


I need help with the use of the combobox plugin.
I don't know how to link panoramas to it, i mean to be loaded by clicking the combobox taps.
a tutorial or explanation would be perfect since I am a beginner and i don't know much about scripting languages(such as XML)

Kind Regards
=Manigordo=
*smile*

Ähnliche Themen