Question

Need to reflect a group containing objects as shown in picture.

I have a sample image for what i have done in my current progress.

enter image description here

Objective: Reflection of objects should be done along x and y axis as per the below image

enter image description here

Was it helpful?

Solution 2

The simple code looks like this:

copiedDisplayObject.scaleY = -1;
copiedDisplayObject.alpha = 0.4;

That is really a specific example of reflection over a line, where the line happens to be the x axis. (ie y = 0x + 0) If you want to reflect over another line, you can use a matrix. The code below preserves previous transformations on the display object, and reflects it over a line passing through the origin.

var m:Number = 0.25; //example slope -- from line: y = mx + 0
var tmpMatrix = copiedDisplayObject.transform.matrix;
var relectMatrix:Matrix = new Matrix(1-m*m, 2*m, 2*m, m*m -1);
tmpMatrix.concat(relectMatrix);
copiedDisplayObject.transform.matrix = tmpMatrix;

I found the matrix formula here: math.stackexchange question.

OTHER TIPS

Very easy approach: for reflection you should have copy of the object that will be reflected. Reflection could be made by myReflectedObject.scaleY = -1

myReflectedObject.scaleY = -1;
myReflectedObject.alpha = 0.4;
//manage Y position accordingly
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top