Change hotspot Alpha (or other property) onOver or onClick

Hi all,

Just wanted to say thanks for creating such a great open source panorama viewer.
I've been modifying it quite heavily to fit into a project I am working on, but am stuck when it comes to changing a property on a hotspot onClick, onOver, etc..

Just for testing purposes I have added a few lines to interactionScene3DEventHandler() method to change a property of the hotspot that called it, but I cannot see the changes reflected in my panorama.

Here's my updated function, can anyone shed some light? :

private function interactionScene3DEventHandler(e:InteractiveScene3DEvent=null):void
{
        var name:String = e.target.name;
        var hs : Hotspot = e.target as Hotspot;
        hs.alpha = 0;

        trace("Hotspot:" + hs + " alpha:" + hs.alpha ); // Traces (Hotspot:toConcert1: x:-36016 y:-8316 z:15288 alpha:0)

        trace("PS:" + interactionEquivalents[e.type] + " at " + name );
        execute( settings..*.(hasOwnProperty("@id") && @id == name).attribute( interactionEquivalents[e.type] ).toString());
}

As you can see, the alpha property of the hotspot is changed as required, but it doesn't affect the image on screen.
Am I doing something wrong?

Thanks,

Dan

Possible solution

Have you set useOwnContainer="true"? And what rev of the source are you using? because I only just added useOwnContainer support a couple days ago (rev 95 or so). And you need to have useOwnContainer set in Papervision in order to support alpha on anything.

Zephyr

Also, this is one feature I

Also, this is one feature I just haven't had time to put into PanoSalado yet, but I have started. There is a function called "set" which is commented out, which is the work I have done on it so far. As I remember, I was debating whether to have the XML changed also, or not, and got distracted by other features....

So some things in there might help you out. And if you would like to share your contributions on this, I would love to put it into PanoSalado with your name on it. This is one of the reasons why PanoSalado is open source.

Zephyr

Finally, you might find the

Finally, you might find the getDisplayObject3DByName function useful, as you could call it, pass it in the name of the object, and get back the hotspot object, and then set it's property: hotspot["property"] = value.

Just make sure to cast the value to the appropriate type. Everything coming from the XML is String, so for alpha: hotspot["alpha"] = Number(value);

Something like that.

Zephyr

Alright, your post reminded

Alright, your post reminded me that I've been wanting to do this for a while, and so I just went ahead and wrote it.

You'll have to download the newest source (it's rev 98, or something like that, just under 100).

Here is the current syntax:

onClick="change:concert1_pano,useOwnContainer=true,alpha=.5"

However, I am going to change it to this:

onClick="change:concert1_pano.useOwnContainer=true,concert1_pano.alpha=.5"

Enjoy!

Any more features you want?

Zephyr

Hi Zephyr, Thanks for the

Hi Zephyr,

Thanks for the quick update!! I'm looking forward to having some time to contribute to PanoSalado as soon as my current project has finished.
I have noticed that the onClick event does not work if you set useOwnContainer="true", do you know what the problem is?

I also made a change to the

I also made a change to the Cylinder class so you can create a cylinder segment rather than a full cylinder, it's usefull if you have a cylindrical panorama that's not 360°

I tried to post the code on here, but it keeps timing out....hmmmm, will try again in a bit

re: posting code; cylinder class

Hey there:

Just a quick note regarding posting code. I noticed that the text-editing toolbar doesn't always appear for comment fields (argh!), so:

When you want to post code inline or single-line, wrap your code in "code" tags; that is <code> and </code>. This example makes the word "and" look like and.

When you want to post multi-line code, I recommend using the alternate tags like so:
<%
//some code
some more code() {
//code
}
%>

This multiline example looks like:

//some code
some more code() {
//code
}

(if you still have issues, hit me up off list or via the contact form; I'll get it up for you)

Cheers,

Patrick

__________________

Patrick Cheatham
FlashPanos.com creator, Panoramic Photographer
Got PanoSalado?

Probably best not to

Probably best not to convolute the thread with a great big source file, so here's a link on my site.

Revised Cylinder.as class

The second param is now segmentPercent between 0 and 1 which is percentage of Cylinder to draw.

Anyone know what I am doing

Anyone know what I am doing wrong here? My alpha changes still don't seem to be working.

Hotspot code from XML

<hotspot id="toConcert1"
         pan="-67"
         tilt="-12"
         scale="2"
         segments="2"
         smooth="true"
         useHandCursor="true"
         interactive="true"
         useOwnContainer="true"
         onOver="hotspotOver:toConcert1"
         onOut="hotspotOut:toConcert1" >
         <file>resources/templates/panorama_viewer/hotspot.png</file>
</hotspot>

Code from hotspot functions in PanoSalado.as

public function hotspotOver(str : String) : void {
         var hs:Hotspot = getDisplayObject3dByName( "toConcert1" ) as Hotspot;
         hs["alpha"] = 0.5;
}
public function hotspotOver(str : String) : void {
         var hs:Hotspot = getDisplayObject3dByName( "toConcert1" ) as Hotspot;
         hs["alpha"] = 1;
}

re: hotspot alpha change in PanoSalado

Hey dan_vegas:

I'll let Zephyr speak to your AS class code, but you're working on doing some things that we've just introduced. Smile

onClick="change:concert1_pano.useOwnContainer=true,concert1_pano.alpha=.5"

That's an example of syntax from the latest rev in the repository. See revs 100 and 101: http://code.google.com/p/panosalado/source/list

Revisions are happening too fast right now for me to package up ZIP file downloads! Wink

__________________

Patrick Cheatham
FlashPanos.com creator, Panoramic Photographer
Got PanoSalado?

Hey Patrick, I've got the

Hey Patrick,

I've got the alpha working but my onClick event now does not fire, it seems that if I set useOwnContainer=true then the onClick event never happens, if it is false, the onClick works, but the onOver/onOut alpha does not work.....puzzling?

onOver="change:toConcert1,useOwnContainer=true,alpha=0.5"
onOut="change:toConcert1,useOwnContainer=true,alpha=1"
onClick="hotspotClick:the hotspot was clicked"

I've just updated to rev 101

I've just updated to rev 101 and changed to dot syntax in the XML, but it's still the same issue with onClick not firing at all.

Hi Dan, This is the syntax

Hi Dan,

This is the syntax you should be using:

onOver="change:toConcert1.useOwnContainer=true,toConcert1.alpha=0.5"
onOut="change:toConcert1.useOwnContainer=true,toConcert1.alpha=1"
onClick="hotspotClick:the hotspot was clicked"

If that is not what you were using try it and let me know. If were using that, and it still isn't working, let me know also, because that would be a bug.

Zephyr

Hi Zephyr, That's the code I

Hi Zephyr,

That's the code I am using as you described.
If I remove the onOver and onOut lines, the onClick works. With them in, onClick does not function.

Any help greeatly appreciated!!

Has anyone had any ideas

Has anyone had any ideas about this? It's really got me whacked!

Oh, ideas. I've had ideas

Oh, ideas. I've had ideas alright. Just none of them are the right ones it seems.

I know generally where the problem is now. It is NOT in PanoSalado's code. It is in Papervision's code, and I think it is in VirtualMouse.as, or possibly in InteractiveSceneManager.as, which are the main two classes that handle making Papervision objects interactive. Papervision recently re-factored InteractiveSceneManager, and I am thinking that that is what introduced the bug. Although, I am not certain that it didn't exist before. onClick and onOver may or may not have been tested in conjunction.....

So, anyway, I am working on tracking down the bug in Papervision and fixing it. I just haven't found it yet tonight.

Tell me though, does it make any difference if you use onPress="change:...." instead of onClick ?

Zephyr

Afraid not Zephyr.If I make

Afraid not Zephyr.

If I make useOwnContainer=false, I recieve all events and can change all transform properties(x,y,z,scale,etc.....all except alpha it seems), if I turn it on, I seem to get no type of CLICK event at all from my object.

I was wondering if the alpha property only works for materials that have an animated property, unlike BitmapMaterial?

Alpha only works on any

Alpha only works on any material WITH useOwnContainer set. I just changed one small thing in Papervision, and the click handlers are now working for me together with onOver and onOut.

onOver="change:toConcert2.useOwnContainer=true,toConcert2.alpha=0.15"
onOut="change:toConcert2.useOwnContainer=true,toConcert2.alpha=1"
onClick="change:toConcert2.useOwnContainer=true,toConcert2.alpha=.5"

works as expected.

Check the file repository for the latest source!

Zephyr

You are quite literally THE

You are quite literally THE MAN!