Sie sind nicht angemeldet.

1

Montag, 25. Januar 2010, 11:13

How to play flash animation ?

Hi,

I have integrated a flash animation as hotspot in a virtual tour and i want to play it when i click on it.
I think that is possible but i don't know what function do i have to use.
If necessary i can change it to plugin.

Can you help me please ?

Thanks.

2

Montag, 25. Januar 2010, 12:03

Hi,

I think you have to do your animation in Flash and Action Script 3.

Create an animation in flash and create AS3 code to play your animation when mouse is clicked :

Quellcode

1
MouseEvent.CLICK


Then, insert your flash plugin in xml file in krpano.

3

Montag, 25. Januar 2010, 12:52

thanks for your help,

i've tried this code

Quellcode

1
2
3
4
5
b_0.addEventListener(MouseEvent.CLICK, button_function);
b_0.buttonMode = true;
function button_function( evt:MouseEvent ) {
gotoandplay(1);
}


but it didn't work. the animation starts before i click.

is there a problem with my script ?

4

Montag, 25. Januar 2010, 13:39

ok i corrected it and it works fine now.

Thanks :)

5

Montag, 25. Januar 2010, 13:56

i've integrated the swf in the virtual tour but when i click on it it does'nt play :(

here is the 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
<hotspot name="anim3"
	     	url="./anim3/anim3.swf"
	     	keep="false"
	     	ath="122.18229541736807" atv="-18.647263602344474"
	     	zoom="false" distorted="true"
	     	width="1131" height="718"
	     	scale="0.22531519359898222" scale9grid="" scalechildren="false" rotate="0"
	     	rx="-3.0374999999999943" ry="4" rz="1.08583441509875"
	     	edge="center" ox="" oy=""
	     	crop="" ondowncrop="" onovercrop=""
	     	visible="true" enabled="true" handcursor="true" capture="true" children="true"
 	     	zorder="20"
	     	alpha="1.00" blendmode="normal" smoothing="true"
 	     	refreshrate="auto"
 	     	onloaded=""
	     	onover=""
	     	onhover=""
	     	onout=""
	     	ondown=""
	     	onup=""
	     	onclick=""
	     	flying="0"
	     	/>

6

Montag, 25. Januar 2010, 14:12

Hi,

First, do your animation work when you preview it in Flash ? When mouse is clicked, your animation play ?

If it works, then you should try to integrate it as a plugin in xml file.

And did you add this code in your flash project ?

Quellcode

1
2
import krpano_as3_interface;
var krpano:krpano_as3_interface = krpano_as3_interface.getInstance();

7

Montag, 25. Januar 2010, 14:25

yes the animation works and when i click it play the animation.

now i tried this code

Quellcode

1
2
3
4
5
6
7
8
import krpano_as3_interface;
var krpano:krpano_as3_interface = krpano_as3_interface.getInstance();
stop();
b_0.addEventListener(MouseEvent.CLICK, button_function);
b_0.buttonMode = true;
function button_function( evt:MouseEvent ) {
gotoAndPlay(1);
}


but the animation in the virtual tour works in loop *confused* (i haven't changed the code in the xml it's always like this :

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<hotspot name="anim3"
	     	url="./anim3/anim3.swf"
	     	keep="false"
	     	ath="122.18229541736807" atv="-18.647263602344474"
	     	zoom="false" distorted="true"
	     	width="1131" height="718"
	     	scale="0.22531519359898222" scale9grid="" scalechildren="false" rotate="0"
	     	rx="-3.0374999999999943" ry="4" rz="1.08583441509875"
	     	edge="center" ox="" oy=""
	     	crop="" ondowncrop="" onovercrop=""
	     	visible="true" enabled="true" handcursor="true" capture="true" children="true"
 	     	zorder="20"
	     	alpha="1.00" blendmode="normal" smoothing="true"
 	     	refreshrate="auto"
 	     	onloaded=""
	     	onover=""
	     	onhover=""
	     	onout=""
	     	ondown=""
	     	onup=""
	     	onclick=""
	     	flying="0"
	     	/>


)

8

Montag, 25. Januar 2010, 14:53

i just want you to know that if i put the animation as plugin then it works correctly (with the events of the mouse) but i want to use it as hostspot *rolleyes*

9

Dienstag, 26. Januar 2010, 00:58

Zitat

i just want you to know that if i put the animation as plugin then it works correctly (with the events of the mouse)


Great ! *smile*

Zitat

but i want to use it as hostspot


then you could add an action in your xml file to your plugin with "onclick" for example :

Quellcode

1
2
3
4
5
6
7
8
9
	<plugin name="animation"
 	        url="your-flash-plugin.swf"
	        onover=""
	        onhover=""
	        onout=""
	        ondown=""
	        onup=""
	        onclick="lookto(180,0,150);"
	        />


Or you could add an action in your flash plugin in AS3 :

Quellcode

1
krpano.call("lookto(0,25,20));");


Good luck !

10

Dienstag, 26. Januar 2010, 12:19

thank you vinyl but i'm sorry i think that you haven't understand me *sad*

I want to you the animation as hotspot because in this situation i will be able to put it where i want exactly in the virtual tour (not the case of the plugin)

11

Dienstag, 26. Januar 2010, 13:13

Hi,

when using a swf as "distorted" hotspot, the own events of the swf will not work anymore,
because the swf will be rendered to a bitmap, and then only this bitmap will be displayed distorted,
that means there is no connection anymore between the displayed object and the real swf,

a solution could be to use the normal krpano events,
you can also call your own AS3 functions from there,

or to add your own events direct to the 'real' Sprite object of the hotspot,

have also a look here:
http://krpano.com/docu/plugins/

first you need to know the 'name' of the hotspot or plugin,
this can be get in AS3 via the krpano PLUGINEVENT_REGISTER,

e.g.

Quellcode

1
2
3
4
5
6
7
8
9
10
11
krpano.addPluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent);

...

public function registerEvent(evt:DataEvent):void
{
  var plugin_path:String = evt.data;
  var plugin_obj:Object = krpano.get(plugin_path);

  ...
}



then you could add your own functions to the plugin/hotspot
and call them from xml,
e.g:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
public function registerEvent(evt:DataEvent):void
 {
   var plugin_path:String = evt.data;
   var plugin_obj:Object = krpano.get(plugin_path);
 
   plugin_obj.registerattribute("test",  testfunction);
 }

public function testfunction():void
{
  krpano.trace(0, "hello from AS3");
}



and call it from xml:

Quellcode

1
<hotspot ... onclick="test();" .. />



or if you want to add own events - there is "sprite" member variable that contains the real
visible sprite object,
e.g.

Quellcode

1
2
3
4
5
6
7
8
9
10
public function registerEvent(evt:DataEvent):void
{
  var plugin_path:String = evt.data;
  var plugin_obj:Object = krpano.get(plugin_path);
  
  var sprite:Sprite = plugin_obj.sprite as Sprite;

  sprite.addEventListener(MouseEvent.CLICK,  handleclick);
  ... 
}


best regards,
Klaus