You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Tourvista

Intermediate

  • "Tourvista" started this thread

Posts: 258

Location: Leicester UK

  • Send private message

1

Wednesday, May 11th 2011, 3:28pm

Get a plugin attribute and use the value in a as3 function (help with the syntax)

Hello There!

Thank you very much in advance!

The question:

How to get a plugin attribute value (located in the krpano xml file) and pass it to a flash plugin, in order to trigger an action (in flash).

The story:

I have a scrolling thumbnails plugin inside krpano, which shows a red frame around the corresponding thumbnail when a scene loads.
As a default the red frame always starts in the first thumbnail, as the virtual tour always loads the first scene first.

Recently I purchased the SWFaddress plugin, which allows me to load any scene from the same html file, changing the url.
So what I would like to do is to put the red frame in the corresponding scene loaded.

DO NOT PANIC! I know exactly how to do that, but my action scrip 3 knowledge is very limited.

Roughly, this is the code I need:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//get the path attribute value from the swfaddress plugion and put it in a variable 
var scene_path:Object = krpano.get("plugin[swfaddress].path");
 
//the input should be /pano01/ or /pano02/, etc... but it returns noting. Not 'nulll'. It just  prints a blank like     
trace (scene_path);

// trigger this action
change_seleted();

//if the attribute  == '/pano01/' then put the frame around the first item of the array [0]
//if the attribute  == '/pano02/' then put the frame around the second item of the array [1]
function change_seleted () {
    if (scene_path == "/pano01/") { myScroll.selectItemAt(0); }
    if (scene_path == "/pano02/") { myScroll.selectItemAt(1); }
}


So after all it is just a syntax thing.

The example:

Virtual tour

Thank you !!!

2

Wednesday, May 11th 2011, 3:46pm

Hi,

just with get() function,

like here:

Source code

1
var scene_path:Object = krpano.get("plugin[swfaddress].path");


e.g. to get the current hlookat:

Source code

1
var hlookat:Number = Number( krpano.get("view.hlookat") );


or to get the current scene:

Source code

1
var currentscene:String = krpano.get("xml.scene");


or to get the current align setting from the plugin logo:

Source code

1
var align:String = krpano.get("plugin[logo].align");


...

best regards,
Klaus

Tourvista

Intermediate

  • "Tourvista" started this thread

Posts: 258

Location: Leicester UK

  • Send private message

3

Thursday, May 12th 2011, 11:50am

Thanks for your quick answer Klaus!

I followed your instructions but Flash throws an error:

TypeError: Error #1006: value is not a function. at scroll_fla::MainTimeline/frame1()

This is the code:

Source code

1
2
3
4
5
import krpano_as3_interface;

var krpano:krpano_as3_interface = krpano_as3_interface.getInstance();

var scene_path:Object = krpano.get("plugin[swfaddress].path");


I read 4 previous threads regarding this error but I couldn't find a definitive fix for the problem.

Here are all the files involved:

Example

main.xml

scroll.fla

krpano_as3_interface.as

I am using version 1.0.8.12

Hope this helps.

Cheers!

Tourvista

Intermediate

  • "Tourvista" started this thread

Posts: 258

Location: Leicester UK

  • Send private message

4

Friday, June 10th 2011, 12:13pm

Hi all!

Sorry for bringing this thread alive again but I still haven't found what's wrong with this thing.
I really would appreciate anyone's help.

I've tried to simplify the problem to it's simpliest form and it the previous post I supplied all the files involved.
To make it even easier I've put everything together in a zip file.

Zip file

Thank you very much in advance!

Cheers

Zephyr

Professional

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

5

Friday, June 10th 2011, 3:15pm

The reason flash throws an error is because krpano doesnt exist in its context. But if you put swf in the tour and load it in as a xml plugin, it should work.

you can test its working by tracing something in flash to krpano:

Source code

1
krpano.trace('flash communication succes");


if you look at the examples of krpano, you'll see that the plugin checks if there is a stage or not. If there's a stage then the plugin is in standalone mode and krpano access isnt posbbile. Alsoo the examples implement a dummy call/set/get/trace, so you wont get errors during debugging.