AS3 alpha of multiple objects adds up [duplicate] - actionscript-3

This question already has an answer here:
As3: Draw overlapping rectangles to a sprite and apply alpha
(1 answer)
Closed 7 years ago.
It seems that when I set alpha on a DisplayObjectContainer, then it works on each individual child separately and not on the container as a whole. Consequently I start seeing overlap regions which are normally not visible.
My question is - How do I fade a container as a whole?

Set the blendMode property on your DisplayObjectContainer to BlendMode.LAYER

Related

How to let the cross part of elements be opaque in HTML? [duplicate]

This question already has answers here:
CSS overlapping elements & opacity issue
(3 answers)
Color of stacked semi-transparent boxes depends on order?
(4 answers)
Closed last month.
This post was edited and submitted for review last month and failed to reopen the post:
Original close reason(s) were not resolved
I tried to write a HTML that enables the user to create a element with angle and color(rgba). I want the cross part to be opaque that each element has transparency
However, I can not use the simple way to do this because the cross area is still not opaque(0.5*0.5=0.75)
I want to ask for a solution to make the cross part of two element be opaque by using CSS or JavaScript.
It must be completely filled into the area. However, the element will have angle so simple JavaScript to calculate it is not working.
I wonder if someone can give me a solution.
opacity doesn't add like that..
it is like discount of 50% + 50%.. if original price is 100 . you get first discount your price is 50 but with second discount, it is 25 more so final price will be 25
for case of opacity... you have one layer which lets 50% of light through it .. and 2nd layer also 50% so basically 50% of the 50% of the lowermost layer.
easy way to think is that both of them have some transparency so together they can't be fully opaque
Imagine that are two glasses, red glass, and green glass. When you put the red glass on top of green glass, it is an overlay, not an addition. You can try it in real life

Colouring a TD based on its value [duplicate]

This question already has answers here:
How can I find elements by text content with jQuery?
(8 answers)
Is there a CSS selector for elements containing certain text?
(20 answers)
Closed 4 months ago.
I have a table and I am trying to give the cells a background colour based on its value. The only issue is that if there is the same part of the word in the td they become the same colour. i.e. - Intensive and Lion Intensive become the same colour. Is there any way to make this distinct to the word?
$('td:contains("M/S Select Farm")').css('background','yellow');
$('td:contains("Lion Free Range")').css('background','Blue');
$('td:contains("Barn")').css('background','Orange');
$('td:contains("Free Range")').css('background','green');
$('td:contains("Lion Intensive")').css('background','Red');
$('td:contains("Intensive")').css('background','White');

How to make a hole in a pygame surface? [duplicate]

This question already has answers here:
Can I use an image on a moving object within Pygame as opposed to to a color?
(2 answers)
How do I focus light or how do I only draw certain circular parts of the window in pygame?
(1 answer)
How do I display a large black rectangle with a moveable transparent circle in pygame? [duplicate]
(2 answers)
how to make circular surface in pygame
(1 answer)
Closed 1 year ago.
I have 2 different images A and B, B is blit on top of A. I'd like to have (blit I guess) a hole in B that lets me see A through it.
Can anyone help me with that? Thanks in advance.
You can set make a hole in B before blitting it above A, using a color key (see https://www.pygame.org/docs/ref/surface.html#pygame.Surface.set_colorkey)
pick a color K not used in B
fill the "hole" in B with this color
set the color key of B to K
blit A
blit B
Instead of a color key you also can use alpha transparency.

4-neighbours of a pixel [duplicate]

This question already has an answer here:
Selecting the 4-neighbours of a pixel [closed]
(1 answer)
Closed 9 years ago.
I know that there is a function called nlfilter in matlab. What I'm trying to find is the 4-neighbours of a pixel. Does that means a 2x2 window? Can we do that using nlfilter?
Thanks.
I think you might find this easier to comprehend if you think of it in terms of blocks rather than in terms of neighbors. So a 2x2 neighbor is actually just a 2x2 block.
If you are talking about a center pixel relative to a north, south, east, west pixel, then you would want to use a 3x3 block. Unfortunately, that block would also include northeast, northwest, southeast, southwest neighbors.
Here is an example of sliding neighborhood operations in Matlab using nlfilter.

Depth related problem for actionscript 3 [duplicate]

This question already has an answer here:
How do I set the depth of images in ActionScript?
(1 answer)
Closed 2 years ago.
I'm having trouble managing the depths of my movie clips.
I've got a startDrag() function and a stopDrag() function.
Whenever I rollover another MC, I want the depth of that object to change to 1+ the object it rolled over.(I apologize if my English is poor)
Can anyone give me a nudge in the right direction?
EDIT: This is as far as I got, but cIndex returns the depth of the object that is currently being dragged; not the object it's hovering over... Is there a way to get that depth?
mc.addEventListener(MouseEvent.MOUSE_OVER, objectFront);
function objectFront(e:Event):void{
cIndex_t3 = getChildIndex(DisplayObject(e.currentTarget))
trace("ROLLOBJ: " + e.target.name + " " + cIndex_t3);
addChild(DisplayObject(e.currentTarget));
}
If you actually want to object to be +1 the object it rolled over then use getChildIndex() on the object dragged over and use setChildIndex() on the dragged object.
However if you simply want the dragged object on top then the easiest way is to simply use addChild() on it. You can use addChild() even if the object is already a child, and that'll bump it to the top of the stack.
You should use getChildIndex and setChildIndex for depth related operations of display objects.
mc.addEventListener(MouseEvent.MOUSE_OVER, objectFront);
function objectFront(e:Event):void
{
//Set display object child index on top in container
e.target.parent.setChildIndex(e.target as MovieClip, e.target.parent.numChildren - 1);
}