All I Want To Do Is Draw Cubic Beziers
I searched around on here but all the posts I found seem to include old code for AS1, or just code that adds to classes which I have no clue how to implement. Flash gives me errors about adding to the classes.
I have found swf examples of a so called midpoint method and it looks like it works very well. But i can't get the code to work.
code
Please someone explain easily how to draw cubic beziers.
Ultrashock Forums > Flash > ActionScript
Posted on: 2005-11-15
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
CS4 - Cubic Beziers (Illustrator Style)
Does anybody know if the drawing methods of AS3 will be updated to use cubic beziers (Illustrator style) rather than current quadratic beziers? If so it will influence my choice to wait for the new CS4 before launching a new project, otherwise I will want to start now. Thanks
Beziers
Here's my implementation of beziers. All that I've done are Linear, Quadratic and Cubic beziers.
I used Point objects for the coordinates but it could be changed to work without them by replacing new Point(xCoord, yCoord) with {x: xCoord, y:yCoord} for usage in flash versions < 8.
See it
Functions:
ActionScript Code:
/* * Citation: * <a href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve" target="_blank">http://en.wikipedia.org/wiki/B%C3%A9zier_curve</a> */import flash.geom.Point;MovieClip.prototype.linearBezierPoint = function(p:Array, t:Number):Point { // Takes 2 Points if (t < 0 || t > 1 || p.length != 2) return null; return new Point( p[0].x+(p[1].x-p[0].x)*t, p[0].y+(p[1].y-p[0].y)*t );};MovieClip.prototype.quadraticBezierPoint = function(p:Array, t:Number):Point { // Takes 3 Points if (t < 0 || t > 1 || p.length != 3) return null; var ax:Number, bx:Number; bx = 2*(p[1].x-p[0].x); ax = p[2].x - p[0].x - bx; var ay:Number, by:Number; by = 2*(p[1].y - p[0].y); ay = p[2].y - p[0].y - by; var t2:Number = t*t; return new Point( ax*t2 + bx*t + p[0].x, ay*t2 + by*t + p[0].y );};MovieClip.prototype.cubicBezierPoint = function(p:Array, t:Number):Point { // Takes 4 Points if (t < 0 || t > 1 || p.length != 4) return null; var ax:Number, bx:Number, cx:Number; cx = 3*(p[1].x - p[0].x); bx = 3*(p[2].x - p[1].x) - cx; ax = p[3].x - p[0].x - bx - cx; var ay:Number, by:Number, cy:Number; cy = 3*(p[1].y - p[0].y); by = 3*(p[2].y - p[1].y) - cy; ay = p[3].y - p[0].y - by - cy; var t2:Number = t*t; var t3:Number = t*t2; return new Point( ax*t3 + bx*t2 + cx*t + p[0].x, ay*t3 + by*t2 + cy*t + p[0].y );}MovieClip.prototype.bezier = function (p:Array, segments:Number) { if (segments < 1) return; var func:Function; if (p.length < 2) { return; } else if (p.length == 2) { func = this.linearBezierPoint; } else if (p.length == 3) { func = this.quadraticBezierPoint; } else if (p.length == 4) { func = this.cubicBezierPoint; } else { return; } var dt:Number = 1/segments; var s:Point = func(p, 0); this.moveTo(s.x, s.y); for (var i:Number=1; i<=segments; i++) { s = func(p, i*dt); this.lineTo(s.x, s.y); }}
Usage:
ActionScript Code:
_root.lineStyle(3, 0x0000FF);// Linear_root.bezier([ new Point(100, 100), new Point(100, 200) ], 10);// Quadratic_root.bezier([ new Point(200, 100), new Point(200, 200), new Point(300, 200) ], 20);// Cubic_root.bezier([ new Point(400, 100), new Point(400, 200), new Point(500, 200), new Point(500, 300) ], 20);
Beziers To Paths With Inertia
Hi all,
I wonder if anyone has any ideas about how to move a mc along a chosen bezier curve, but to add inertia to it also?
Basically i've got a bezier curve you adjust and choose the path (curve) a ball will take. For now I just animate the ball along the original bezier points, but this provides rigid motion, i need it to ease out, but still follow this bezier!
It's quite complex to explain the code, you can get the files at which will explain it better:
http://www.paperscreen.co.uk/shared/alpha.fla
http://www.paperscreen.co.uk/shared/alpha.swf
Just roll mouse over ball to adjust bezier, then click once to kick the ball (it's a football game!) You'll see what i want to happen, the ball just needs to ease-out to look more realistic!
Cheers
Sam
Cubic QTVR
Does anyone know if cubic QTVR panoramics will work in Flash Pro 2004?
Does anyone know of a program that will convert these files? Thanks
QT Cubic VR In Flash? Help
How can I get a Quicktime cubic VR to play in Flash? I have tried imported (as linked file) the .mov file, but it does not appear at playback.
I am using FLash MX.
Maybe the new version handles this.
-or-
The cubic VR format uses 6 images stitched together to allow for full 360deg viewing. I have a client that wrote a java app .exe that does this on the fly from six images in a folder. It views them stiched but never pysically creates a new panorama file.
Is there any way to have flash perform bitmap operations and sitch the images at runtime?
RR
Cubic VR Into Flash?
Any of you know if there's any possibility of simulate a cubic VR within Flash using only actionscript?
Or integrate/embedding it within Flash in order to Flash movie control it?
Thank u all
Cubic Bezier Class
Hi!
I was investigating bezier curves, and found this paper: http://timotheegroleau.com/Flash/art...r_in_flash.htm. It has a library for working with bezier curves (four different approaches for approximating a cubic bezier), but it's done for AS 1.
So I took the preferred one, and placed it in a class. It works great, and I've found it to be really useful. Plus, practically all the calculations are made with some of the Point Class Methods, so it should be faster than the AS 1 version.
Of course, the credit it's not for me, but for the author of the class, Timothée Groleau.
hope you find it useful.
byess!
Ramiro
Cubic Bezier Curves
Here you go...
Its all fully commented and documented.
What it can do? Draw a cubic bezier curve with AS (the one with two controll points).
It has several parameters, that is, array of points, number of sergments and line properties as thickness, etc.
I tried to optimize it as much as possible... one line can take from one to two milliseconds.
AS file link
Example link
and also a link to the Benchmark class used in the example
Drawing Using Catmull And Rom Cubic Spline
This came up on other forum. I was just dorking around this article.
ActionScript Code:
var px = [], py = [];function spline (t, p) { // this maps t = 0..1 to P1..P2 var P0 = p[p.length -4], P1 = p[p.length -3], P2 = p[p.length -2], P3 = p[p.length -1]; return 0.5 * ((2 * P1) + (-P0 + P2) * t + (2*P0 - 5*P1 + 4*P2 - P3) * t * t + (-P0 + 3*P1 - 3*P2 + P3) * t * t * t);}function onMouseUp () { do { px.push (_xmouse); py.push (_ymouse); } while (px.length < 4); var x0 = px[px.length -2], y0 = py[py.length -2], x1 = px[px.length -1], y1 = py[py.length -1]; // polyline _root.lineStyle(1, 0xFF0000, 100); _root.moveTo(x0, y0); _root.lineTo(x1, y1); // employ spline x0 = px[px.length -3]; y0 = py[py.length -3]; x1 = spline (1, px); y1 = spline (1, py); var n = Math.round(2 + Math.sqrt((x0 - x1)*(x0 - x1) + (y0 - y1)*(y0 - y1)) / 5); _root.lineStyle(1, 0x0000FF, 100); _root.moveTo(x0, y0); for (var i=1; i<=n; i++) { x1 = spline (i/n, px); y1 = spline (i/n, py); _root.lineTo(x1, y1); }}
Moving Cubic Bezier Curves
Hi there - i am drawing cubic bezier curves, but want to keep them animating (ie, oscillating up & down).
I am currently using this prototype, however this draws them out sequentially, static. Does anyone know how to amend this, so that they will always change slightly? Thanks
Code:
Object.prototype.drawBezier_bg = function(De, Ma, Mb, Fi, line, colour ) {
this.clear();
this.lineStyle(line, colour);
this.moveTo(De.x, De.y);
this.t = 0;
var ID = setInterval(function (C) {
var u = (1 - C.t);
var uc = u * u;
var tc = C.t * C.t;
var t1 = u * uc;
var t2 = 3 * C.t * uc;
var t3 = 3 * u * tc;
var t4 = C.t * tc;
x = t1 * De.x + t2 * Ma.x + t3 * Mb.x + t4 * Fi.x;
y = t1 * De.y + t2 * Ma.y + t3 * Mb.y + t4 * Fi.y;
C.lineTo(x, y);
if (C.t > 1) {
C.t = 0;
clearInterval(ID);
}
C.t += .01;
}, 5, this);
};
Cubic Bezier Approximated With Quadratics
Last edited by robpenner : 2002-05-20 at 14:20.
Enjoy. :]
Code:
/*
==========================
Cubic Bezier Drawing v0.9
==========================
recursive quadratic approximation
with adjustable tolerance
May 20, 2002
Robert Penner
www.robertpenner.com
MovieClip.drawBezier()
MovieClip.drawBezierPts()
MovieClip.curveToCubic()
MovieClip.curveToCubicPts()
*/
Math.intersect2Lines = function (p1, p2, p3, p4) {
var x1 = p1.x; var y1 = p1.y;
var x4 = p4.x; var y4 = p4.y;
var dx1 = p2.x - x1;
var dx2 = p3.x - x4;
if (!(dx1 || dx2)) return NaN;
var m1 = (p2.y - y1) / dx1;
var m2 = (p3.y - y4) / dx2;
if (!dx1) {
// infinity
return { x:x1,
y:m2 * (x1 - x4) + y4 };
} else if (!dx2) {
// infinity
return { x:x4,
y:m1 * (x4 - x1) + y1 };
}
var xInt = (-m2 * x4 + y4 + m1 * x1 - y1) / (m1 - m2);
var yInt = m1 * (xInt - x1) + y1;
return { x:xInt, y:yInt };
};
Math.midLine = function (a, b) {
return { x:(a.x + b.x)/2, y:(a.y + b.y)/2 };
};
Math.bezierSplit = function (p0, p1, p2, p3) {
var m = Math.midLine;
var p01 = m (p0, p1);
var p12 = m (p1, p2);
var p23 = m (p2, p3);
var p02 = m (p01, p12);
var p13 = m (p12, p23);
var p03 = m (p02, p13);
return {
b0:{a:p0, b:p01, c:p02, d:p03},
b1:{a:p03, b:p13, c:p23, d:p3 }
};
};
var MCP = MovieClip.prototype;
MCP.$cBez = function (a, b, c, d, k) {
// find intersection between bezier arms
var s = Math.intersect2Lines (a, b, c, d);
// find distance between the midpoints
var dx = (a.x + d.x + s.x * 4 - (b.x + c.x) * 3) * .125;
var dy = (a.y + d.y + s.y * 4 - (b.y + c.y) * 3) * .125;
// split curve if the quadratic isn't close enough
if (dx*dx + dy*dy > k) {
var halves = Math.bezierSplit (a, b, c, d);
var b0 = halves.b0; var b1 = halves.b1;
// recursive call to subdivide curve
this.$cBez (a, b0.b, b0.c, b0.d, k);
this.$cBez (b1.a, b1.b, b1.c, d, k);
} else {
// end recursion by drawing quadratic bezier
this.curveTo (s.x, s.y, d.x, d.y);
}
};
MCP.drawBezierPts = function (p1, p2, p3, p4, tolerance) {
if (tolerance == undefined) tolerance = 5;
this.moveTo (p1.x, p1.y);
this.$cBez (p1, p2, p3, p4, tolerance*tolerance);
};
MCP.drawBezier = function (x1, y1, x2, y2, x3, y3, x4, y4, tolerance) {
this.drawBezierPts ({x:x1, y:y1},
{x:x2, y:y2},
{x:x3, y:y3},
{x:x4, y:y4},
tolerance);
};
MCP.curveToCubic = function (x1, y1, x2, y2, x3, y3, tolerance) {
if (tolerance == undefined) tolerance = 5;
this.$cBez (
{x:this._xpen, y:this._ypen},
{x:x1, y:y1},
{x:x2, y:y2},
{x:x3, y:y3},
tolerance*tolerance );
};
MCP.curveToCubicPts = function (p1, p2, p3, tolerance) {
if (tolerance == undefined) tolerance = 5;
this.$cBez (
{x:this._xpen, y:this._ypen},
p1, p2, p3, tolerance*tolerance );
};
////////////////////////////////////////////////////
// override drawing methods to store pen location
MCP.$sysMoveTo = MCP.moveTo;
MCP.moveTo = function (x, y) {
this._xpen = this._xsubpath = x;
this._ypen = this._ysubpath = y;
this.$sysMoveTo (x, y);
};
MCP.$sysLineTo = MCP.lineTo;
MCP.lineTo = function (x, y) {
this._xpen = x;
this._ypen = y;
this.$sysLineTo (x, y);
};
MCP.$sysCurveTo = MCP.curveTo;
MCP.curveTo = function (cx, cy, ax, ay) {
this._xpen = ax;
this._ypen = ay;
this.$sysCurveTo (cx, cy, ax, ay);
};
MCP._xpen = MCP._ypen = MCP._xsubpath = MCP._ysubpath = 0;
// hide custom methods from for..in loops
ASSetPropFlags (MovieClip.prototype, null, 1);
delete MCP;
Please Help Us Make A Free To All - Flash Cubic VR Player
Hi all,
At the moment in time - flash8 CAN make warped Virtual tours using a cubic format.
eg..
http://www.trueview.com.au/Davey/Flash/index.htm
and this is a good one (at the bottom)
http://www.immervision.com/en/multim...logy_flash.php
I was wondering if anyone here would like to help me make a free viewer in this thread?
I can provide all the photography and VR details???!!! and some actionscript - but I need help at the start!
Thanks for this - the VR industry have needed it for years - a free one would be so popular - and of course coders will be credited
Cheers
Byron
Math Gurus Cubic Bezier Curves Intersection, In Actionscript If Possible.
Hello there, let's see if there is somebody who is more intelligent than me here (well... I know there are plenty, but I need somebody with a boat load of available brain cells). I need to find a way to get the intersections of two cubic bezier curves.
I obviously have all the anchors and controls, and I was also able to make a small function to draw them (since flash only support quadratic) but finding the intersection seem to be out of my league. I did lots of research on the web, but all I have been able to understand is that I don't understand .
If somebody has a function or script or whatever, in actionscript if possible, but I'll take anything, please post it .
Thanks!
How To Draw Premieter Of MC? (using Draw Api)
Hi im trying to work out the perimeter of my mc visually, so I want to be able to draw the perimeter of the mc. I gathere there is use of getBOunds and the lineTo and moveTo methods, but how to use them to draw the boundary im not sure. Can any one help?
I Can't Draw
I've recently purchased flash 5 and I've pretty much got all of the scripting and what not figured out. But I'm having trouble with !!!!!DRAWING!!!!! it's the stupid mouse I'm not coordinated enough to draw with it. Does anybody out there know any software or hardware compatible with flash that will make it more like REAL drawing? instead of trying to draw with mouse.
Thanks
HELP ME PLEASE I NEED SOMEONE THAT CAN DRAW
can someone help me i need someone to draw me two street or modified cars that is all i need please someone help me ill make them a banner or something thanx
e-mail-- LPLinkinPrk@aol.com
Aim- LPLinkinPrk
Draw
I have a simple line drawing tool.
Click, it places a root, and a line follows the mouse until the mouse is clicked again at the end point.
After the line has been placed and created:
How can I make it so that the user can click on the line, (so I can allow color change, width change, etc.)
any ideas would be wonderful! thanks
Can't Draw
hello, this is my first time on the forum and somehow I closed the menu bar that allows me to change the color, writing tool, and access of the lasso.Now I can't draw at all, and I was wondering if anybody can tell me how to bring it back up.
-thanks in advance
Mc Draw
I'm a newbie to this. I really need some help. I'm trying to use mc Draw to make a rectangle. I want it to scale depending on what the user enters in the width and length text box. When they hit enter it draws the rectangle.
Can anyone help? the more I work on this the more confused I get....
Thanks in advance.
Draw A Arc
Hi,
i have a knob/dail which you can turn by draging a handle. i can get the degrees and the percentage from the dail, as i have a listener setup to monitor its position.
so...
heres what i want to do; using the the degrees var i want to be able to draw out a circle (or rather outline my dial) so if for example the dial is dragged to 180 degrees the arch reaches to 180 degrees.
does this make sense?
cheers,
Gareth
[CS3, AS2] Draw()
Can someone help me out with this please?
I have a graphic symbol which is on first frame of "framefile.swf".
And, I have the below code on the first frame of my "main.swf"
Code:
stop();
import flash.display.BitmapData;
var newclip = this.createEmptyMovieClip("newclip", 1);
var empt = this.createEmptyMovieClip("empt", 2);
function bmpFunction() {
var bmpdata = new BitmapData(empt._width, empt._height, true, 0x00000000);
bmpdata.draw(empt.frame_tin);
newclip.attachBitmap(bmpdata,newclip.getNextHighestDepth());
newclip._x=500
}
var xxx = new MovieClipLoader();
var ddd = new Object();
xxx.addListener(ddd);
ddd.onLoadInit = function() {
bmpFunction();
};
xxx.loadClip("framefile.swf",empt);
Below is the screenshot of what i get in "main.swf" when its compiled. The image graphic on the left is the graphic which is there on the first frame of "framefile.swf" which appears fine as per the above code. But its the image that you see on the right that has a problem. Its not getting displayed fully. I am just trying to draw the same image again using bitmapdata.
[CS3] Draw()
Can someone help me out with this please?
I have a graphic symbol which is on first frame of "framefile.swf".
And, I have the below code on the first frame of my "main.swf"
Code:
stop();
import flash.display.BitmapData;
var newclip = this.createEmptyMovieClip("newclip", 1);
var empt = this.createEmptyMovieClip("empt", 2);
function bmpFunction() {
var bmpdata = new BitmapData(empt._width, empt._height, true, 0x00000000);
bmpdata.draw(empt.frame_tin);
newclip.attachBitmap(bmpdata,newclip.getNextHighestDepth());
newclip._x=500
}
var xxx = new MovieClipLoader();
var ddd = new Object();
xxx.addListener(ddd);
ddd.onLoadInit = function() {
bmpFunction();
};
xxx.loadClip("framefile.swf",empt);
Below is the screenshot of what i get in "main.swf" when its compiled. The image graphic on the left is the graphic which is there on the first frame of "framefile.swf" which appears fine as per the above code. But its the image that you see on the right that has a problem. Its not getting displayed fully. I am just trying to draw the same image again using bitmapdata.
Draw On A SWF
Hey guys
i am trying to make a SWF file so that one can select a pen tool and start drawing on the swf file. Does anybody have an idea how can i do that I dont mind scripting anuthing if that can make it work. Any input is appreciated.
thanks all.
How To Draw On JPG
Hello
I am totally new to flash actionscript. I have an image in jpg and it has some shapes ,say a ball. I want the user to be able to draw the ball over it. How can I do this in actionscript. I when I have selected a closed contour I want to tell an application running on another computer, probably on webserver that I have selected a particular shape like in this example a ball.
Is this possible in actionscript.
Thanks
Draw Itself
HELP>>>>>>>>>>>>>>
Does anyone know how make it seem like a shape is drawing itself?
What I really mean is that the effect that makes shapes look like it is filling out the outlines of its shape.
Thank you.
Draw Box
Hello. I have a flash file that draws a box when the user clicks down on the mouse, adjusting the box to any size they need. Here is the code:
Code:
box._visible = false;
box.onMouseDown = function() {
this._x = _root._xmouse;
this._y = _root._ymouse;
this._xscale = this._yscale=0;
this._visible = true;
this.onMouseMove = function() {
this._xscale = _root._xmouse-this._x;
this._yscale = _root._ymouse-this._y;
updateAfterEvent();
};
};
box.onMouseUp = function() {
delete this.onMouseMove;
this._visible = true;
};
This works fine, but I need the user to be able to create multiple boxes. Right now, after drawing a box, then clicking again it erases the existing box. I also need these boxes that are created to attach themselves to a movie clip. I've tried the attachMovie script, but cannot seem to get it to work the way I need it to. Any ideas?
Draw Itself
HELP>>>>>>>>>>>>>>
Does anyone know how make it seem like a shape is drawing itself?
What I really mean is that the effect that makes shapes look like it is filling out the outlines of its shape.
Thank you.
How To Draw A Line
Hi !
I would like some pointers as to how to go about drawing a line. Here's what I want to happen :
I would like the user to click and drag from a point A and a line should begin and end at the point B where the user releases the mouse button.
Any help is highly appreciated.
Thanks in advance
Vinod Sharma
Using Actionscript To Draw
can someone please post some links re: drawing with actionscript using variables and duplicating movie clips....
most of the cool sites (you know who you are!) use this mode of drawing and i would love to find a good tutorial...
thx in advance
Help: Draw & Fill Using AS
Hi all. I'm tring to figure out how to dynamically draw simple shape, such as a square, with actionscripts then fill them. Idealy I would like to beable to set coordinates for the 4 corners so that I could move a corner to morph the shape using code. I dont need dragability, just need to be able to change and fill the shape using AS.
Can anyone point me in the right direction on how to do this in F5 / MX?
Thanks
Draw Instance Name From Within Mc
I am using this code on a checkbox component to draw the instance name of the component back so I can put it to use. But it will only work on components that are placed directly on the stage, it wont pull the instance name from any component in a MC. Any suggestions? Thanks for any help.
Here is the code:
Code:
function noteBtn(component){
trace (component);
}
CreateEmptyMovieClip And Draw
Hi, I am trying to draw a square with 50% transparency with no lines.
I can draw a square and fill it, but I can't get rid of the lines, can anyone help?
m@)
Draw Speed
Is there away to detect how fast the users pc can draw an image/vector or what ever in flash.
The idea being if the computer is slow I can have some features turned off automatically - _quality = "LOW" for exmaple. and vica verca for better computers.
I tring to make a site that will look good on a lot more computers.
cheers
Draw Line
How do you draw lines between different mcs with actionscript
I am using flash 5 but I would be interested in the Mx way as well.
How To Draw An Oval...
How to draw an oval by AS? Not by attaching movieClips directly from library, I tried curveTo but it seems like it doesn't work quite well.
Draw Functions
I've been working on a program which will need to have the user draw on the screen, so I've been working with MX draw functions. I'm having difficulty figuring out what the equation they use for the curve is. I've gathered that you give the end points, and that the anchor point determines the direction of the curve, but what exactly would the equation be, given these three points?
Also, I've noticed that when you are actually drawing with flash, it seems to work differently. When you draw a line, each vertice of the line seems to have a seperate anchor point. What is the equation they use for this, and how does it relate to the one used for the curveTo function?
Thanks for your time, any other details about the draw functions would also be appreciated.
Help Me Draw And Animate
pls help me i cant do ether i whant to learn tho but i whould like some one to personly learn me if they could here is my msm
topbrickforever2003@hotmail.com
Bug With Draw Commands?
I'm not sure if this is my video card driver or not.
So I could appreciate someone taking a look at this.
Just test the movie and see if the draw commands I'm using
creates the same bug I'm getting here.
The fla is a set of class routines for useing the movie clip
drawing commands. Seems when you use multiple beginFill()
and endFill() commands on the same clip odd things start to happen.
Thanks,
Chris
Draw Restrictions?
how do I make draw restrictions, so I cannot draw on the tool bars or other things, exept one display. Check the attachment so you understand better.
-=Thanx=-
Need Someone To Draw For My Shoot Em Up
I need somebody quite good at drawing cartoon style stuff to draw characters/weapons/items/backgrounds for the shooter I plan to make. I know all the actionscript needed to make the game, but I suck at drawing, and I don't want to start without the graphics. If anyone is interested, please email me at tom@wombatman.co.uk
Thanks,
Draw Circle
Hy guys,
I'm still working on my paint-like program and its going pretty wel. Except when it comes to drawing cirkels. Flash came up with the most difficult way ever to draw a circle! What ever happened to just giving the coordinates of the bounding box of the oval? Or center point and radius for a perfect circle?
I've been working on this for three days now. With no result. I know there's a lot about it on the internet but I just can get it to work. Mostly because of the math.
I hate to ask but I've got no choice. Anyone up to creating this peace of code?
Here's what supposed to happen:
The user clicks on the button for drawing circles (I only need perfect circles so that should make it easier)
When he clicks on the stage, a circle should appear with the mouse position where the user clicked as center point and with the radius equal to the distance between the created center point and the current mouse position (I'm afraid this will need the Math.atan() and the Math.acos() functions). While the user drags, the circel should change size according to the mouse position. As the user releases the mousebutton, the current circle is drawn.
To give you a better idea, here's the code I used for drawing a squaire in the exact same way.
if (_global.action == 3) { // tells that user wants to draw a squaire
_root.xbegin = _root.xpos; //xpos & ypos contain the current mouse position. They are updated on every mousemove event
_root.ybegin = _root.ypos; //xbegin & ybegin are the coordinates where the user cliked (onMouseDown)
_root.draw = "rectangle";
onMouseMove = function () { //each time mouse moves, a new squaire is created
_root.createEmptyMovieClip(["clip"+i],i); //everytime user clicks : i++ to create overlapping MC's
_root["clip"+i].lineStyle(1,0xff0000,100);
GetPos.call(); //To get x & y position of the mouse --> then stored in xpos & ypos
_root["clip"+i].beginFill (0x0000ff)
_root["clip"+i].moveTo(_root.xbegin+11, _root.ybegin+10);
_root["clip"+i].lineTo(_root.xbegin+11, _root.ypos+10);
_root["clip"+i].lineTo(_root.xpos+11, _root.ypos+10);
_root["clip"+i].lineTo(_root.xpos+11, _root.ybegin+10);
_root["clip"+i].lineTo(_root.xbegin+11, _root.ybegin+10);
};
onMouseUp=function(){
if (_global.action == 3) {
loadVariablesNum("submitDisplay.cgi",0,"POST"); //send the data
onMouseMove=null; //stop drawing squaires
onMouseMove = function() {
GetPos.call(); //to restart mousetracking
};
}
}
Draw On Image...
Hey,
In need of a solution. I am unbale to get my spray can (mc) to draw on an image (a wall mc). my code so far looks like this...
on the frame:
_root.wall.createEmptyMovieClip("line",1);
_root.wall.line.lineStyle(2, 0x000000, 100);
stop(
on my sray can:
on (press)
{
startDrag(can);
_root.wall.line.moveTo(_x, _y);
_root.onMouseMove = function()
{
_root.wall.line.lineTo(_x, _y);
};
}
on (release)
{
stopDrag();
_root.onMouseMove = null;
}
Can I eventually get my spray can to draw on the wall?
thx for any help.
How To Draw Grass
Does anyone know where I can download a flash file with grass in it or anywhere there is a tutorial to draw grass? I am kind of new with flash and the drawing of it with so many blades, etc. seems too drawn out and plus I find the drawing tool hard to use. Thanks for your help.
Getting Flash To Draw By Itself
I am trying to get Flash MX to draw a spider web. I have Flash creating a empty movie clip
and I have looked into the commands moveTo and curveTo. But how do you get it to slowly draw? I am also having difficulty figuring out how to place my lines where I want them. Thank you.
How To Draw Line?
Hi all,
I have a photo, say of a Printer and I draw the Outline of the Printer, with simple Sketches... just Lines.
Now, how would I create an Animation like Someone is "DRAWING" that lines that make up a Printer???
Hope you get that...
Please help me with that... I do not mean a masking effect.. If I want the Individual Lines to be drawn the way they are... how would I do that..
Thanks a lot for any help that you may provide.
Wishy
Draw Effect... How Do I?
Hi I want FLASH to draw a logo, as If I myself was drawing the outside lines of a logo, any suggestion as to how I do this?
Cheers,
Mads
What Tool Do You Use To Draw?
What tools do most of you usually use when drawing in Flash? Whenever I use the paintbrush, my line are a little jagged, not nice and smooth like on good animation sites such as homestarrunner.com.
Just wondering what tool is most used. Paintbrush or pencil? If paintbrush how did homestarrunner get their lines so smooth? And if pencil, do you use smooth or ink?
Or do you draw in Photoshop?!
Thanks a lot!
Using An Animation To Draw...
i'm using flash mx 2004 pro...
i have a pen that i want to write out whatever i tell it too...similar to this ...i'm just taking a different approach to it...
i have an animation of a pen in flash and i would like it to draw a line or make a mark where ever the tip of the pen is... so basically i'm doing something like my_mc.lineTo(pen._x, pen._y) but that's not working...i've created an empty movie clip, set the lineStyle, etc. ...there's just nothing showing up when the animation runs...maybe you can't do it this way, but i would just like to see what others have to say about this...thank you...
|