Sie sind nicht angemeldet.

1

Freitag, 1. Oktober 2010, 03:30

Why isn't this plugin working? (possibly xml-related)

Alright, this is probably something simple I'm overlooking, so I thought I'd paste here all the details and get some more minds on the problem *cool*

I have this in my xml:

Quellcode

1
2
3
4
5
6
<plugin name="history" url="gui/history.swf" backbutton="back_button" fwbutton="forward_button" keep="true" preload="true" />
<plugin name="cap" url="gui/caption.swf" visible="true" align="leftbottom" x="0" y="0" handcursor="false" keep="true" preload="true" />

(...)

<events onxmlcomplete="action(qtvrcursor); plugin[history].register(get(localname)); plugin[cap].upd();" />


This is how history.swf registers itself:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import krpano_as3_interface;

var krpano:krpano_as3_interface;
var plugin:Object;

(...)

function registerEvent(evt:DataEvent):void {
	var path:String = evt.data;
	plugin = krpano.get(path);
	plugin.register = update;
	(...)
}

function update(place:String):void {
	(...)
}


And this is how caption.swf registers itself:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import krpano_as3_interface;
import flashx.textLayout.*;

var krpano:krpano_as3_interface;
var plugin:Object;

(...)

function upd():void {
	(...)
}

function registerEvent(evt:DataEvent):void {
	var path:String = evt.data;
	plugin = krpano.get(path);
	plugin.upd = upd;
	upd();
}


The base plugin structure, startpluggin, stopplugin and such are *exactly* the same in both plugins (directly copied from the examples and other existing plugins).

Why is it that while history.swf works perfectly, the call plugin[cap].upd(); in the load event fails with the error "WARNING: unknown action command: plugin[cap].upd" ?

Calls to (krpano, not flash) trace from within caption.swf's registerEvent *do not seem to be working*, which means the call to upd would fail because it somehow fails to run registerEvent (!) and therefore never really assigns the upd function?

However, visually speaking, caption.swf is being properly loaded and shows up where it's supposed to show up.

What could be happening here?

2

Freitag, 1. Oktober 2010, 09:04

Hi,

the posted code itself looks okay, it must be something other...

has the caption.swf compiled without any errors?
or do you have a link to view it?

best regards,
Klaus

3

Freitag, 1. Oktober 2010, 09:42

Yes, no errors. At this time it ONLY contains this code:

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
import krpano_as3_interface;
import flashx.textLayout.*;

var krpano:krpano_as3_interface;
var plugin:Object;
stop();
if (stage == null) {
	addEventListener(Event.ADDED_TO_STAGE, startplugin);
	addEventListener(Event.REMOVED_FROM_STAGE, stopplugin);
}
function startplugin(event:Event):void {
	krpano = krpano_as3_interface.getInstance();
	krpano.addPluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent);
}
function stopplugin(event:Event):void {
	krpano.removePluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent);
	krpano = null;
}
function upd():void {
	caption.text = krpano.get("localname");
}
function registerEvent(evt:DataEvent):void {
	krpano.call("trace(Loaded);");
	var path:String = evt.data;
	plugin = krpano.get(path);
	plugin.upd = upd;
	upd();
}


On the stage it contains one TLFText of the read only type whose instance name is 'caption'.

4

Freitag, 1. Oktober 2010, 09:49

from code side I would say everything is okay...
what is a TLFTex? maybe this cases the problem?
have you tried the debug flashplayer? any errors?

5

Freitag, 1. Oktober 2010, 09:58

It's just a more advanced text component from Flash CS5. It displays text. Since it shows up in the krpano viewer nothing is wrong there. It's just upd() that doesn't run when called from the onxmlcomplete event, and also

krpano.call("trace(Loaded);");

This doesn't show in the log inside the krpano viewer so it's safe to assume it never runs.

6

Freitag, 1. Oktober 2010, 10:10

okay, what is the stop() call? maybe try without it, and add more traces,
e.g. you can also call - krpano.trace(0,msg) - this would be better:

Zitat

import krpano_as3_interface;
import flashx.textLayout.*;

var krpano:krpano_as3_interface;
var plugin:Object;
stop();
if (stage == null) {
addEventListener(Event.ADDED_TO_STAGE, startplugin);
addEventListener(Event.REMOVED_FROM_STAGE, stopplugin);
}
function startplugin(event:Event):void {
krpano = krpano_as3_interface.getInstance();
krpano.trace(0,"startplugin");
krpano.addPluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent);
}
function stopplugin(event:Event):void {
krpano.trace(0,"stopplugin");
krpano.removePluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent);
krpano = null;
}
function upd():void {
krpano.trace(0,"upd");
caption.text = krpano.get("localname");
}
function registerEvent(evt:DataEvent):void {
krpano.trace(0,"Loaded");
var path:String = evt.data;
plugin = krpano.get(path);
plugin.upd = upd;
upd();
}

7

Freitag, 1. Oktober 2010, 10:29

I'm not familiar with actionscript but shouldn't you register the caption.swf as you are doing with history.swf ?

8

Freitag, 1. Oktober 2010, 10:36

hi, no, that's not nessecry,
krpano will automatically dispatches a 'krpano_as3_interface.PLUGINEVENT_REGISTER' event after loading to send the name/path of the plugin, to let the plugin know under which name/path (like "plugin[cap]") it was loaded to krpano,

best regards,
Klaus

9

Freitag, 1. Oktober 2010, 12:14

Hi, srisa. If you look more carefully at the code you'll see register is a custom function from the history plugin! It recieves whatever unique identifier you want to be used to tell panoramas apart (such that panoramas with the same identifier will be considered the same place) and, if the latest panorama in history is different from the current panorama, adds the current panorama to the history. One of the advantages of using a plugin for history (besides the fact that I don't really like the krpano if clause :P) is that it can work with php-generated xml to remember the direction you were looking at and, when you navigate through history, seamlessly load the panorama directly looking at that direction even with zoom and blend effects. I'll add the code to the wiki as soon as I get some real work done on it.

klaus: NONE of the traces is showing up :S I'll look into problems with tlftext and files and post my findings in a few minutes.
stop is a MovieClip function and it stops the timeline when there are 2 or more frames.

10

Freitag, 1. Oktober 2010, 12:28

Well, when I replace the TLFText with a TextField the plugin works. The problem is, TextField doesn't have a vertical alignment setting, and I need my text to be aligned to the bottom of the field.

Why would TLFText not work? The component seems to create an extra file textLayout_1.0.0.595.swz . I uploaded this both to the viewer path and to gui/, but it still doesn't work. Since none of the traces run, I'm assuming that when the plugin is imported into the viewer it is somehow unable to find this file, so it crashes in the very beginning at:

import flashx.textLayout.*;

The strangest thing is that the TLFText field is there and showing content, so I assume this shared library contains only the AS3 code for manipulating it, not the component itself. Would there be a way to solve this issue?

11

Freitag, 1. Oktober 2010, 12:33

Ok, I solved it. In Publish Settings > Flash > AS3 Settings > Library path, under Runtime Shared Library settings, I changed the Default Linkage dropdown from Runtime Shared Library (RSL) to Merged into code and now it works (though the plugin is even bigger! TLFText takes a lot of space...)

Sorry about all this. I find that explaining my problems to others often helps me solve them much faster by myself :P

12

Freitag, 1. Oktober 2010, 17:46

I find that explaining my problems to others often helps me solve them much faster by myself :P


This is usually the best problem solving process. Post it on a bulletin board and then the answer immediately comes to you. (right after you click submit) *cool*

Ähnliche Themen