Actionscript 3 :: Drawing API On Flex 4 Stage?
Oct 11, 2010
I'm currently trying to debug a problem in Flex 4, in where a component is firing a custom event with its local coordinates translated to global coordinates (i.e. localToGlobal) and another component (in a separate "branch" of the display list hierarchy) recieves such event and uses it as a part of an animation, via globalToLocal. It should be a simple, coordinate-transformation system but it is not working.I'm trying to debug this, by using AS3's drawing API to draw circles where the Points should be.Here is the dispatching component (Component A in the image below):
// Check where is the local x,y
this.graphics.beginFill(0x0000FF);
this.graphics.drawCircle(this.x,this.y, 10);[code].......
One would expect the three circles (Red, Green and Blue) to correspond, each being drawn just before the event dispatch and one (green) on event listening. What actually happens is:
Blue circle is drawn where you would expect it.
Red circle is never drawn (hence, my question on drawing on the stage in Flex 4)
Green circle is drawn in an un-expected place.
EDIT: Here is an image that explains the relationship between components and where are the dots being drawn:
View 1 Replies
Similar Posts:
Jan 12, 2010
I tried to erase whatever was drawn on the stage by using a similar function in a recent previous post but I'm not getting it.when I try to use it an error says that this is no longer supported. I tried addChildAt() and inserted different Num but it only erased everything including my button.the current code is:
var drawing:Boolean = false;
this.graphics.lineStyle(5,0x000000);this.graphics.moveTo(mouseX,mouseY);
this.addEventListener(Event.ENTER_FRAME, onLoop, false, 0, true);stage.addEventListener(MouseEvent.MOUSE_DOWN, onDown, false,0,true);stage.addEventListener(MouseEvent.MOUSE_UP, onUp, false,0,true);
[code]....
View 2 Replies
Nov 5, 2010
I started working with AS3 a month ago, I know the basics and stuff, but I can't do that much. The user would draw lines by clicking on the stage. The code works exactly as I wanted it to, but it is on AS2 . I tried, but I can't 'convert' it to AS3. I would like to know how this code would work on AS3! Here's the download link of the .fla, so you can see better what I mean: [URL].
View 3 Replies
Jan 13, 2010
I keep trying to change the code so that I can control the area for drawing. The attached code is where I left of after many tries. The movie clip box_mc is being called from the library.
View 3 Replies
Mar 31, 2011
I'm drawing with Flash's brush tool and the marks I make are appearing not just where I draw them, but also in the timeline or elsewhere on the stage. It goes away if I minimize and restore, but this is a big time-waster.
View 1 Replies
Jan 29, 2012
I have a little problem with counting all elements on stage. Flash, unfortunately is counting all objects on the stage without drawn objects (all shapes, including drawing objects, rectangles etc) all missed. Is there any way to count them?
View 2 Replies
Jan 13, 2011
flash and at the risk of sounding like an idiot, here goes.My question is:How can I make it so that the stage is divided up into a grid of 4 by 4px spaces that can be filled with a color after a click?So far I have some code that lets you draw a 4 by 4px dot but the dots can overlap because there is no grid:
dot.addEventListener(Event.ENTER_FRAME, do_stuff);
/*dot is a movie clip of a 4x4 black dot*/
function do_stuff(event:Event):void
[code].....
View 4 Replies
Dec 4, 2009
I got this code from [URL]; it writes an image to stage as a way of tile it.
holidaytile is an instance of a Gif Image.
But I want to change the Alpha so that my top layer shows through it, and I can't seem to figure out how to do that.
import flash.display.BitmapData;var tile:BitmapData = BitmapData.loadBitmap("holidaytile");this.beginBitmapFill(tile);
[Code]....
View 3 Replies
Sep 29, 2010
I need to use a Timer for time controlled animation, time the drawing to occur every 500 milliseconds & Draw 20 circles in total. I also need to make sure the circles are completely drawn inside the limits of the stage...
import flash.events.TimerEvent;
import flash.utils.Timer;
// creates a new hundred-second Timer, ticks every 250 milliseconds
var faster_minuteTimer:Timer = new Timer(250, 6);
// designates listeners for the interval and completion events
[Code] .....
View 2 Replies
Jul 28, 2011
I have a little snippet of code that allows the user to create a line with the mouse, and clears the line if they end up touching the hitbox with the mouse, while they're drawing the line. It works fine when it's just thrown onto the main timeline. However, when I try to encapsulate it within a movie clip, it suddenly doesn't work. At all. Are there any suggestions as to why this is happening? Here's the code.
[Code]....
View 13 Replies
Jul 15, 2004
This time round i need to get the pattern drawn on the drawing board to be repeated on another area of the stage.I need it to be repeated 4x4 tile.
View 1 Replies
Oct 8, 2008
Someone told me once that every function in Flash has some associated actionscript being executed behind the scenes, e.g. converting a graphic to a symbol or drawing a pentagon on the stage. This person also told me that there is somewhere in which you can view said ActionScript as it's being executed. How can I do this? I deem such a feature necessary to do the projects I have been given, especially having very little experience with AS.
View 1 Replies
Feb 1, 2011
I just need a simple code of drawing a text curve in flex
View 2 Replies
Nov 9, 2010
i've tried to simulate a pencil tool, for drawing above a imagem, but the drawing is below the picture. How fix it?
[Code]....
View 3 Replies
Dec 23, 2009
I'm trying to write some code to an animated images of squares on a Flex Canvas There's something wrong with my code below because it becomes progressively slowerI assume I'm supposed to clear the old squares or something.What am I doing wrong below?:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init();">
<mx:Script>
[code].....
View 1 Replies
Aug 4, 2011
I've created a line chart in flex and it works like expected. Now, I would like to add shading to the background for specific information. For example, this chart - [URL], shows a shaded background for recessions. How would I mimic this shading in a Flex linechart?
View 2 Replies
Jul 22, 2009
Basically I've got a reasonably complex drawing object in a fla and I want to reproduce it in a class definition using the drawing api. However obviously this is a tedious task, so is there some trick or automated method of doing this?
Last time I needed to do this it was a drawing of an arrow and I ended up writing down x,y,width,height values for everything but this one has curves in it which I don't have experience with drawing anyway.
View 2 Replies
Oct 25, 2010
It looks to me like the easiest route in AS3 is to use a Shape/Sprite's Graphics property to draw these lines, clearing and re-drawing each time the stickman changes. But some of the newer Flash 10 stuff seems to suggest a closer functionality to 3D graphics where you can define points and lines/triangles and then move the points rather than recreating all from scratch each render. Is this the case?
View 1 Replies
Nov 15, 2009
My code is on the main timeline.I call a function loop to draw lines between them.The lines are drawing between the right x, y values BUT between those values on the main stage, not those values within the kite.For example, dot1_mc is at x100, y0 inside kite. the line that should go from its center, draws from stage x100, 0.How do I draw the lines inside kite so that they draw between the dots?Heres my code that draws the linesPHP Code:
function loop():void{ lineDrawing.graphics.clear(); var a:Point = new Point(kite_mc.dot1_mc.x, kite_mc.dot1_mc.y); var b:Point = new Point(kite_mc.dot2_mc.x, kite_mc.dot2_mc.y); var c:Point = new
[code].....
View 4 Replies
Sep 28, 2009
I cannot get this to work. Without the "var drawing", "var drawing being true or false" and the "if statement", it works fine. But I need to add the "var drawing" so that you can only draw if you turn it on by pressing the "draw_btn" button. Note, I do not get an error, the script "apparently" contains no errors. Here is the code:
ActionScript Code:
var drawing = false
_root.createEmptyMovieClip("myLine", 0);
[Code].....
View 3 Replies
Jan 13, 2012
I've created a drawing tool which allows the user to draw on the canvas, the problem is that if I try to draw over a movieclip nothing happens. Is there a way I can allow for the user to draw over movieclips? For example if I had a background of paper?
Here's the code I'm using for it:
// This code is for drawing the lines on the page
//1.
var drawingLine:MovieClip = new MovieClip();
addChildAt(drawingLine,0);
[code]....
View 8 Replies
Sep 21, 2010
I'm using flex sdk and trying to draw primitive geometry figures, what is wrong in following code? i tried without the trigger(placing) of button, but did not work.
<mx:Script>
import flash.display.Sprite;
import flash.display.Shape;
[code]....
View 2 Replies
Jan 24, 2011
I have one left panel in which there are different shapes like start,end connectors..... when i drag line image inside canvas i want to draw line/connector between two shapes how would i do it
View 1 Replies
Feb 9, 2011
I want to develop an image editing application in Flex 4. My initial requirement is to draw various shapes like Line, Rectablge, Triangle, Circle, Star etc in appication. I want to facilitate user to draw shapes using rubber banding like professional applications do.
All shapes would be vector and should look smooth in an size. So, can't use bitmap and scale them.
What are better methods to achieve this?
View 2 Replies
Feb 16, 2011
i want to draw a line with actionscript .Here is my code
<?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 2 Replies
Jul 28, 2009
I wonder which component to extend in Flex 3 in order to make a drawing stage.
View 1 Replies
Mar 31, 2010
I am simply trying to draw a rectangle inside of a panel using flex4. I am using spark instead of mx. It complains about addchild being replaced by addelement; however, addelement expects type ivisualcomponent. I think sprite should be of that type; however, it reports an error when trying to use the below code... I have tried a few different ways. I think I am missing something very basic about flex 4.
[Code]...
View 3 Replies
Apr 13, 2010
Update: Once and for all, how can I draw a line that goes from (0,0) to the opposite corner of the stage?Here is what I have:
package
{
import flash.display.Sprite;
[code].....
View 1 Replies
Aug 4, 2010
I have a project where we are trying to skin Spark components from a third party library that are built up from the drawing API primitives. Our first attempt involved creating a Flex skin (SWC) in Illustrator/Flash and applying that skin to the Spark components via CSS. We found that even with only a single instance of one of the components skinned in this way on stage, the application was brought to it's knees. For example, it failed to respond in repaint scenarios in a timely manner, and exhibited all the symptoms of being hung.
Our next approach will be to recreate the same skin artifacts in MXML classes that are in turn associated with the third-party components. Although the complexity of some of the skins leads me to believe that we might not avoid performance problems with this approach either. My question is the following: Is there a correct or recommended way to apply either a SWC or based skin to a component that is built up from the Spark drawing API to begin with? Even as I ask the question I recognize that the approach means using the Spark drawing API in two places and will probably have unexpected consequences.
View 1 Replies
Jan 14, 2011
In order to set a background image for my Desktop Flex application, I created a custom skin class, setting the skinClass property to my custom MXML skin. The host component is SkinnableContainer. I use a bitmap image for the custom MXML skin. Everything works fine, except that it's drawing over all my components. How do I get the skin to draw in the background? Should I move the Bitmap markup to somewhere else in my skin file?
View 1 Replies