ActionScript 3.0 :: Flash- Drawing Api Bug Work Around?
Jun 7, 2010
I've come across a bug in flash drawing api where if you draw many (24) light opacity layers things get blotched especially if you use bitmap.draw(). I have read somewhere that this is how the draw method has been coded but I don't see any work arounds.
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.
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.
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);
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);
I need to draw on stage about 40,000 4x4 squares each a different color. The color is determined by an xml file. I have this working in as2 and have converted it to as3 the problem is the amount of time it takes to draw is causing cs4 to time out. I have extended the script time out to 60 seconds. In cs3 as2 it would draw the squares in about 15 seconds. I was hoping as3 cs4 would improve performance but seems to be the opposite. I have tried several methods such as adding children and various drawing variations. the bellow seems to work the best, but is still causing flash to crash.
I'm in the process in making a little drawing board using flash Drawing API. Right now i have the lines drawn by using lineTo() but i was wondering if there is a way to erase portions of the line. I know i could just write over it with white but was thinking of a better way. maybe by change the alpha or using a mask something like that. Just wanted to know if anyone came across this before or have a theory that can give me some insight to solve this problem..
I have a small flash that I'd like to expand upon, and basically I'm wondering if it's possible to Make a button that lets you erase things on click, rather than clearing the screen.Draw lines of different colours/thicknessHave the Flash output a code for the drawing (similar to Punk-o-Matic 1/2) and be able to put it into the Flash in a text form to have it output the picture. (Thus allowing sharing of pictures).Here's the code.
I'm creating a flash game which uses time intervals with setInterval and sometimes does heavy calculations. The problem is that on slower machines these calculations can't keep up with the framerate and the movie slows down BUT the timers are unaffected what makes them asynchronous to the movie. Looking back, it was a bad idea to use timers but I can't change it back now. So...is there a way to skip drawing frames?
The issue I am having is how to tackle forming a logo using circles. I have done one letter manually, however it would take forever to do this with every single letter, and so I am asking here if anyone knew of a faster method. Requirements:
- Has to fill non-circular letters(i.e. does not have to be precise, but look like it has edges)
- Circles have to animate in, therefore they need to have drop shadow and seem like they are landing in place
Okay, there are a few things I want to know how to draw in one-point perspective: a toilet, a shower, a bath; basically I want to know how to draw everything in a bathroom.
just wondering if anyone has ever had any luck drawing spirals in flash? ive had a stab at it a few times, but it always results in a pretty 'boring' looking spiral... this is the code i've been workin on:
Code: my._x = Math.sin( this.currentTime ) * this.spiralRingSpacing my._y = Math.cos( this.currentTime ) * this.spiralRingSpacing where this.currentTime = an incrementer and this.spiralRingSpacing = a integer
I was hoping to get one that had more control. with a formula I could use to change the 'weight' of the inside and outside of the spiral..
I'm trying to design an application where you can draw lines. This is my code.
Code:
onMouseDown = function (){ original_x = _root._xmouse original_y = _root._ymouse
[Code].....
value_obtained is true when you click the mouse, and is made false when the mouse is released. original_x and original_y are the coordinates for the point of the first click.
How can I make it so that each created line stays on the screen and is not remade?
export a drawing made in flash as a transparent png in actionscript I know you can do it as a jpg with a white background but can you export the transparency?
I created a simple drawing app using Action Script 3.0.My son asked if I could set it up so a drawing could be sent as an email. My website use a dynamic text in order to do that and I annot find any references that would help me out.Right now I am using Sprites and Movie Clips.
the short version of what i need to do - via AS3 and PHP - is a user can come to this project and draw something. drawing's no problem, that's done. my issue is figuring out how to take that drawing data, converting it into something i can save to my database ... then reload said data and recreate it on the stage when the user "loads" it.
i guess i'm just searching for a way to take drawn data (just using typical as3 drawing methods) and breaking it down to a string, then bringing that string back in and recreating it. i'm not super versed in ByteArrays - which i suspect is where my answer lies.
user doesn't need to adjust any of this after it's loaded, fwiw. i'd just like to send this drawing data out - then bring it back in and place it back on the stage.
One thing that seems particularly easy to do in the Flash IDE but difficult to do with code is to outline an organic shape. In the IDE you can just use the inkbucket tool to draw a stroke around something. Using nothing but code it seems much trickier. One method I've seen is to add a glow filter to the shape in question and just mess with the strength. But what if i want to only show the outline?What I'd like to do is to collect all of the points that make up the edge of the shape and then just connect the dots. I've actually gotten so far as to collect all of the points with a quick and dirty edge detection script that I wrote. So now I have a Vector of all the points that makeup my shape. How do I connect them in the proper sequence so it actually looks like the original object?[code]
I have imported a lot of paths from an Adobe Illustrator document right into a flash file. The paths exists as Drawing Objects inside the scene. Using pure actionscript, how can I move a symbol following each of the lines, without using predefined Motion Guides.
EDIT: I've attached the Flash file, full of drawing objects.
http:[url]....
The question is: Are these drawing objects accessible through AS3 or I should convert them to symbols / whatever format necessary.
Am currently working on a tool created by a colleague of mine and would like to improve performance. Basically, it's a tool for drawing on screen and uses a combination of Sprites and the Graphics class to draw a line segment every time the mouse is moved when the mouse button is down. Here is the drawing bit:
// on MouseMove protected function drawLine(e:MouseEvent):void { if (currentTool.thickness > 0){ //pen var line:Sprite = new Sprite(); line.graphics.lineStyle(currentTool.thickness, currentColour); [Code] .....
As you can see, it checks if the line 'thickness' property and draws if it is and erases if it isn't. I did think of using a technique similar to blotting here where it'd draw to a bitmap but I'm not sure this'd give the performance boost I want or if, indeed, there would be any way to have an eraser function. The drawing itself works nicely - this isn't the problem, it's the performance of the subsequent 'drawn' sprites.
I'm making a Flash game, and I've encountered a really weird problem while trying to draw a polygonal shape in Box2D.
Here's the code I use:
var fixtureDefs:Array = new Array(); ... var fDef:b2FixtureDef = new b2FixtureDef(); fDef.density = 0;
[code]....
Where vertexArray is a valid array containing 4 b2Vec2 vertices, making up a convex shape.The problem is, when I test, collisions don't work right for that body. Most other objects -enemies, user-controlled characters - pass straight through, as if the body isn't there at all. Some raycasts pass through as well.
Infuriatingly enough, one kind of bodies I have (a custom enemy) somehow does detect the body and collides with it. The raycasts that particular kind of enemy attempts do work - when your character hides behind the polygon, it's like they can't see him.The other weird thing: when I try the same code, only go for SetAsBox instead of SetAsArray, it works exactly as it should.I'm using a custom ContactListener class, but I haven't done any contact filtering (unless it's possible to do that without realising).I'm using the Flash 9 version of Box2D 2.1a.
I have two options and I want to know whats faster. I have a pool of 1000 sprites objects in as3 on screen. When its needed each sprite has to resize itself. I can 1- Make each sprite a simple container to use graphics to draw a rectangle, that is, call a 'spriteInstance.graphics.' ,draw the rectangle and on each 'refresh', I do graphics.clear and redraw the rectangle but with the new size, this for each sprite. or 2- Create each sprite with a border and on each refresh, resize it Whats better?
Is it possible to draw a sprite, on a movieclip, on a specific layer? I have a MC I created in the Flash designer, and it has 3 layers on it, background, some layout stuff, and then some text. In actionscript i've created a Sprite object in code, drawn a rectangle on it, and added it to the stage with addChild (called from within the MC). The problem is, the sprite is always being drawn above all the layout stuff I added in the designer. Is there any way to add the sprite to the MC at a specific layer? In this case the background layer. I tried changing the z on the sprite and no effect.