Actionscript :: Draw Rectangle With Dashed Border In Flex?
Mar 21, 2011Draw rectangle with dashed border in flex ?
View 3 RepliesDraw rectangle with dashed border in flex ?
View 3 RepliesHere'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]...
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.[code]...
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.
How can I create a rounded rectangle with a dashed line? I've seen several routines that draw their own straight lines, but nothing for rounded rectangles.
View 2 RepliesAs i understand, flash cant assign dashed or dotted linestyles. Ive googled it for a while and found 2 classes which actually draw dashed and dotted lines, but i can't manage to implement it with my drawing tool.
[Code]...
Let's assume I have an Image that's used a button. By default, the image has no border around it. Clicking on this Image will cause another component be displayed beneath it or next to it. When the second component is displayed, I want to draw a joined border around the Image and the second component.
The second component would not be visible by default. It would only be visible after clicking on the Image by using the popupManager, PopUpAnchor, setting the visible property, etc.
Example before clicking:
+--------------------------------+
| |
| XXX <-- My Image |
| XXX |
| |
| |
| |
| |
| |
| |
| |
+--------------------------------+
Example after clicking:
+--------------------------------+
| +---+ |
| |XXX| <-- My Image |
| |XXX|_______________ |
| | | |
| | My Second | |
| | Component | |
| | | |
| | | |
| +-------------------+ |
| |
+--------------------------------+
How difficult would it be to create something like this?
[code]...
Basically this is not working. I used this question to improve - still nothing.Why doesn't this Flex App draw a simple rectangle?
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].....
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 RepliesIs there a way to easily specify on which sides a border is drawn for Flex 4's Spark BorderContainer?[URL]But that uses MX styling which seems like a hack. Is there a better or 'correct' way without having to build a skin? It seems incredibly silly to build a skin for a 'Bordered' component when this is a very common use case.
View 1 RepliesI have been doing much research on this - including creating a custom skin but cannot seem to be able to do it. I just want to have one border around both the checkbox and label. I also want a background color which I did manage to via opaqueBackground property (setting it via AS3). Just can't seem to find the key to have a border as well.
View 1 RepliesMy basic requirement is to draw a circle inside a BorderContainer with the layout set to BasicLayout.I run this method in the CREATION_COMPLETE event of the BorderContainer object.[code]I know I must be missing something VERY basic here. Can I just draw like this OR should I draw in some other event? I know that I can create a Ellipse object and easily add it to the border container but I would like to know how I can do this using the graphics object.
View 3 RepliesI am drawing a rectangle at 0,0 with a line-style-thickness of 4px. It has height 100% and width 50%. The right-hand edge has a border 4px wide, but all 3 other sides are only 2px, suggesting the mid-point of the edge is classed as the border. Why isn't the edge drawn 'inside' the rectangle?
View 1 Replieshow can I change or tween the color of a dynamic rectangle's borders ? (created with LineTo)I d'like the color to change when I hover the rectangle...Right now I 've always been to change the global color of the rectangle with it changes the color of the borders too.
View 1 RepliesI have a rectangle and I want to change its border colour on mouse over, I have found a way to make it work but that redraws the whole rectangle, i am wandering is it possible to only manipulate border colour without redrawing rectangle?
PHP Code:
import flash.display.Sprite;var rect:Shape = new Shape();rect.graphics.lineStyle(3, uint("0x666633"));
rect.graphics.beginFill(uint("231f1c"), 1);
rect.graphics.drawRect(0 , 0 , 60 ,10 );
rect.graphics.endFill();
[Code] .....
I have a template which loads thums form XML file, i want to modify the thumbs to have a border around each one and alfa rollover effect.
Code:
function createThubmnail(thumbURL) {
thumbsHolder.attachMovie("itemPhoto", "itemPhoto"+photoN, photoN);
eval("thumbsHolder.itemPhoto"+photoN).picture.picture.loadMovie(thumbURL);
eval("thumbsHolder.itemPhoto"+photoN).d_w = widthThumb;
[code]....
how to draw a border around image or movie clip?
View 11 RepliesI'm trying to write some ActionScript which will accept a mask and an image, then mask the image and put a border around the result (assuming that the mask is always 100% opaque).
For example, if my mask is a poorly drawn star, and my image is a bunch of flowers, I want the result to be a poorly drawn star with flowers inside it and a border around it. Something like this:
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 Repliesi 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 Replieshow to draw border for even/uneven shape object? it is stored in a movieclip
View 0 RepliesI 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
How would I draw a rectangle on the stage with 40% alpha? using bitmaps, bitmapdata, and copypixels?
View 2 RepliesI'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] .....
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 RepliesI 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 Repliesis it possible to draw a rectangle specifying which corners should be rounded and which not in a simple manner?
View 3 RepliesI have got a new requirement in which i have to display my Column Chart in dashed manner.
View 1 RepliesI can't post images yet: [URL]. Using Actionscript 3 I'm drawing multiple Shapes onto a MovieClip [top drawing]. The end result I need is the bottom drawing. I originally thought it would be simple to just merge the shapes and then find a way to draw a border around the end result but I can't seem to find any way of doing this. Is this possible or is there a better way of trying to do this?
View 1 Replies