AS3: draw 2d DisplayObjects UNDER stage3ds - actionscript-3

Is there any way to draw 2d DisplayObjects UNDER stage3ds? I mean, flash' stage is allways upper stage3ds:
Can I create another stage below Stage3D[0]? Or any other way?

Related

Drawing Rectangle images-LibGdx

In my first LibGdx Project,I want to draw some rectangles.
I am not looking for shape rendering purpose.I am aiming to implement a function like what fillRect() in j2me do.I have to draw filled rectangles and need to manipulate it(changing size,rotating.. etc).
When I google about it, always getting shapeRenderer related things only.
Please mention how can I draw and manipulate my own images.
Draw Rectangle by using Pixmap.
Texture texture=getPixmapTexture(Color.WHITE);
Sprite sprite=new Sprite(texture); //Used for drawing 2D sprites.
//or
Image image=new Image(texture); //2D scene graph node.
public static Texture getPixmapTexture(Color color){
return new Texture(PixmapBuilder.getPixmapRectangle(1, 1, color));
}
public static Pixmap getPixmapRectangle(int width, int height, Color color){
Pixmap pixmap=new Pixmap(width, height, Pixmap.Format.RGBA8888);
pixmap.setColor(color);
pixmap.fillRectangle(0,0, pixmap.getWidth(), pixmap.getHeight());
return pixmap;
}
The answer by Abhishek is correct.
However, if you have just started game developement with LibGDX, I would check whether you need at all to perform such operation (draw a rectangle).
In libGDX you can use Scene2D which allow you to create a Stage, Actors and direct them on your stage.
So instead of drawing a rectangle, you create an actor, such as an image, to which you can associate a texture, a button or a TextBox and place it on your screen.
Scene2D allows you to then use things like Action or rotation, scaling..
There are some good visual demos about that on Libgdx.info
I am mentioning this because moving to Scene2D later may be more complicated than if you make that decision early on.

Changing Shape Dynamically Using Mouse In As3

I want to dynamically change the shape of a shape in as3. Say for example, on clicking and dragging on shape square the shape should change according to my mouse movement, direction. I have pasted a link below which display my requirement, selecting one shape and edit edges option, then click the shape and drag, the shape will change according to mouse movent and direction based on some math calculation. Is that possible in AS3.
http://www.shodor.org/interactivate/activities/Tessellate/
Yes, it is possible to make this type of programs.
I suggest you looking into Sprite's graphics object. It has the API to draw primitives, lines and curves.
The reason why you should use Sprites in this case is because it extends InteractiveObject => they support user input, like mouse or touch inputs.
Here's an example of creating triangle:
var s:Sprite = new Sprite();
s.graphics.lineStyle(1, 0x000000); // optional
s.graphics.beginFill(0xff0000); // optional
s.graphics.lineTo(0, 100);
s.graphics.lineTo(100, 100);
s.graphics.lineTo(0, 0);
s.graphics.endFill();
addChild(s);
You can combine mouse events to track input and event ( enter frame in particular ) to redraw your shape depending on the mouse position.
To redraw the shape, you might want to call graphics.clear() method on that object to erase it from the screen.

AS3 DropShadowFilter() with a 3D instance

I have an instance on stage that has a DropShadowFilter() added by code, when I change rotationXor rotationY of that instance, the angle of DropShadowFilter() goes crazy, so my question
How can I make the angle of the DropShadowFilter() fixed while altering the 3D properties of an instance?
A sprite wrapper should do. You wrap your instance in a Sprite, add a new DropShadowFilter() to the instance, and change rotationX or rotationY on the wrapper sprite. This way the filter will continue to operate in a 2D space and will retain correctness, while the complete object will be rotated in 3D via wrapper.

AS3 cacheAsBitmap questions?

I'm a bit confused. If I import a png picture, drag it onto my stage, and right click > convert to bitmap. Is that the same thing is if I have a vector created in code, and then apple cacheAsBitmap = true?
A PNG picture is a raster object, and it has a parent class of Bitmap already. You might, however, encapsulate that Bitmap into a drawn rectangle (effectively making a rectangle with bitmap fill, that is actually a vector object), and then convert to bitmap, applying cacheAsBitmap = true to the vector object made of the raster object. I don't understand why do you want double transformation raster->vector->raster in the first place. Probably Flash isn't so stupid if you just drag a library asset made out of a PNG to the stage, it'll make you a Bitmap based object instead, and "convert to bitmap" won't do a thing.

ActionScript 3.0 get BoundingBox of MovieClip

How do I get the BoundingBox of a MovieClip? if the contents of the movieclip have they're lowest coordinate at the movieclips origin then it's easy (just take width and height of the movieclip and add them to the coordinates of the mc). but how to do it for an arbitrary movieclip?
See the ActionScript reference for getBounds() or getRect().