ActionScript 3.0 :: Application To Draw Rectangle On Stage?
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
Similar Posts:
Oct 5, 2009
How would I draw a rectangle on the stage with 40% alpha? using bitmaps, bitmapdata, and copypixels?
View 2 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
Sep 18, 2009
In Flash CS4, when I draw a rectangle (or circle, or anything) with a color that has 0 alpha, nothing is drawn. Also, if I select a piece of drawing and change the color to 0 alpha, the drawing (e.g. rectangle) disappears!I know I can draw a non-transparent rectangle, convert it to movie clip and set the movie clip's alpha to 0, but I'd like to avoid this.
View 5 Replies
Sep 20, 2011
[code]...
Basically this is not working. I used this question to improve - still nothing.Why doesn't this Flex App draw a simple rectangle?
View 1 Replies
Aug 26, 2005
i don't know if i'm posting at the right topic but i would like to know if anyone can tell me how to auto draw a rectangle around an image? for example, the image loads and is static then a rectangle is drawn around the image starting from the top left corner and goes around the rectangle back to the start of the image.
View 14 Replies
Jul 27, 2008
I Created an action script code when the mouse Down and Drag I taks the X,Y postion in the first and when the mouse is Up it take the Final X, Final Y and Draw Rectangle
I need to Show the User the Rectangle with the mouse Motion (like when you draw in photoshop ) But in my Code the the Rectangle appears when the mouse up
I attached The Code to the msg
View 3 Replies
May 6, 2011
the code is straightforward and my Intention should be clear. Still i can get this to work:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
[Code].....
View 1 Replies
Mar 25, 2006
I'm trying to draw a filled rectangle with no border. Here's the code for my test project:
ActionScript Code:
myMC = this.createEmptyMovieClip("", this.getNexthighestDepth()-1);
myMC._x = 0;
[Code].....
If you take a look at the coordinates, this was suppose to draw a 180x22. Well, it looks lika it draws a 180x22 rectangle, but only if the zoom is at 100%. If I zoom in on the flash player, there are two problems:
1) the line, as it is scaled, goes over the shape edge. Basically, as the border line has 1 pixel, Flash starts do draw it half pixel up and half pixel left; 2) the rectangle is in fact a 179x21 pixels, instead of the 180x22.
I'm sending an example project on an attachment. In this example I have 2 vertical rectangles which act as buttons:
1) the first button draws the rectangle step-by-step;
2) the second button cycles through 3 different styles:
2.1) line with 1 pixel, normal border rescale. This is the style at start;
2.2) no line;
2.3) line with 1 pixel, no border rescale.
The background is a checker texture, with 1 pixel per square. This gives you a perfect look on how the line is drawn.
The drawing instructions are executed on the yellow movieclip, which serves as reference, considering that it has the desired dimensions (180x22). *
If you zoom a couple of times you'll be able to see the problems I'm experiencing.
All you have to do is to click the first vertical button several times to draw the lines, to press the second vertical button to reset the draw and to change the border style, and finally to look at the draw with some zoom in, in order to see it in detail.
So, what can I do in order to draw a perfect rectangle, meaning that the border will not go outside the shape (it would be nice that when the border is rescaled, it does it inside the boundaries of the shape) and the rectangle has right dimensions (why am I missing one pixel in each direction?).
* By the way, is there a way to draw in a movieclip using the lineTo in such a way that the drawing is on the topside instead of the bottomside? I had to make the yellow rectangle partially transparent in order to see my drawing.
View 9 Replies
Jun 21, 2011
Is there a way to apply styling to the line of a rectangle that is drawn using AS3? So instead of the solid stroke, can I apply a dotted or a dashed one?
View 3 Replies
Feb 25, 2009
I am trying to draw Round Rectangle on Mouse Down. The width and height is depending on the new positions of mouse x and y. But it is not working as I wanted it to be.
View 1 Replies
May 23, 2009
is it possible to draw a rectangle specifying which corners should be rounded and which not in a simple manner?
View 3 Replies
Mar 21, 2011
I try draw one pixel width rectangle in a sprite. And add some tween on it to make some effect. But I find use the code below can't create exactly one pixel white rect. I created I want to create
[Code]....
View 1 Replies
Mar 21, 2011
Draw rectangle with dashed border in flex ?
View 3 Replies
Oct 10, 2005
I want to be able to draw a rectangle within my flash movie by clicking one point and dragging the cursor to another.
View 3 Replies
Jul 28, 2006
Is it possible to draw a rectangle dynamically using 'lineTo()' and have it fill with a gradient that is 100% alpha on one side and 0% on the other?
View 2 Replies
Aug 28, 2009
My idea was to create a method for drawing rectangle with rounded corners, but while being able to specify which of the four corners (any, all, none,etc.) you wanted to round. The method below does the trick, but for some reason my corners don't match the same curves that I get using the same radius with drawRoundRect(). In other words, if I call my method (and set all four corners to be rounded) and compare that with the same call to drawRoundRect() the actual curves of the corners are slightly different.
HTML Code:
public function drawComplexRoundedRect(startX:int,startY:int,rectWidth:int,rectHeight:int,radius:int,canvas:Sprite,roundTopLeft:Boolean=false,roundTopRight:Boolean=false,roundBottomLeft:Boolean=false,roundBottomRight:Boolean=false):void{
if(roundTopLeft){
canvas.graphics.moveTo(startX,(startY+radius));
[Code] .....
Then compare
HTML Code:
var canvas:Sprite = new Sprite;
drawComplexRoundedRect(0,0,200,200,25,canvas,true,true,true,true);
with
HTML Code:
var canvas:Sprite = new Sprite;
canvas.drawRoundRect(0,0,200,200,25);
and you will see the two rectangles are not identical.
View 2 Replies
Mar 18, 2009
I am using the draw() method of the BitmapData to encode a jpeg of part of the image. Now this should be easy enough given the object I want to draw to the bitmap is on the stage at design time so I know its location and dimetions exactly! Heres the code I have in place.
Code:
var myBitmapSource:BitmapData = new BitmapData ( street.width, street.height, false, 0x333333);
myBitmapSource.draw(street, null, null, null, new Rectangle( 96, 5, 571, 450 ), true );
I know for a FACT that no part of the street clip I am drawing out is in negative space, and it's registration is (0,0). However, it cuts off A lot of the top of my image. y=5 in the above rectangle is where I need the top to be, but it cuts the top off of the image... even if I change it to 0, it has no effect.
View 2 Replies
Apr 23, 2010
Im probably overlooking something simple, but when I try to draw a rectangle Flash is automatically applying a corner radius. I've tried resetting the options in the Properties Inspector, which resets to the default, but soon as a draw a shape it goes right back to a random radius.
View 4 Replies
May 10, 2005
I need to to incorporate a functionality where the user can use his mouse to draw a rectangle by dragging his mouse over the canvas - much like the Rectangle Drawing Tool in the Flash Authoring environment. The requirement is something like a rubberband tool where the user can define a portion of a map by drawing a rectangle over it. The coordinates needs to be captured.
View 1 Replies
Feb 1, 2004
Here's my latest attempt at rendering a dynamic rectange (w/ width, height, border_width, border_color & background_color) I'm trying to render a dashed border, and can't seem to get the code right...
I've reworked my logic about five times, and can get the dashes to render right (almost) but the fill color disappears. It's rendered using actionscript. You can see the issues if you change the border width... Anyone mind taking a look to see what I'm doing wrong? It seems like the moveTo function isn't behaving right when I get to the end of each line.
[Code]...
View 3 Replies
May 10, 2005
I need to to incorporate a functionality where the user can use his mouse to draw a rectangle by dragging his mouse over the canvas - much like the Rectangle Drawing Tool in the Flash Authoring environment. The requirement is something like a rubberband tool where the user can define a portion of a map by drawing a rectangle over it. The coordinates needs to be captured. Can anyone help me with the actionscript.
View 1 Replies
May 18, 2011
I have the following code to create a Sprite with a rectangle in it:
container = new Sprite();
container.graphics.beginFill(0x00CCFF, .5);
container.graphics.lineStyle(1, 0x00CCFF);[code].......
The only thing is, I'd like the registration point to be in the middle (not the top left corner). Is there a way to set up the registration point in the middle of the rectangle, but still have the position of the rectangle be correct?
i.e. not moved over so that the top left corner of the rectangle is in the "middle" of where I want the rectangle to be...
View 1 Replies
May 11, 2009
I want to make an editor like this site. [URL] If you browse this link you will find "Button. If you press this button you will navigate to a editor to design your layout. After draw a rectangle or circle or line you can resize that or can rotate that. When you finish if press the "you will back to the previous page where your desinged layout display. If you press the "" again then you will navigate the editor with the previously designed layout. I want to make a site like this. I want to use the flash cs4 to make the editor. Anybody knows how to draw a rectangle or circle shape with mouse and how to scale by setting the point and how to rotate by setting the rotation point also by using flash cs4 and as3?.
View 3 Replies
Mar 15, 2010
I need t draw a rectangle on a movie clip(board_mc) by dragging mouse over it......It works fine till here but I want to put the movie clip(board_mc) in scrollpane.
but after doing so the code doesnot work....can u plz guide me how to make this code work after placing the movie clip (board_mc) in scrollpane(say board_scp).
[Code]...
View 5 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
Jan 9, 2012
I am having an issue with using BitmapData.draw(stage). I am getting the following error:
SecurityError: Error #2123: Security sandbox violation: BitmapData.draw: file:///C|/Documents%20and%20Settings/bla...bla...bla.swf cannot access null. No policy files granted access. Here is a portion of my code:
var bd:BitmapData = new BitmapData(2800, 2100); bd.draw(stage);//this is where the error happens All of the files referenced (.xml/.jpg/.swf) are located in the same local folder as the main .swf. How do I get around this error? The main objective is to print the stage using PrintJob(). I am using Flash Professional CS5.5 and publishing to Flash 10.0/10.1. Let me know if I need to supply any more info.
View 4 Replies
Dec 2, 2010
in the following SWF example: [URL] you can see small iphone application created with flash cs5, this application has blue rectangle, you can drag and drop this rectangle with your mouse cursor.. ok no problem in the code, but i want ask a question: when i run this application in iphone device, my finger will drag and drop the rectangle instead of mouse cursor ? or I need change the code? here is the code i used:
[Code]...
View 1 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
Jan 31, 2010
I am trying to have flash draw a line from the center of the stage out and increment around the stage. Not sure what math I would use to do this though. So far I have the line going out to a certain point but not sure how to change that point so that it circles around whatever the dimensions of my stage would be.
So far I have this:
var linetox=0;
var linetoy=0;
var _stage=this;[code]...
which obviously moves the destination ending of the line lower and lower, just trying to get it to draw around the screen (like a clock)
View 1 Replies