Very Tricky - Trace The X , Y Value Of All Nodes Of A Curve Line Shape
........
SitePoint > Design Your Site > Flash and Actionscript
Posted on: Sep 4, 2008, 01:59
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Curve In Line
Pls take a look at this file
http://www.dreamance.com/download/ball.swf
Currently, the ball will follow the mouse and will go toward it in a straight line. It there anyway to make the ball move toward the mouse in a curve manner?
Here the code:
Code:
onClipEvent (load) {
speed = 0.05;
}
//
onClipEvent (enterFrame) {
targetX = _root._xmouse;
targetY = _root._ymouse;
//
this._x = this._x+(targetX-this._x)*speed;
this._y = this._y+(targetY-this._y)*speed;
}
The fla if needed.
Thanks!
Chup
Line Curve Help
Hi
How do you make a straight line curve?
just like a sine curve
can anyone show me the code for doing it?
one more question
lets say i create an empty movieclip on frame 1 of the main stage
e.g. _root.MovieClip.createEmptyMovieClip(testmc,1);
then how do I put the code into "testmc"?
where should I put it?
need help,
newbie on flash
=)
TIA
Valse
Drawing A Line Behind A Sin Curve
http://www.geocities.com/ryanhbowman/sin.html
a movie clip travels the path of a sin curve, i want to draw the actual curve behind it as it moves. any ideas? thanks.
ryan
Algorithm For Line Curve
I want to come up with an algorithm, preferably in the form of a function where you provide three points, a starting point, a curve point, and an end point, and the function will calculate a curve that starts at the first point in the direction of a second point, and will curve so that it ends at the third point.
an example would be something similar to the interface at http://www.flight404.com/version7/index.html
Any ideas on where to start? or perhaps you could point me in the right direction?
Cheers,
Stwelin
Fonts - Line To And Curve To
Hi all
If I embed a font into flash is it possible to have their lineto curveto info.They would help to make effects like outline without doing much effort.
I just want a way that flash drawing tool could generate the text (with moviclip.lineTo and curveTo)
Thanks for the reading and Help
Zareh
Drawing A Line Behind A Sin Curve
a movie clip travels the path of a sin curve, i want to draw the actual curve behind it as it moves. any ideas? thanks.
ryan
http://www.geocities.com/ryanhbowman/sin.html
Duplicating Mc Of Line Drawn With Curve To
I am working on this thing where you can draw your own line by dragging around points and curve points using the new curve to methods. I then want to duplicate that movie clip into a pattern. The pattern is actually based off something from uncontrol.com. Creating and manipulating I have set up fine. It's the duplication part that I'm having problems with. I have a button to press when you want the line to be duplicated. the code on it is
on (release){
counter = 1;
speed = 3;
radius = 50;
x_offset = 400;
y_offset = 100;
// --------------------
// creates objects
// --------------------
for (counter=1; counter<=100; counter++) {
_root.duplicateMovieClip(_root.mc, ["mc"+counter], counter+15);
_root["mc"+counter]._x = x_offset;
_root["mc"+counter]._y = y_offset;
_root["mc"+counter]._yscale = 100;
_root["mc"+counter]._xscale = Math.sin(counter/Math.PI/speed)*radius;
_root["mc"+counter]._alpha = 10;
_root["mc"+counter]._xscale = counter*4;
_root["mc"+counter]._yscale = counter*4;
}
speed = 50;
x = 1;
}
mc is the name of the line created by the curve to. Here is the code:
_root.attachMovie("squareHandle", "h1", 5);
_root.attachMovie("squareHandle", "h2", 6);
_root.attachMovie("squareHandle", "h3", 8);
_root.attachMovie("squareHandle", "h4", 9);
_root.attachMovie("squareHandle", "h5", 10);
_root.attachMovie("roundHandle", "ctl", 7);
_root.attachMovie("roundHandle", "ctl2", 11);
_root.attachMovie("roundHandle", "ctl3", 12);
_root.attachMovie("roundHandle", "ctl4", 13);
h1._x = 50;
h1._y = 150;
h2._x = 250;
h2._y = 150;
h3._x = 220;
h3._y = 130;
h4._x = 200;
h4._y = 110;
h5._x = 180;
h5._y = 90;
ctl._x = 150;
ctl._y = 50;
ctl2._x = 140;
ctl2._y = 40;
ctl3._x = 120;
ctl3._y = 30;
ctl4._x = 80;
ctl4._y = 20;
// create a clip to draw to
_root.createEmptyMovieClip("mc", 1);
// this function redraws the curve
function draw() {
// clear out the old curve
mc.clear();
// set our line style for the handle lines
mc.lineStyle(0, 0xCCCCFF);
// draw lines based on control handle location
mc.moveTo(h1._x, h1._y);
mc.lineTo(ctl._x, ctl._y);
mc.lineTo(h2._x, h2._y);
// set the line style for the curve
mc.lineStyle(1, 0x000000);
// draw the curve based on handle locations
mc.curveTo(ctl._x, ctl._y, h1._x, h1._y);
mc.lineStyle(0, 0xCCCCFF);
// draw lines based on control handle location
mc.moveTo(h2._x, h2._y);
mc.lineTo(ctl2._x, ctl2._y);
mc.lineTo(h3._x, h3._y);
// set the line style for the curve
mc.lineStyle(1, 0x000000);
// draw the curve based on handle locations
mc.curveTo(ctl2._x, ctl2._y, h2._x, h2._y);
mc.lineStyle(0, 0xCCCCFF);
// draw lines based on control handle location
mc.moveTo(h3._x, h3._y);
mc.lineTo(ctl3._x, ctl3._y);
mc.lineTo(h4._x, h4._y);
// set the line style for the curve
mc.lineStyle(1, 0x000000);
// draw the curve based on handle locations
mc.curveTo(ctl3._x, ctl3._y, h3._x, h3._y);
mc.lineStyle(0, 0xCCCCFF);
// draw lines based on control handle location
mc.moveTo(h4._x, h4._y);
mc.lineTo(ctl4._x, ctl4._y);
mc.lineTo(h5._x, h5._y);
// set the line style for the curve
mc.lineStyle(1, 0x000000);
// draw the curve based on handle locations
mc.curveTo(ctl4._x, ctl4._y, h4._x, h4._y);
}
// call draw every 25 milliseconds
setInterval(draw, 25);
Curve A Line To Reach Desired Distance From Its Base?
I have a line, with its base at a specified point. It rotates to always point at the mouseCursor.
Also, when the distance of the cursor compared to the line-base is smaller than the line-length I want the line to curve so that its tip is on the cursor.
I have almost gotten this to work..
When the curveValue of the line is 1, it is fully curved meaning it goes around 360 degrees, and when its at 0 it's perfectly straight.
So I have tried setting the curve like this:
ActionScript Code:
curveValue=(1-mouseDistance/lineLength);
if (curve<0)
curve=0;
This almost does the trick but not quite. It only touches the cursor when the the distance is zero or equal to the lineLength.
You can see the result here.
And as you can see I'm not using curveTo, I'm using lineTo's with a set amount of segments. I set it to 5 so you can see what I mean.
If anyone can tell me how to set the curveValue so that the tip always is at the cursor when distance is smaller than lineLength it would be greatly appreciated.
Thanks in advance =)
How Can I Fill In The Area Below And Above A Sine Wave Curve/line?
I'm trying to create a "Scorched Earth" (eg. Tanks) clone and I'm having trouble creating a nice random 2D landscape (eg. hills, slopes, valleys, etc).
Right now I just combine a couple of sine waves and draw them using movieClip.lineTo(x, y) so what I end up with is a movie clip containing a TON of lines (each x,y value is connected to another x,y using the lineTo function)
So, after I have my nice curve/lines, how do I fill in the area below it with a solid color (eg. green representing grass).
Also, is there a better way to drawing a 2D landscape? I'm wondering if creating 600 lines on a movieClip is bad... (using all those lines make the full line look like a curve...)
You can checkout exactly what I'm talking about right here:
http://www.lagworld.net/canon.swf
Finally, if anybody knows why my movie runs so slow please let me know =) (its running at 60fps in case that has anything to do with it)
Trace A Line
Hi,
I need to make a presentation with maps and trace lines in maps over the roads. I would like to tracing these lines at the start to the end with animation. Any idea?
Thanks in advance,
Amadeu Carlos Penzin
Trace A Line
Hi,
I need to make a presentation with maps and trace lines in maps over
the roads. I would like to tracing these lines at the start to the end
with animation. Imagine a randomized line traced with the "pencil tool"
on the stage. I want that this line will be traced since the beginning
until its end along the movie, better, in the beginning the stage is
empty, later this line will be appearing frame by frame. I know to make
this with a straight line but with a randomized line I still didn't
get. Dividing the line and making it frame by frame is very laborious.
Through this method I know to make this. The problem is that I have to
make a lot of routes over the map and this background map must be
visible during the movie. I think that it does not allow to use the mask. The manual procedure becomes unproductive for hundreds of lines. I already
have being instructed and guided in many interactive training tutorials of flash, action script etc. and I saw a lot of examples and nothing...Any idea to make this automatically with the action script?
Sorry for my english!!!
Many THX,
Amadeu Carlos Penzin
Trace Out Line Breaks?
I am playing around with text fields, and I am not finding a way to trace out line breaks in text fields. Anyone know how to do this?
Trace Line Number
Hi, I am expanding Flash's Array Class adding a lot more methods to make arrays more powerful inside of Flash. I want to be able to trace out errors when people use the methods incorrectly, but I was wondering if there is a way to get the code line number? So I could trace something like this..
Warning: ** Value sent in holds() is not supported. Type "undefined" was is not suppored in this method. (Line: 239) **
If there is a function I can use to grab the line where the piece of code that contains errors is?
Line To Shape
how to i convert all lines to shapes so the resize normally with all the pther shapes?
-thanks
How Do I Add A Line Around A Shape?
I'm trying to draw a 'pipe' so I've drawn a thick line, then converted it to a shape. Now I need to add line to the shape (the perimeter).
How is this possible?
Drawing A Line From One Shape To Another
OOPS perhaps i should have posted this in the flex forum......I'm developing an application in Flex.
So I found out how to create shapes with the Drawing API. I also found out how to draw lines from a point (x1, y1) to a another (x2, y2).
I am going to try to explain this as easily as i can. I dynamically generate two triangles and add them to a canvas as follows:
var triangleHeight:uint = 100;
var triangle:Shape = new Shape();
// red triangle, starting at point 0, 0
triangle.graphics.beginFill(0xFF0000);
triangle.graphics.moveTo(triangleHeight/2, 0);
triangle.graphics.lineTo(triangleHeight, triangleHeight);
triangle.graphics.lineTo(0, triangleHeight);
triangle.graphics.lineTo(triangleHeight/2, 0);
// green triangle, starting at point 200, 0
triangle.graphics.beginFill(0x00FF00);
triangle.graphics.moveTo(200 + triangleHeight/2, 0);
triangle.graphics.lineTo(200 + triangleHeight, triangleHeight);
triangle.graphics.lineTo(200, triangleHeight);
triangle.graphics.lineTo(200 + triangleHeight/2, 0);
var uiWrapper:UIComponent = new UIComponent();
uiWrapper.addChild(triangle);
myCanvas.addChild(uiWrapper);
So one triagle is red then the one to its right is green. I can certainly connect both triangles by drawing a line between them like this:
triangle.graphics.lineStyle(1, 0xFF0000);
triangle.graphics.moveTo(50, 50);
triangle.graphics.lineTo(230, 50);
each triangle will have "drag and drop" functionality so heres is my question: how can I assign a point in each triangle so that the drawn line will be redrawn each time a triangle is moved? with the line drawing above that line is static. In toher words I need a dynamically drawn line that will adjust to the position of the triangles. Any ideas/tips/resources????? If lets say instead of triangles I used Button components is there a way to assing "connection points" to the buttons as well??? I would much rather use the buttons than the shapes but whatever gets me to the end....
Help!
[CS3 IDE] Adding A Line Shape Around A Form
Hi,
This is maybe stupid or obvious, but I have a vector form in the flash IDE that is not surrounded by a line border.
How can you add a line around a form ?
It happned to me from time to time after a bug in the IDE (when changing the x/y coordinates of a form), so I know it's is tchnically possible but I can't manage to make it propertly.
Apply Line To A Non Actionscript Shape?
Hi guys,
Is it possible to apply a line (with actionscript) to a movieclip created without actionscript?
If so, could someone explain how.
I'm kinda guessing that you can't, but I thought I'd ask anyway.
Thanks in advance
Bongo
Animation Of A Line Being Drawn Via Shape Tween
while i know how to reveal lines and other graphic elements through masks, i wonder if there is a way to animate the drawing of a line directly via shape tweening (or some other method i don't know?). the line i want to make is scribbly and overlaps itself many times, which makes the mask method very time comsuming and not so easy to do smoothly. my early attempts show a dot that just exapnds into the final scribbly shape, and shape hints do not seem to be applicable here.
i would greatly appreciate any insight here (even if it is a conformation that i'm barking up the wrong tree).
many thanks,
shawn
Create Shape And Motion Tween Of A Line
I am trying to create a line graph in which the line is following a certain path over time like in a simulation. The line starts with a point in frame 1 and ends with a smooth not straight line in e.g. frame 50. The line has to "run" like in an electrocardiogram.
Is it possible to create this in flash?
If so, how? I tried to combine shape and motion tweening, but that didn't work.
Thanks for your help
Shape Tweening With A Dashed Line Stroke?
I have a simple shape tween set up. The shape has the same dashed line for a stroke on both keyframes, but when the animation is played, the dashed line turns solid during the shape tween.
Why doesn't the stroke style animate?
Adding Nodes And Child Nodes To An Xml Tree
Hello Ed, and every1 else.
Can i first say a big thank you for your effort, you didnt have to and i really appreciate it...im somewhat of a novice and am finding my feet.
I can now attach a comment to a node. Prior to that I have imported my xml file - which contains the tree into flash and can now display the tree structure and all of its nodes. the comment is there so thats great.
Is there any way though that you can update the xml file with the comment that you have submitted.
i.e. after you have attached the comment with a node, is there any way that the comment willl be passed through to that xml file itself?
Im thinking i need an attribute in the xml file called say "comment" and somehow when you press the submit button to attach the comment to a node the xml file (the "comment" attribute within) is also updated with the comment.
Loading Ext Variable - Tricky Tricky...
Loading ext variable - tricky tricky...
I have this external txt file that contain some variable that i wanna include in a swf while it is running. The unique part about the variable in the txt file is that they all share the same variable name, but differen value.
In the swf itself, i will have different(say 5) mc, each containing a dynamic field with the same name.
So my problem is as below:
Is there anyway u can strip the infomation/variable in flash so that all the variable of the same name will be place into different mc? Sound confuse? download this dummy structure file to get wat i mean
http://www.chupcreations.com/forum/test.zip
Thanks in advance!
chup
Trying To Show "drawing" Effect Along Line Of A Shape
I am trying to get a simple shape to "draw".. I found this tutorial
http://actionscript-toolbox.com/shapeDefinedMC.php - that's what I'm going for - just drawing the lines - but this tutorial is over my head!
I created a shape with the Flash pen tool, put it in a MC (shouldn't this then be a 'shape defined MC' at this point?) and tried:
onClipEvent (load) {
this.drawAlong({width:2, color:0x0000aa, alpha:100}, 2, {npts:20, type:'b', fixed:false}, 25);
}
I know I must be missing something... can anybody help?
[flash 8]Adapting 'Auto Trace Mouse' Script To Perfom 'Atuo Trace Object'
Hello everyone..
I am new to flash and I am hoping the good people of this forum will help.
I have this sript for auto tracing a mouse position (got from this site) but i would like intead of trcing the mouse...to get it to trace a random moving object from another script!
mouse script:
createEmptyMovieClip("Line",1);
Line.lineStyle(1,0x000000,100);
onMouseDown = function ()
{
Line.moveTo(_xmouse, _ymouse);
onMouseMove = function ()
{ Line.lineTo(_xmouse, _ymouse);}
}
onMouseUp=function()
{
onMouseMove=null;
}
Random moving object:
loops = 0;
_root.target_x = Math.random()*450;
_root.target_y = Math.random()*300;
_root.xdiv = (_root.target_x-_root.circle._x)/20;
_root.ydiv = (_root.target_y-_root.circle._y)/20;
loops++;
_root.circle._x += _root.xdiv;
_root.circle._y += _root.ydiv;
loops++;
_root.circle._x += _root.xdiv;
_root.circle._y += _root.ydiv;
if (loops<20) {
gotoAndPlay(2);
} else {
gotoAndPlay(1);
}
I guess there is a way I can do this or it can be done...? Help will be much appreciated.
Thankz
Is There A Way To Perfectly Compare Overlapping MC's Shape On Shape?
Is there some sord of hitTest tweak or script/code that can tell whether the two movie clips are overlapping each other SHAPE on SHAPE and not bounding box on bounding box? I have experimented that whenever I use the hitTest code like this.hitTest(anotherMovieClip) it does not work as I hoped.
Don't get what I mean? Well...
Is is possible to compare 2 objects shape against shape by doing a hit-test from object A to compare it against the shape of object B and then another hit-test to compare object B against the shape of object A and if both give true then the shapes are overlapping each other?
Shape Hint Makes Shape Dissapear
Sometimes (not always) when I add shape hints to shapes to help shape tweening, the tweened images inbetween two shapes dissapear leaving nothing except for the first image on the first frame and the last image on the last frame that i'm trying to shape tween.
This only happens if i'm using shape hints, and if I take them away, it tweens normally.
How can I fix this and still use the shape hints?
Is It Possible To Get The Dimensions Of An Oblong Shape? Or Can I Replace The Shape?
I am using the loader to load an swf. The swf has movieclips inside that I register to my class using this.clip1 = loadedMov.getChildByName("clip1");
Say clip1 contains only a solid colored, oblong shape. I want to be able to change clip1's color to a gradient fill and retain the oblong shape. What is the best approach to do this? The shape would be a little difficult to draw dynamically. It also would not be practical to redraw it for every possible gradient at design time for my situation.
Seems to me I should be able to replace the shape's color with a gradient like a ColorTransform does for solid colors, or get the vectors of the shape and redraw it with beginGradientFill. Really need help on this one.
Tags: Actionscript 3.0
Drawing Custom Shape, And Filling Shape
Hello Forum members,
I have not yet figured out how to fill a shape (not an oval or a rectangle) that I draw.
for example, I draw a triangle with the pen tool (or the pencil tool). I have a nice triangle now.
Three lines, etc.
How can I fill this new "shape" with a color? Witout using the brush or the pencil and drawing color in.
Thanks,
eholz1
Shape To Text Shape Tween Not Responding
I wanted to know if anyone has encountered this problem or can see that I'm doing something wrong. It really doesn't look too complex and I've also done it before with no issue. I'm only running 2gb of ram, but I've done this plenty of times with no latency and for some reason recently it just won't work. I'm using CS3 Pro, AS 3
Set up:
Draw a square in frame one
create a blank keyframe on say, frame 30
write some text on frame 30
shape tween the square into the text
Results:
If I tween the square to a single character-no problem
If I tween the square to a sentence slow tween on preview and publishing
If I tween 3 paragraphs it will bomb out and go into...not responding and I have to shut down the program
Any thoughts?
Advanced Hittest . Shape/shape Not Rectangle?
Does anybody know a solution
for testing the collision of two shapes
where only the visible shapes
not their border rectangle count.
the point/mc collision is not enough. i need to check the shapes of both mcs.
Shape Tweening, Shape Hints...
I can't seem to be able to make shape hints affect the morphing of a box...the hint remains red color wherever i place it both in the starting frame and the end frame of the tween. Also, i also cannot set the initial width of the box to be tweened as 1px...if i do that the tween breaks down. But frustrating, i was able to set it a 1 px width the very first time i tried.
Set Shape Id , Or How To Accesse Shape After Creating It
Hello all
im newbie in AC3 programming , so bare with me
i created shape with simple function ( using flex compiler )
but after i created the shape i like to access it for example to change the
color of it , but i cant see in the AC3 ref any indication to Shape id or name propriety.
what im missing here ?
Thanks
From Drawing API Shape To Shape Tween
I would like to take the shape I created with drawing api and shape tween it into a square via a tween. How is this done?
I have searched, but cannot find a howto for this.
Thanks!
Shape Tween A Shape Into Text?
How do you do this. I want, for example. to make a simple square shape tween into the name, "Bryan". I fiddle with this, but it doesn't want to do it.
What needs to be done to get this to work.
Thanks
Bryan
Api Curve
Hi all,
I'm new here and I have a question
I've made a curve with API that follows the ball.
The coordinates of the end of the curve are the coordinates of the ball. When I use the drag function the line updates perfectly but when I move the ball with the keyDown It really bugs. I think it doesn't updates when I use the Key.isDown.
Does anybody knows how to fix this. Or is there an otherway to achieve this effect.
With this is the fla. file. With the arrow keys you can move the ball and you can also move the ball. You will see there is a difference in updating the curve. I want that the line reacts the same way when I use the arrow keys as it does with the drag.
hopefully somebody can help because this is for a schoolproject.
Thanks in advance
3D Curve
Does anyone know how to get a ball flying in a curve with a z-coordinate, as it's done in the following: http://www.chunk.co.uk/snowball/
thanks
Curve To
Hi,
I've looked on here for a straight forward example of this but cannot find it.
I need some code that will move a point in a curve to a destination x,y position.
Also some time ago, I saw some trig code using sin and cos I think where you could place a cross hair at a destination and the ball mc would move in a nice "wobblly" curve right up to the point, how did they do that?
thanks for any advice
boombanguk
|