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.

1

Monday, August 1st 2011, 7:52pm

Dynamically creating many hotspots from AS3

Hi there

I'm making an AS3 plugin which requires creating a lot of hotspots dynamically (1000+), from information returned by a server. I've tried two solutions, but none of them works 100%.

First, I tried repeatedly calling a krpano action from the AS3 plugin. This made krpano go really slow for some time and even crash because of a timeout. I also tried enabling "freezeview" while doing this, but it didn't seem to do much.

My second try was to create an array from AS3 and then calling a krpano action which iterated over the array and created the hotspots. I created the array using the information on this thread, and the iteration was done using the "loop" action from 1.0.8.14. Unfortunately, I couldn't iterate over the entire array due to the "actions overflow".

The last solution I can think of is to generate some krpano XML using the information I get from the server, and then use "loadxml()" to create the hotspots. However, this means that I won't be able to change the hotspots dynamically, since "loadxml" always expects a new panorama to be loaded.

So, before trying this last solution, I'd like to know if there some "faster" way to make KRPano create a lot of hotspots, or if this is really the best way to go.

Thanks,
Manuel
PanoTag: Facebook tagging for krpano

KRPano development and more: http://www.digisfera.pt/en/development

Posts: 1,850

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

2

Tuesday, August 2nd 2011, 2:24am

Use your second try, but try using delayedcall to put the actions on different frames.
There are frames/per second in flash, and actions that happen on a frame.
By using a delayedcall you are queuing actions on future frames and bypassing the actions overflow limit.
At least this is my understanding.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

3

Tuesday, August 2nd 2011, 3:02pm

Thanks for the sugestion. I tried using delayedcall, but it causes KRPano to go really slow and then crash (I guess because too much stuff is added to some queue).

I also tried adding a WAIT(0) after every 50 hotspots, but this also makes KRPano slow for around 1 minute.
PanoTag: Facebook tagging for krpano

KRPano development and more: http://www.digisfera.pt/en/development

Posts: 1,850

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

4

Tuesday, August 2nd 2011, 7:48pm

Why don't you load them all initially in the xml generated from the db, and then control the existing ones dynamically if need be?
You didn't really explain what you are trying to do precisely, so I'm not sure why they aren't all in your single xml at start.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

5

Thursday, August 4th 2011, 2:03pm

Yeah, that was my third option, but it will make the code a lot more complicated. That's why I was wondering whether there was some faster way to add hotspots with the AS3 interface.
Thanks for the help *smile*
PanoTag: Facebook tagging for krpano

KRPano development and more: http://www.digisfera.pt/en/development

6

Saturday, August 6th 2011, 2:04pm

Hi,

can you show the code that you were trying to use?

this should be the fastest way to add and get a hotspot:

Source code

1
2
3
krpano.call("addhotspot("+spotname+")");
var hotspot:Object = krpano.get("hotspot["+spotname+"]");
...


the setting of the attributes of the hotspot should be done directly in as3,
this is faster then setting them by calling the set function and much faster then calling the set action,

best regards,
Klaus

7

Sunday, August 7th 2011, 9:10pm

Hi

Thanks! I'll try that as soon as I can. In the meantime, here's the code I used on the other attempts.

The first try was just a simple loop in as3 and a krpano action:

AS3:

Source code

1
2
3
4
5
6
7
8
for each(var i:Object in response.list) {
	var krcode:String = "createSpot(" +
		i.id+ "," +
		i.ath + "," +
		i.atv + "," +
		i.info + ")";
	kr.krpano.call(krcode);
}


krpano:

Source code

1
2
3
4
5
6
7
8
<action name="createSpot">
	addhotspot(hs-%1);
		
	hotspot[hs-%1].loadstyle(myspot);
	set(hotspot[hs-%1].ath,%2);
	set(hotspot[hs-%1].atv,%3);
	set(hotspot[hs-%1].info,%4);
</action>


On the second try, I was creating an array in AS3, and then looping in krpano. For looping, I used a foreach() action, which is based on the new loop():

as3:

Source code

1
2
3
4
5
6
7
8
9
krpanoObj.createarray("newhotspots");
newHotspotsArray = krpanoObj.newhotspots

for each(var i:Object in response.list) {
	var nh:Object = newHotspotsArray.createItem("hs-" + i.id);
	nh.registerattribute("ath",i.ath);
	nh.registerattribute("atv",i.atv);
	nh.registerattribute("info",i.info);
}


krpano:

Source code

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
<action name="createNewHotspots">
foreach(plugin[myplugin].newtags,panotag-tmpi, panotag-tmpo,
	createSpot(
		get(panotag-tmpo.name),
		get(panotag-tmpo.ath),
		get(panotag-tmpo.atv),
		get(panotag-tmpo.info));
	
		<!--
		mod(panotag-tmpm, panotag-tmpi,80);
		if( panotag-tmpi,
			wait(0));
		-->
	);
</action>

<!-- %1 - type of data 
	%2 - iterator variable
	%3 - variable where the object will be stored
	%4 -  action -->
<action name="foreach">
	set(%2,0);
	loop(%1[get(%2)] !== null,
		copy(%3, %1[get(%2)]);
		%4;
		inc(%2);
	);
</action>
PanoTag: Facebook tagging for krpano

KRPano development and more: http://www.digisfera.pt/en/development

8

Tuesday, August 9th 2011, 10:19pm

Hi again,

I tried the method you proposed. It was much faster, but still not enough. I'll try something different: creating only the hotspots which are currently visible, and update them as the view changes.

Thanks,
Manuel
PanoTag: Facebook tagging for krpano

KRPano development and more: http://www.digisfera.pt/en/development

9

Thursday, August 11th 2011, 11:25am

Hi,

if you need performance then try to do as much as possible in as3,
the xml code is very slow compared to it because it need to be parsed character by character of code,

best regards,
Klaus

10

Thursday, August 11th 2011, 8:01pm

Thanks for the info!

One more thing: is there any way to change the textfield plugin HTML from AS3? I tried changing it as if it were ath, atv or visible, but it didn't work.
PanoTag: Facebook tagging for krpano

KRPano development and more: http://www.digisfera.pt/en/development

Stoney

Trainee

Posts: 119

Location: Portland, Oregon

  • Send private message

11

Friday, August 12th 2011, 2:02am

Are you attempting to implement tagging? You should display fewer icons that communicate the fact that there are more tags in a general area. Many of the applications ruin the aesthetics and hinder performance. You should also make a good balance between a responsive application and uneccessary function calls.

12

Saturday, September 17th 2011, 2:38pm

Just in case someone stumbles on this thread, here's how I solved it.

I "pre-loaded" a number of invisible hotspots by creating them on an xml file like this:


Source code

1
<hotspot name="panotag-pi-ts-0" style="panotag-tagspot" visible="false"/><hotspot name="panotag-pi-ts-1" style="panotag-tagspot" visible="false"/><hotspot name="panotag-pi-ts-2" style="panotag-tagspot" visible="false"/>(...)



Then I retrieved them in AS3 using their name, and added them to a "not used" list. Whenever I needed to create a new hotspot dynamically, I got one from the "not used" list, changed its coordinates and visibility and added it to a "used" list. To remove a hotspot, I did the opposite. This was much faster than creating new hotspots.

When there are a lot of hotspots in a panorama , krpano will get a bit slow. Therefore, I'm only showing hotspots which were in the currently visible area, and removing the others.

The result can be seen here: http://www.digisfera.pt/panotag-example-giga
PanoTag: Facebook tagging for krpano

KRPano development and more: http://www.digisfera.pt/en/development

13

Sunday, September 18th 2011, 8:29am

Is it possible to show or hide the hotspots based on time elapsed or the current timeline of say the video / ( as in a 360 video panorama)

14

Sunday, September 18th 2011, 1:01pm

I haven't played with 360 video much yet, but I imagine it should be possible.
PanoTag: Facebook tagging for krpano

KRPano development and more: http://www.digisfera.pt/en/development

eduardo

Beginner

Posts: 40

Location: Belo Horizonte

Occupation: Flash Developer

  • Send private message

15

Friday, September 23rd 2011, 12:31am

What´s the problem here please?

why my hotspots don´t apearing?

in As3:


private function onResultObterTodosUsuarios(e:Array):void
{

for (var i:int = 0; i < e.length; i++)
{
_krPano.call("createSpot(" +e.Id+ "," +e.PosicaoX + "," +e.PosicaoY + ")");

};


}

in XML:

<action name="createSpot">
showlog();
trace("createSpot");

addhotspot(hs-%1);
set(hotspot[hs-%1].url,mark.png);
set(hotspot[hs-%1].ath,%2);
set(hotspot[hs-%1].atv,%3);
</action>

trace:

INFO: createSpot
INFO: createSpot

Posts: 1,850

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

16

Friday, September 23rd 2011, 12:42am

Use the editor.swf/options.swf to see if they were even created .. and with what properties.
That way you can troubleshoot better.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

eduardo

Beginner

Posts: 40

Location: Belo Horizonte

Occupation: Flash Developer

  • Send private message

17

Friday, September 23rd 2011, 2:01pm

Hey man,

What´s the problem with this code please?


for (var i:int = 0; i < e.length; i++)
{
//_krPano.call("showlog()"); _krPano.trace(1, "Uma vez");

var spotname:String = "spot" + "-" + e.Id;
_krPano.call("showlog()"); _krPano.trace(1, "spot" + "-" + e[i].Id ) ;
var spot:Object = _krPano.get("hotspot[" + spotname + "]");
_krPano.call("addhotspot(" + spotname +")");

spot.zoom = true;
spot.url = "mark.png";
spot.ath =e[i].PosicaoX;
spot.atv = e[i].PosicaoY;
spot.onclick = function():void { _krPano.call("showlog()"); _krPano.trace(1, "spot clicked... X = " + e[i].PosicaoX ) };

};

the hotspots don´t appearing people!

18

Monday, September 26th 2011, 5:03pm

Hi,
What´s the problem with this code please?


var spot:Object = _krPano.get("hotspot[" + spotname + "]");
_krPano.call("addhotspot(" + spotname +")");
wrong order - first you need the add the hotspot and then you can get it,
then there is no hotspot with that name you will get 'null' as so the following actionscript code will fail when trying to access a 'null' object (use the DEBUG flashplayer to see such errors),

spot.ath =e.PosicaoX;
spot.atv = e.PosicaoY;
the ath/atv coordinates are spherical 360/180 coordinates in degrees, using 'x/y' screen coordinates here is not correct,

best regards,
Klaus