Actionscript 3.0 :: Get Bounds Of A Rectangle On Stage
Apr 30, 2009
I have a simple MC on the stage. I want to create a simple conditional statement that would check if the mouse is on the rectangle using get bounds. something like [code]Basicaly...how do I properly use the getBounds in a situation like this?
View 3 Replies
Similar Posts:
Dec 28, 2011
i cant get "on stage" bounds of sprite that rotated in 3d space
Code:
var draggableContent:Sprite=new Sprite();
var _3dContent:Sprite=new Sprite();
var _child3D:Sprite=new Sprite();
[Code]....
View 0 Replies
Dec 15, 2010
I am creating an app that has to load a image or swf on to the stage and dynamically place and position it on either sides of the stage i.e. (top, left, bottom or right).how can I dynamically calculate the remaining bounds of the stage using the bounds of the dynamically placed loaded image/swf. ?e.g if the bounds of the loaded clip isRectangle(x=10, y=10, w=250, h=800);What is the remaining Rectangle() to use ofRectangle(0,0,1024,800); ?
e.g if the bounds of the loaded clip is
Rectangle(x=0, y=0, w=800, h=50);
What is the remaining Rectangle() to use of
[code].....
View 3 Replies
Apr 13, 2010
from my main class i call to create a sprite and add it to the stage
private function addSwatch(evt:MouseEvent):void
{
if (stage.getObjectsUnderPoint(mousePoint()).length == 0)
{
[Code]....
View 1 Replies
Apr 11, 2007
I'm having a little difficulty getting to grips with the getBounds() Movie Clip function. I assumed the getbounds() method simply got the boundary coordinates for the movie Clip, that one could use to draw a rectangle. This is what I'm trying to do;I'm trying to get a movie clips coordinate bounds, and use the min and max values of x and y to draw rectangle around the object. Simple right? But in my case, I'm getting some unexpected results. I wonder does ther registration point of the object determine the coordinate values? Also are the coordinate values local to the clip instance or global to the stage?
[Code]...
View 5 Replies
Jun 23, 2009
I have a bunch of images going on all at once, some on the stage, and some off, and i would like to find a way of telling whether or not they are currently on the stage or not....
I know i can do the whole
checkStage = function () {
if ((mc._x>=0) && (mc._x<=Stage.width) && (mc._y >= 0)&&(mc._y >=Stage.height)) {
//have mc do whatever here
[Code].....
that way i can satisfy my laziness AND achieve what i'm trying to do without having to deal with long winded paths and a bunch of else if's
View 1 Replies
Jun 9, 2006
I have a "circle_mc" movie clip and its registratoin is in the center but it moves and works fine but i dont want it to go off the stage half way I want it to stop before it goes off
ActionScript Code:
circle_mc.onRollOver = function() {
this.dx = Math.round(Math.random()*Stage.width);
this.dy = Math.round(Math.random()*Stage.height);
this.onEnterFrame = moveIt;
}; function moveIt() {
this._x += (this.dx-this._x)/10;
this._y += (this.dy-this._y)/10;
if (Math.round(this._x) == this.dx) {
this._x = this.dx;
}}
View 4 Replies
Jul 27, 2009
When using the Loader class to load an external SWF into another timeline and then displaying that SWF using addChild on the loader.content, one discovers to one's consternation that elements positioned off the stage of the external SWF are still displayed.To illustrate this with an example: suppose you have a 500x500 pixel "main" SWF, and it loads an external SWF at runtime and positions it in the center of the stage. And suppose that this external SWF's document properties set the stage width to 200 x 200 pixels. However, when authoring this external SWF, we draw a box that's 300 x 300 pixels, so part of this box is actually off-stage.
When you play the external SWF in the standalone Flash player, it is sized correctly at 200 x 200 pixels, and the rest of this box is cropped off.When you load this external SWF into the "main" SWF and use addChild() to put it on the stage, you will see the full 300 x 300 pixel boNow of course, we can simply solve the issue using a mask, but I'm wondering whether there's a more elegant solution that's built in, either to the MovieClip or the Loader or the LoaderInfo classes. Something that says "respect the document bounds of the original SWF" or "crop to stage dimensions".
View 1 Replies
May 7, 2010
If an object exists outside of Flash's stage boundaries, is on the Display List, and is visible, is it causing a performance hit from Flash rendering it? In other words, does Flash render what isn't seen?
This leads me to believe so:
http://stackoverflow.com/questions/170203/how-do-you-make-flash-not-render-an-object-on-the-stage
View 1 Replies
Jul 2, 2010
is it possible for flash to detect off-stage mouse coordinates in order to continuously drag an object within its bounds while the mouse is moving outside of the stage? for example: i have a draggable red square on my stage. the stage is the bounds of the drag. if i drag the red square to the bottom of the stage and continue to drag outside of and around the stage, i'd like the red square to continue moving within it's bounds, following the mouse coordinates. currently, dragging halts as soon as i leave the stage and the red square only begins to move with the mouse coordinates if i reenter the stage bounds.
View 2 Replies
May 3, 2010
I have a class called shapeC that only creates a rectangle and then addChild(rectangle);. That class is instantiated on the main timeline. Currently, the only way you can see that rectangle is to add the instantiated class to the stage via addChild(shapeC);. My question is, is there a way that the shapeC class can add the rectangle to the root stage without requireing the instantiated class to be added to the stage?
View 4 Replies
Oct 9, 2007
how to make an invisible rectangle on stage that could be clicked for example
View 0 Replies
Aug 14, 2007
I have my stage set at 500px x 500px. I have a map mc on stage that is 2500px x 2500px and I am trying to mouse scroll the entire map mc inside the bounds of the 500px x 500px stage. The map mc xy ref coordinate is in the center of the graphic. This is a math problem for me. An example would be [URL]
View 1 Replies
Mar 1, 2011
Is there a simple way to take existing rectangle on the stage and "flip" the rectangle so that if it was on the left it's now on the right side?
View 2 Replies
Oct 5, 2009
How would I draw a rectangle on the stage with 40% alpha? using bitmaps, bitmapdata, and copypixels?
View 2 Replies
Dec 8, 2009
I'm learning ActionScript 3.0 and I made a small app to draw rectangles on stage. Now I want to drag&drop them around. I want to be able to click on an object, without triggering the stage.addEventListener(MouseEvent.MOUSE_DOWN, clickEvent); but when I click on an object, it also triggers that event. How can I save the click on object from triggering that event on stage?
Here's the code:
Main.as
package {
import flash.display.Sprite;
import flash.events.*;
public class main extends Sprite {
var startX, startY, endX, endY: Number;
function main() {
[Code] .....
View 0 Replies
Nov 14, 2009
I am using the drawRect() method. The only way I know how to colour something is by using beginFill and endFill(). But if it's already drawn then how can I change it? It
View 2 Replies
Oct 23, 2009
I currently have a button that triggers an event merging the movieclips on stage into one sprite, and passing it to a printer class. The printer class looks as follows:
ActionScript Code:
public class Printer {
private static var printJob:PrintJob = new PrintJob();
private static var printJobOptions:PrintJobOptions = new PrintJobOptions();
[Code]....
The problem is that when clicking the button, the stage gets a white rectangle in the upper left corner that can't be removed!
View 1 Replies
Jun 2, 2011
I would like to take a straight line/rectangle that is already created on stage and tween it with as3 so that when mouse is down, i can drag and bend it into an ark shape, and when i release the shape snaps back to its originally form?
View 2 Replies
Aug 26, 2009
I need to have a shape (black rectangle) that will cover the stage. It should resize with the stage when needed. I'm trying it with the following code, but when it's resizing, there is a clipping effect that is visible and it is not fluid. How can I prevent this?
Code:
Select all
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, resizeHandler);
var blinder:Shape = new Shape();
[Code] ......
View 4 Replies
May 14, 2005
I had to create dynamic with AS some rectangular on stage using moveTO and lineTo. I had a button and when I press it should add a new rectangle on stage but it doesn't. Because the array that I am storing the MovieClip created are overriding I guess
var i:Number =0;
button_name.onRelease = function() {
i++;
var instancename:String ="new_mc"+i;
var mcClip:MovieClip=createEmptyMovieClipinstancename,this.getNextHighestDepth);
[Code] .....
View 1 Replies
Mar 8, 2010
For those of you still with me, I am tasked with making some scrollable content in Flash. Load in a TextFile using LoadURL(), then display it. To get the text, we've written our own class TextFieldExtended, which is basically just there to give the textfile location to the constructor and then have the class do the various steps of getting it and loading it for you.So I needed to get a Scrollbar, which I got hereThe thing is, it works with Sprites.After trying to get it to accept TextFieldExtended, I bumped into a block, since the scrollbar relied heavily on a Sprite property that TextFieldExtended didn't have or could have.
So I tried adding the TextFieldExtended instance to a Sprite instance using addchild.A problem occurs here that I do not know how to handle. It seems that a Rectangle is drawn and the Text is drawn on that. I say this because the scrollbar moves the Rectangle up and down a bit, but the text doesn't scroll, just the Rectangle it is positioned in and the text then moves along with it.My question: can this be fixed, or is does this implementation of scrollbars need a lot of adaptations before this is possible?
View 1 Replies
May 20, 2009
I draw a rectangle i should see a little bold circle to indicate a perfect rectangle, I seemed to lost mine, can somebody please tell me how to get it back!
View 2 Replies
Aug 2, 2011
I am trying to convert a rectangle(actually multiple rectangles) to a curved rectangle. I think it should be pretty easy but I guess i am stupid. Basically I would have a start position and stop position (many of these), and they would be converted to curved rectangles and follow in a cicrle around.
View 0 Replies
Jun 26, 2010
I would like to create a rectangle inside of a rectangle, starting approximately 15% inward from the right side of the other rectangle.
I know how to create rectangles with:
Code:
var newHotRect:MovieClip = new MovieClip();
newHotRect.graphics.beginFill(0x00FF00);
newHotRect.graphics.drawRect(0, 0, 100, 100);
addChild(newHotRect);
But how would I make another rectangle on top of that (the black one pictured) that is approximately 15% from the right?
I toyed around with .right, and .bottomright with no success. Can anyone lead me in the right direction? or even finding the x and y of the upper right or bottom right side of a rectangle?
View 10 Replies
May 20, 2011
how to respond when a rectangle hits another rectangle? I already know how to detect the collision, I just don't know how to respond to it. I'm just trying making a simple side-scrolling platform game where I have platforms I can walk on and bump against on all sides. I have searched everywhere and just can't find the tutorials I'm looking for.
View 6 Replies
Mar 3, 2009
I opened up the NY Times homepage, and they have this giant Apple addvertisement that has animations over the entire top half of the page, outside the area occupied by the swf.
View 1 Replies
Nov 10, 2011
Although I put _x = player._x etc. code in an onEnterFrame function the masking mc is moving without the player
You see...the player is held within some borders. When cornered and then hit, the mask moves according to how it would move normally, but without the player (because he is held in place by some borders)...
Also, if I don't have a problem but I'm missing a crucial piece of code,
code on masking mc
ActionScript Code:
stop();
this._x = _root.player._x;
this._y = _root.player._y;
radiance = 180 / Math.PI;
[Code]...
View 1 Replies
Jul 9, 2010
for some reason this flex 4 code gives me an error but I can't figure out why. In my WindowedApplication I have:[code]That seems like a bogus error since I can assign pref.bounds to rect without an error. I don't know why this isn't working. It works under flex 3 compatibility mode but that also breaks a lot of my spark components so I can't use it.
View 1 Replies
Mar 12, 2008
I have a script that produces random motion along the y axis, however, I want that motion to occur within the movie clip that is centered on the stage, or I should say within the bounds of that movie clip.
The movie clip has a height of 335 px
[Code]....
View 9 Replies