Forums: Flash:

 

Papervision - how to make irregular planes into buttons

first
 

DontBogartMe Papervision - how to make irregular planes into buttons

Here's a demo showing how far I've got:

danwashere.com/dev/papervision/interactive_cows.html

What I want is to be able to click on any of the three planes and make the corresponding red dot show or hide. It works on the top most cow - try clicking on it. But you can't click on the other two. *edit* In this version the cows are made by using library clips that mask out the transparent areas as the panel graphics.

I've also tried this with transparent PNGs with the same result.

I think that because it's really a rectangular plane with some transparent bits, that it blocks the mouse click from getting to the planes below.

What would be a good approach here? Do I have to create these via collada or somesuch to make them into lots of smaller planes? Or is there something I can do with what I've got?

 

jestros

I don't really know what papervision is, but can you turn the cows into symbols and use a layer mask? That will let you click through the hidden bits of an image.

 

DontBogartMe

Originally posted by: jestros
I don't really know what papervision is....


thanks for trying smile

I know there are other ways to get get these cows working in Flash, but that's not the point for me here - I'm learning Papervision and I felt like making this purely as a test, as I think it'll be useful to know how to do it for an upcoming project.

Having read a few things out there it looks like it might actually be quite a challenge to do what I'm trying to do.

I thought about Collada now and think that would be quite a hefty load to make those flat cows into many little planes to match the irregular outlines.

Perhaps best to fake it with simpler code outside of papervision, and use papervision to do the stuff that I really need it for.

 

jestros

So the ONLY thing you can load in papervision is an image? No symbols? Seems a little funny.

 

DontBogartMe

did I say that?


Yes you can load symbols in to use as the graphics for your planes - and that's what I've done. But it doesn't fix my problem, cos the transparent bits are still getting the click events.

Just realised I didn't say that I'd used library clips for the graphics in the first post - I'll edit that.

 

jestros

Originally posted by: DontBogartMe
did I say that?


Yes you can load symbols in to use as the graphics for your planes - and that's what I've done. But it doesn't fix my problem, cos the transparent bits are still getting the click events.

Just realised I didn't say that I'd used library clips for the graphics in the first post - I'll edit that.


Ok, so to rephrase what I said the first time....

What if you put the bitmap in a symbol. In that symbol is a layer mask that reveals the bits that you want showing.
Then you send that symbol on into Papervision. Don't be a girlie man, just do it.

 

DontBogartMe

it makes no difference how you build up the graphics that you'll use in the plane - to make any part of the plane interactive (e.g. a button on there, or a cow in my case) you have to make the whole place interactive. This means that clicking anywhere on it - even the transparent bits - gives it the event. Stuff that's behind it - even though it's visible through the transparent bits - won't get the click event.

At least that's my current understanding of what papervision's doing.

 

jestros

I sent a file to show you what I'm talking about. Flash interprets transparent bits as solid, as far as I know.

The shape on top is a gif with transparent bg in a symbol. The bottom 2 shapes are jpgs in a symbol with a layer mask. Roll over the various symbols and you'll see from the "test" text box.

 

DontBogartMe

jestros - that FLA you sent won't load here, not sure why not.

But if you're just trying to show me how to create a mask then it's not relevant anyway - the problem is specifically when trying to do this using Papervision.

 

DontBogartMe

Originally posted by: jestros
Flash interprets transparent bits as solid, as far as I know.


yep.

I think that papervision turns the content you use as gfx into a rectangular bitmap before using it on the plane - so even empty space will turn into transparent bits, and will therefore always get the bloody events.

 

jestros

Crap, I loaded a swf version. Roll around it and you'll see what I'm talking about.

 

DontBogartMe

thanks for trying, but see the above post. It doesn't matter how you make the graphics - it's down to how papervision creates the panels.

 

jestros

Did you even fucking try it with a mask? FLASH scripting ignores the transparency. Jesus freaking Christ.

 

DontBogartMe

yes. My example uses masks.

Bloody freaking hell!

 

JLM

DontBogartMe

are you using hasOwnContainer or making it an effectLayer ie if its using its own MovieClip to draw in then it should be easier to do a hitTest or getPixel or maybe regular mouse event.
Otherwise you will need to dig through virtual mouse code till you find where it sorts hits by depth from camera!
In your case, a simple distance from spot to mouse, on press would work.

 

DontBogartMe

Originally posted by: JLMare you using hasOwnContainer or making it an effectLayer


I haven't heard of either of these, so unless it's used by default I'll say: no.



My current thinking is to have the movieclips that are used as materials to also be rendered on top of everything, but with alpha 0. Then I make those the bits that catch the mouse events... it's based on this tutorial:

papervision2.com/advanced-interactivity-2/

but in there the author isn't trying to handle transparency, so I have a couple of hurdles.

He listens for InteractiveScene3DEvent.OBJECT_MOVE on the cube, and the handler for that repositions the transparent overlain clip accordingly. I can't listen for that event, because only the top cow layer will ever send it, as it blocks the others. So the neat e.x and e.y coords that he uses aren't available to me. I have to do my repositioning in the onEnterFrame handler (or I would if I could work out how).

I'm getting close:

danwashere.com/dev/papervision/interactive_cows.1.html

but not quite there yet. Note that in this one the active parts are actually the 20% alpha pics that don't move. But as you can see, this way you can interact with everything, I just need to work out how to reposition the active clips properly.

 

pyrogen

you could probably separate the cows and the grass onto separate planes, like nest a display object 3d, or, use a movieClip material and make an event inside the MovieMaterial instead of making the event attach directly to the material, ie the primitive shape.

dig?


var MovieClipMat:MovieMaterial = new MovieMaterial( "clipInstanceWithBtnInside")
var MovieClipMat.interactive = true;


so that way whatever clip shape you want can be your hit area as opposed to the material with all its transparency etc, in this case the plane.

I believe you have to have the material in the left upper hand corner of the timeline on init, this may have changed however in the great white release.


here is an example


http://papervision2.com/advanced-interactivity-2/

 

JLM


I haven't heard of either of these, so unless it's used by default I'll say: no.



blog.zupko.info/?p=129
[quote]
var p:Plane = new Plane(new ColorMaterial());
p.useOwnContainer = true;
[quote]

p.addMouseEvent( MouseEvent.MOUSE_DOWN, pressed );

but an interactive movie material as pyrogen says should work.

// make sure viewport is interactive as its switched off by default.
//then

var daisy:MovieClip = new Cow_mc();
var field:MovieClip = new Grass_mc();
addChild(field);
field.addChild(grass);
daisy.addEventListener(MouseEvent.MOUSE_DOWN, oopsadaisyCowPushing );
var MovieClipMat:MovieMaterial = new MovieMaterial( field );
MovieClipMat.interactive = true;

 

DontBogartMe

Hey Pyro - that's what I was already trying (I've linked that article myself a couple of posts back up). Problem is that by making the material interactive, you make the whole plane grab the mouse events, stopping them from going through the transparent bits to the planes beyond.

So really I think I have to keep my materials non-interactive, and find another way. I can't rely on interactive materials because the top one will always block those beneath. I'm now trying to adapt the code from that article to my needs, but the problem is that in his code he uses the InteractiveScene3DEvent.OBJECT_MOVE to reposition the overlaying MC, and as I can't have interactive materials I can't listen for that event. So I was trying to work in the onEnterFrame event and just reposition the 3 overlaying clips according to where the mouse is relative to the coord system of each plane. But that's causing me problems too:
twelvestone.com/forum_thread/view/40012
(sorry JLM haven't had time to look at your latest post)


Any chance I could see that demo you did a while back with the puppets? Just looking for inspiration here, and I vaguely recall it looked something like where I want to go myself.

 

wookee88 Solution?

DontBogartMe

I've been trying to do the same thing and came across your post recently. So did you find a solution to the problem?

 
first
 

Forums: Flash: Papervision - how to make irregular planes into buttons

 
New Post
 
You must be logged in to post