Sie sind nicht angemeldet.

Lieber Besucher, herzlich willkommen bei: krpano.com Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

1

Montag, 1. August 2011, 19:52

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

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

2

Dienstag, 2. August 2011, 02:24

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

Dienstag, 2. August 2011, 15:02

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

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

4

Dienstag, 2. August 2011, 19:48

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

Donnerstag, 4. August 2011, 14:03

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

Samstag, 6. August 2011, 14:04

Hi,

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

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

Quellcode

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

Sonntag, 7. August 2011, 21:10

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:

Quellcode

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:

Quellcode

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:

Quellcode

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:

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
<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

Dienstag, 9. August 2011, 22:19

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

Donnerstag, 11. August 2011, 11:25

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

Donnerstag, 11. August 2011, 20:01

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

11

Freitag, 12. August 2011, 02:02

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

Samstag, 17. September 2011, 14:38

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:


Quellcode

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

Sonntag, 18. September 2011, 08:29

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

Sonntag, 18. September 2011, 13:01

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

Anfänger

Beiträge: 40

Wohnort: Belo Horizonte

Beruf: Flash Developer

  • Nachricht senden

15

Freitag, 23. September 2011, 00:31

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

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

16

Freitag, 23. September 2011, 00:42

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

Anfänger

Beiträge: 40

Wohnort: Belo Horizonte

Beruf: Flash Developer

  • Nachricht senden

17

Freitag, 23. September 2011, 14:01

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

Montag, 26. September 2011, 17:03

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