ActionScript 3.0 :: Getting Display Object Dimensions Including Transparent Areas
Dec 20, 2010
I'm having troubles getting the dimensions I'm looking for for a given display object. This display object has some transparent area to the top-left of the opaque content but to the bottom-right of 0,0. As such, the display object's reported width ONLY includes the opaque area, not the transparent area. For example:
Code:
var myChild:Sprite = new Sprite();
myChild.graphics.beginFill(0xff0000);
myChild.graphics.drawRect(100, 100, 100, 100);
myChild.graphics.endFill();
trace(myChild.width);
This reports 100 as the width and height. I need to somehow retrieve 200 as the width and height.
I'm trying to take a bitmapdata snapshot of the display object, but when I do new BitmapData(myChild.width, myChild.height) and then draw into it I don't get the full opaque content of myChild drawn because the dimensions are too small.
View 3 Replies
Similar Posts:
May 13, 2011
Is there any way to get width/height of a loaded movie, excluding any area that is not displayed? My problem is that I am loading swfs to use as icons in a menu and am unable to get the desired width & height in order to calculate dynamic spacing based on how large the icons are. Most of the swfs where published with a document size of say 50 pixels x 50 pixels but some vary in dimensions. When I access the width or height property of the swf, I get a value that includes objects in the swf that fall out of bounds of the size set in the fla. Basically I get values that include areas that are effectively masked. So my 50x50 icon (that displays just fine), gets me a width of 63x86 or something like that. My sloppy workaround that I would like to replace was that I republished all of them with a extra property that I can read when I load them instead of using the width and height.
View 1 Replies
Dec 24, 2011
I wanted to put on the stage a png file with some transparent areas, unfortunately it weight too much.So instead I thought I'll create a shape object and use jpeg image as it's mask...
This is my code:
Code:
package {
import flash.display.Bitmap;
import flash.display.Shape;
[code]....
And it doesn't work, can I use jpeg images to mask the shape at all?
View 2 Replies
Jan 5, 2012
I made a simple test Air application to try different approaches to masking or using hitArea to ignore mouse events over transparent areas of a PNG. Can't seem to find the right mix of things to make it work, nor could I find a succinct example on the web.Clicking on the transparent areas of any of these methods don't result in the click getting handled by the background.Here's the code I have:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" [code].......
View 2 Replies
Jan 21, 2009
I have a simple Flash movie which loads several external PNG-24 images into movie clipsEach movie clip is partially transparent (using alpha transparency), and made drag-and-droppable. Everything works properly except that for each movie clip, I am able to drag and drop the clip using the transparent space around the image. I want the "grab-able" area of each clip to correpond to only the non-transparent areas of the PNG, not a rectangular box around each movie clip.
View 2 Replies
Jan 23, 2004
I've got a movie clip with masked-out areas. It's placed on top of various buttons.The idea is, the user rotates the top movie clip to reveal stationary buttons beneath it. Where there's a hole in the top movie clip, i'd like the user to be able to click the button revealed below.
It's looking like that's not possible. The buttons underneath cannot be activated, because the top movie clip is in the way, despite the transparency from the mask.
I'll begin thinking of a Plan B workaround, but first I wanted to ask if there's a way I'm not thinking of to do my Plan A.
View 2 Replies
Jan 23, 2004
I've got a movie clip with masked-out areas. It's placed on top of various buttons. The idea is, the user rotates the top movie clip to reveal stationary buttons beneath it. Where there's a hole in the top movie clip, i'd like the user to be able to click the button revealed below.
It's looking like that's not possible. The buttons underneath cannot be activated, because the top movie clip is in the way, despite the transparency from the mask. I'll begin thinking of a Plan B workaround, but first I wanted to ask if there's a way I'm not thinking of to do my Plan A.
View 2 Replies
Apr 27, 2009
I've got a movieclip called img_container that holds a draggable image (img_mc) and a mask over img_mc. I can save my img_container out as a transparent png which works great but the issue I have is that the png dimensions are still the size of the original img_mc. I fairly new to AS3 so I'm at a stand still. What I would like to do is save out the bitmap as only the visible area of the masked img_mc. The mask (called myMask) is also draggable and resizable so I'm not sure how to go about saving that specific area only.
View 2 Replies
Apr 25, 2010
I want to make a script that initially has a cursor I have chosen (an image) that is going to be "left" at a specific spot. The spots should be divided into a grid, meaning that if I am closest to point B, rather than point A, the object on the cursor should move/tween to that area. So far I have managed to find out how to move objects around freely and snap within one axis, but I need to specify some certain points that the object will adhere to. If it is to hard to make the cursor transform into the newly moved object then the cursor layer could simply disappear and another appear I would think.
View 7 Replies
Nov 18, 2010
What are the maximum dimensions of a bitmap allowed to be loaded and displayed in Flash?
View 1 Replies
Jan 31, 2010
If I create a rectangle with 100px width and 100px height and then rotate it, the size of the element's "box" will have increased.With 45 rotation, the size becomes about 143x143 (from 100x100).Doing sometimes like cos(angleRad) * currentWidth seems to work for 45 rotation, but for other bigger angles it doesn't.At the moment I am doing this:
var currentRotation = object.rotation;
object.rotation = 0;
var normalizedWidth = object.width;
[code].....
View 4 Replies
Apr 15, 2010
I want to clone an object of a class (whose source code I do not have) and copy all of the associated event handlers from the original object to the new cloned object. Does anyone know how I can do that? I know how to copy the properties from the original to the new, but can I iterate over all the event handlers and add them to the new object?
View 1 Replies
Apr 8, 2011
Is there anyone that can write a really basic physics engine including 1 ball and 1 solid object?
So it should be 1 ball and then 1 solid object like a box. The box should be completely solid, the ball shouldn't be able to go through the box, it should just stop when hitting it at any angle.
View 13 Replies
Aug 30, 2005
I recently wrote a small script to display an endless scroll for 360 degree images. The image is loaded dinamically so I can use it as a viewer for all the 360 degree images in the site's gallery. It works fine, but I found one image that appears truncated even though everything else works as expected. I found this [URL] that says: The maximum image size of a Flash 2 movie is 2880 x 2880 pixels The image that is giving me this problem is larger than that and it seems to be cut at 2880px widht. Can anyone confirm this? And if so, is there any way to override it since I'm using pure as? Despite the years working with flash, I keep finding these nasty surprises. Last time I learned about the 16,000 frame limit when working on a cd presentation... I wonder what's next.
View 2 Replies
May 31, 2011
I transformed a sprite with a simple rotationX and I would like to get the projected dimensions of the latter, i.e. the dimensions as they appear on the stage (see picture here : i.imgur.com/7Ugrv.png)The sprite is not in the middle of the stage, so a simple Math.cos doesn't work.Is there any ActionScript method or math function to get the dimensions ?
View 4 Replies
Jun 25, 2009
I am new to Flash and ActionScript 3.0 environment. I have only basical knowledge regarding this platform.
My issue/problem starts here:
I have a Sprite object on the stage.
What I should do in order to change the dimensions (viz.,size,colour, or both ,etc) of this Sprite object, when it gets clicked?[code]...
View 2 Replies
Jun 25, 2009
I have a Sprite object on the stage. What I should do in order to change the dimensions (viz.,size,colour, or both ,etc) of this Sprite object, when it gets clicked?My sample code looks like this:
Code:
var circle:Sprite = new Sprite();
stage.addEventListener(MouseEvent.CLICK,onStage);
function onStage(e:MouseEvent):void
{
[code]....
View 5 Replies
Aug 17, 2011
I bought this flying birds MOV file from istockphotos and now I'm stuck trying to implement it into my webpage, I want it to run like a flash file, every few seconds but I can't seem to be able to import it into Adobe Flash, I tried using the code below but it does not allow me to do much and is not transparent:
[Code]...
View 1 Replies
Jan 25, 2010
In AS3, I have a Sprite that has a Z axis rotation applied.How do I calculate that Sprite's dimensions (it's original size) from Sprite.rotationZ and Sprite.getRect(...)?
View 2 Replies
Jan 31, 2012
What do I have to write to keep the movieclip not to change dimensions if the user starts playing with the dimensions of his screen ? I remember it was a line of as3 written at the beginning.
View 3 Replies
Jan 26, 2010
Is there a way to transparent an object background which is imported into Flash? I have imported an object but it has with blue background color. I want to make its background to transparent.
View 1 Replies
Mar 6, 2008
Is there any way to test if a display object has been added to the display list?
View 9 Replies
Jan 22, 2012
can I resize a display object (container) without its contents (children) are resized?
For example, in the following code when I resize the green square, red is also resized. I wanted to resize only the green.
ActionScript Code:
import flash.display.Sprite;
var sprite:Sprite = new Sprite();
sprite.graphics.beginFill(0xff0000);
[Code].....
View 3 Replies
Oct 12, 2009
[URL] Comes in handy with jpg and gif elements in html.
View 1 Replies
Jan 31, 2011
Getting this little button to properly highlight in it's "over" state when it is behind another object with transparency.[url]...
View 1 Replies
May 30, 2010
have in my movie clip a png image with a Hole.
And I have another picture behind the png.
I've used this code to drag the picture:
Quote:
nave.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
nave.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
function mouseDownHandler(evt:MouseEvent):void{
[Code].....
It works well, but only if the picture is is Front of the PNG image.
View 2 Replies
Mar 4, 2011
What's a simple way to detect if a display object is currently on the display list?
View 1 Replies
Mar 17, 2010
I have several objects that share a single mask. I can see all of them when wmode is set to window but i want the background image on the page to show through the flash and have designed the flash around that. However when I set the wmode to transparent some of the objects don't render at all even though others do and they share the same mask.
View 3 Replies
Aug 14, 2009
Can you make one Bitmap Object (I'm using an external jpg) or something similar, and then display it many times simultaneously without creating a separate object each time?
Also, would they be easily removed or hidden?
I've got a little checkmark jpg graphic loaded here, but I'm not sure how to go about using it in many places at once.. I can only display it in the one place at any one time...
I'm thinking there might be a way to load the picture once, then use its bitmapData elsewhere in new display objects somehow, without needing to reload the image over and over?
View 3 Replies
Feb 9, 2009
It's my understanding that a display object cannot be in the display list more that once.So if I add something to the stage shouldn't a second addition of the same object replace the first? for instance:
[code]...
there should now only be one "myDisplayObject" on the stage.
View 3 Replies