Drawing Api... AttachMovie Along A Lineto?
Is it possible to get the values along a lineTo and have movieclips attach along the path?
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 09-14-2008, 02:10 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
For Loop And Lineto Drawing
this is where my problem lies i think...
when not running the for loop everything is ok
when i use the for loop, flash hangs up
is it becuase of the endfill()?, maybe for loop cant be there?
and does for loop run atleast once?
// previously calculate co-ords, no prob here
_root.beginFill (colour, 100);
_root.moveTo (p0x,p0y);
_root.lineTo (p1x,p1y);
_root.lineTo (p2x,p2y);
for(i=3;i<points_length;i++)
{
// calculate 2d screen points
pt = cam.transform_point (point[i], D);
persp_ratio = D / (pt.z + D);
px = xctr + pt.x * persp_ratio;
py = yctr - pt.y * persp_ratio;
_root.lineTo (px,py);
}
_root.endFill ();
Scaling The Drawing Lineto
Hi,
I have a whole bunch of values in an array that I want to plot on a graph using the lineTo.
The values in the array are very large and the stage is not big enough for them.
Could anyone suggest a way to scale the values to the size of the stage?
ActionScript Code:
for (var p:int=0; p<l_pcm.length; p++) {
var plot=l_pcm[p]/1000;
graph.graphics.lineTo(p,l_pcm[p]);
}
addChild(graph);
EDIT
Please use [ as ] [ /as] tags for code (without spaces)
Thanks,
dub
Drawing A Border With LineTo
Hi,
I am trying to draw a border around a dynamically generated movieclip using lineTo, and am running into a problem with an incorrect width value, which is messing up the border. The strange thing is that my variables start_x and delta_x trace fine (<500) individually, but then when added together get some odd number (>10000)
Code :
PHP Code:
_root.createEmptyMovieClip("main",_root.getNextHighestDepth());
main.createEmptyMovieClip("graph_lines",_root.getNextHighestDepth());
var x_pts:Array = new Array("110","120","130","140","150","160","170","180","190","200","210","220","230","240","250","260","270","280","290","300","310","320","330","340","350","360","370","380","390","400","410","420","430","440","450","460","470","480","490");
var y_pts:Array = new Array("342.4","332.4","332.4","342.4","352.4","342.4","352.4","342.4","332.4","342.4","352.4","362.4","362.4","352.4","342.4","352.4","352.4","342.4","332.4","322.4","312.4","322.4","322.4","312.4","322.4","312.4","322.4","332.4","322.4","312.4","322.4","312.4","322.4","332.4","332.4","322.4","312.4","302.4","292.4");
max = function (array) {
var mxm = array[0];
for (i=0; i<array.length; i++) {
if (array[i]>mxm) {mxm = array[i]};
};
return mxm;
};
min = function (array) {
var mn = array[0];
for (i=0; i<array.length; i++) {
if (array[i]<mn) {mn = array[i]};
}
return mn;
};
box2 = function (a_movieclip){
trace ("running_box2");
var border = 10;
var scale = 100;
var start_x = a_movieclip._x;
var start_y = a_movieclip._y;
var min_x = min(x_pts);
var min_y = min(y_pts);
trace ("my min_x : " +min_x);
trace ("my min_y : " +min_y);
start_x = min_x;
start_y = min_y;
var delta_x = a_movieclip._width;
var delta_y = a_movieclip._height;
trace ("my d_x : " +delta_x);
trace ("my d_y : " +delta_y);
var max_x = start_x + delta_x + border;
var max_y = start_y + delta_y + border;
trace ("my max_x : " +max_x);
trace ("my max_y : " +max_y);
box2 = main.createEmptyMovieClip("box2",main.getNextHighestDepth());
box2.lineStyle( 1, 0xFF00FF, 100 );
box2.moveTo (start_x, start_y)
box2.lineTo( start_x, max_y );
box2.lineTo( max_x, max_y)
box2.lineTo( max_x, start_y)
box2.lineTo( start_x,start_y);
};
make_graph = function(){
for(i=1;i<x_pts.length;i++){
main.graph_lines.createEmptyMovieClip("line"+i, 100+i);
main.graph_lines["line"+i].lineStyle(2, 0x000000, 100);
main.graph_lines["line"+i].moveTo(x_pts[i-1], y_pts[i-1]);
main.graph_lines["line"+i].lineTo(x_pts[i], y_pts[i]);
};
};
make_graph();
// bounding_box();
box2(main.graph_lines);
- dialectric
Slow Down The Lineto Drawing
Hi All
I have an example of the script I have written bellow which will produce a box on the stage starting a 0,0
My question is, If I wanted to make the lines draw on stage slowly over a spacific time frame so that the end viewer would see the lines being drawn, is there a way of doing it in AS?
ActionScript Code:
_root.createEmptyMovieClip ("box", 1); with (_root.box){lineStyle (5, 0x00000, 100);moveTo (0, 0);lineTo (200,0);lineTo (200, 200);lineTo (0, 200);lineTo (0, 0);}
BaNa
Slow Down The Lineto Drawing
Hi All
I have an example of the script I have written bellow which will produce a box on the stage starting a 0,0
My question is, If I wanted to make the lines draw on stage slowly over a spacific time frame so that the end viewer would see the lines being drawn, is there a way of doing it in AS?
ActionScript Code:
_root.createEmptyMovieClip ("box", 1); with (_root.box){lineStyle (5, 0x00000, 100);moveTo (0, 0);lineTo (200,0);lineTo (200, 200);lineTo (0, 200);lineTo (0, 0);}
BaNa
[F8] Drawing (lineTo, MoveTo, Etc) Withing An Mc?
I have an image generated with lineTo and moveTo calls, but so far I can only get it working if I draw to the root stage; I'd like to be able to draw just within an mc. And I'd rather not have to set arbitrary boundaries mimicking an mc because I have the same mc on multiple frames with different perspectives, so I'd have to change everything for each instance.
LineTo Drawing Copied To A Specified Frame Of Mc?
Heya all,
I'm trying to make a really simple online animator, but have hit a point where I'm wondering what the best approach would be..
EXAMPLE:
User draws first frame of a walking cycle using lineTo, clicks a 'next' button and then draws frame 2 of the walking cycle, and repeats for frame 3. Once finished, the user will click 'finish' button and get a preview of their walking animation.
Has anyone ever made something like this or have some insights as the best way to do this?
Specifically, is there a way to copy a drawn object to a particular frame in an mc? I've thought about a couple ways to do this, but I want it to be super efficient as this may become a somewhat large project.
thanks for your insights.
Ryan
Drawing API: Child LineTo Parent
Here is my code:
ActionScript Code:
//------------ATTACH CLIPS AND SET COLOR-------
var colors:Array = ["0xFF0000", "0xFFCCCC", "0x336699", "0x0000FF", "0xFFFF00", "0x000000"];
var Q:Number = 0;
for (var i = 0; i<colors.length/2; i++) {
_mc = container_mc.attachMovie("ball", "ball"+i+"_mc", i);
//_mc._x = Q;
Q += _mc._width;
var myColor:Color = new Color(_mc);
myColor.setRGB(colors[i]);
}
//--------------END ATTACH CLIPS------
//
//-----------GIVE PERSPECTIVE TO BOTTOM THREE--------
// radians = degrees * (Math.PI/180);
var degrees:Number = 0;
var radians:Number;
var radius:Number = 50;
for (var i = 0; i<colors.length/2; i++) {
_mc = container_mc["ball"+i+"_mc"];
_mc._y = 40;
// this value needs to change later
//or maybe not?!?
degrees += 120;
trace("degrees = "+degrees);
radians = degrees*(Math.PI/180);
_mc._x = radius*Math.sin(radians);
_mc._xscale = _mc._yscale=radius*Math.cos(radians)+50;
trace("x & y scaling = "+_mc._xscale);
}
//--------END PERSPECTIVE TO BOTTOM THREE----
//
//-------DRAW LINES TO HOLDER_MC--------
for (var i = 0; i<colors.length/2; i++) {
_mc = container_mc["ball"+i+"_mc"];
_mc.lineStyle(1, colors[i], 100);
x = container_mc._x;
y = container_mc._y;
_mc.lineTo(x, y);
}
I want to be able to draw the line that are shown in the attached pic? I thought that lineTo(0,0) would do the trick, but it doesn't even draw a line.
Thanks!
Drawing Problems CurveTo And LineTo
HI beginner back again!
I have imported a video with 120 cuepoints
The idea is that as the video plays a graph will plot. This works fine (for a change) but i need to make a nice curve and im having problems. I understand that a curveTo works with 4 points but i just want a curve to appear whihc ater will go back to a lineTo method after. has anyone done this?
My code is below whihc works, i have yet to finalise the other cue points but it works i just cant figure out how to put a curve in.
var myCount:Number=0//declare & initialis
createEmptyMovieClip("drawingclip",1)
drawingclip._x=76
drawingclip._y=337
drawingclip.lineStyle(3,0xCC0000)
steel_sample_vid.cuePoint = function() {
myCount+=1//increment variable by 1
if (myCount==1){ //
drawingclip.lineTo(0,-1)
}else if (myCount==2)
{
drawingclip.lineTo(2,-5)
}else if (myCount==3)
{
drawingclip.lineTo(2,-10)
}else if (myCount==4)
{
drawingclip.lineTo(2,-15)
}
else if (myCount==5)
{
drawingclip.lineTo(2,-20)
}
else if (myCount==6)
{
drawingclip.lineTo(2-25)
}
else if (myCount==7)
{
drawingclip.lineTo(2,-30)
}
else if (myCount==8)
{
drawingclip.curveTo(2,-35)
}
else if (myCount==9)
{
drawingclip.lineTo(2,-40)
}
else if (myCount==10)
{
drawingclip.lineTo(2,-45)
}
else if (myCount==11)
{
drawingclip.lineTo(2,-50)
}
else if (myCount==12)
{
drawingclip.lineTo(2,-55)
}
else if (myCount==13)
{
drawingclip.lineTo(2,-60)
}
else if (myCount==14)
{
drawingclip.lineTo(2,-65)
}
else if (myCount==15)
{
drawingclip.lineTo(2,-70)
}
else if (myCount==16)
{
drawingclip.lineTo(2,-75)
}
else if (myCount==17)
{
drawingclip.lineTo(2,-80)
}
else if (myCount==18)
{
drawingclip.lineTo(2,-85)
}
else if (myCount==19)
{
drawingclip.lineTo(2,-90)
}
else if (myCount==20)
{
drawingclip.lineTo(2,-95)
}
else if (myCount==21)
{
drawingclip.lineTo(2,-100)
}
else if (myCount==22)
{
drawingclip.lineTo(2,-105)
}
else if (myCount==23)
{
drawingclip.lineTo(2,-110)
}
else if (myCount==24)
{
drawingclip.lineTo(2,-115)
}
else if (myCount==25)
{
drawingclip.lineTo(2,-120)
}
else if (myCount==26)
{
drawingclip.lineTo(2,-125)
}
else if (myCount==27)
{
drawingclip.lineTo(2,-130)
}
else if (myCount==28)
{
drawingclip.lineTo(2,-135)
}
};
Urgent Help:drawing Arrow Mark With Lineto
hello,
in my project i am plottin position of ships on different days on the world map using xml.....everything is fine except...am having problems in showing the direction of voyage of the ships can someone suggest me a way way by which i can draw arrow marks on the lines i am drawing using lineto,moveto command so as to indicate the direction of the ship voyage......it is extremely urgent.....kindly help....
Thanks in advance
ActionScript Drawing - Lineto - Root Co-ordinates ?
Hi Guys
I'm drawing lines in actionscript within a movieclip.
How do i specify _root timeline co-ordinates instead of co-ordinates relative to the movieclip?
Ie, lineto( 0,0) currently is the centre point of my movieclip, and not 0,0 on the root timeline....
any suggestions?
Cheers
Urgent Help:drawing Arrow Mark With Lineto
hello,
in my project i am plottin position of ships on different days on the world map using xml.....everything is fine except...am having problems in showing the direction of voyage of the ships can someone suggest me a way way by which i can draw arrow marks on the lines i am drawing using lineto,moveto command so as to indicate the direction of the ship voyage......it is extremely urgent.....kindly help....
Thanks in advance
Urgent Help:drawing Arrow Mark With Lineto
hello,
in my project i am plottin position of ships on different days on the world map using xml.....everything is fine except...am having problems in showing the direction of voyage of the ships can someone suggest me a way way by which i can draw arrow marks on the lines i am drawing using lineto,moveto command so as to indicate the direction of the ship voyage......it is extremely urgent.....kindly help....
Thanks in advance
Trigonometry - Drawing API - Find Rotated Points X,y With Radians. LineTo
First I would like to say thanks to everyone for keeping this a great forum. I have been comming here for years to ask questions and post answers, and I am always happy with the time I spend here.
PROBLEM:
I need to rotate a drawing API object BEFORE it is drawn. Rotating the clip will not work in my situation. (I am writing source for a PDF file with the help of blazePDF component). I have tried a dozen ways with radians, cos(r*len), atan2, etc. I cannot get the trig correct. I have made a small example below, with a very basic shape. The var "r" being passes to the method needs to facilitate rotating the object. All of the lineTo(x,y) points need modified based on the radians.
Will someone more versed in Trig lend a hand? Thanks for any help you could offer.
--mm
Code:
// draw a box that is rotated 45 degrees
var r:Number = 45*(Math.PI/180);
drawBox(r);
/*
* Draw a box
*
* @paramrA number in radians to rotate the object
*/
function drawBox(r:Number){
_root.createEmptyMovieClip("pdf",1);
pdf.lineStyle(2, 0x0000FF, 100);
pdf.moveTo(100,100);
pdf.lineTo(200,100);
pdf.lineTo(200,200);
pdf.lineTo(100,200);
pdf.lineTo(100,100);
}
Drawing API Hit Test AttachMovie
I currently have a simple box on the stage, using the attachMovie function.
I am also using the drawing API to draw lines on the stage, but can’t seem to get a hittest working. I want a message box to appear when I draw a single line on the box.
Any ideas?
Drawing API Within AttachMovie Instances
Hi I am trying to get curveTo to work within attachMovie created instances where the _x coordinate of each movie lines up with the _x coord plus width of the previous. Each movie is a square of differing dimensions.. All works fine apart from the curveTo which whatever i try does not come out as expected (all curves should look like the first one but scaled according to the dimensions of its containing square). I must be misunderstanding the relative coord settings or something but i have tried every combination. Can any one help? I'm at the tearing my hair out stage.
SWF can be viewed at:
http://www.widecombefair.com/draw/spiral3.html
and the fla file at
http://www.widecombefair.com/draw/spiral3.fla
also see code below
Many thanks in advance
Attach Code
create();
function create():Void {
this.createEmptyMovieClip("gSpiral", this.getNextHighestDepth());
var num:Number = 8;
var startSize:Number = 200;
var nextSize:Number = 200;
var incrSize:Number = 0;
nextSize = startSize;
for (var i:Number = 1; i<=num; i++) {
var mSelected:MovieClip;
mSelected = this.gSpiral.attachMovie("gSquare", "gSquare"+i+"_mc", this.gSpiral.getNextHighestDepth());
var incr:String = String(i);
var sInstance:String = "gSquare"+incr+"_mc";
this.gSpiral[sInstance]._x = incrSize;
this.gSpiral[sInstance]._height = nextSize;
this.gSpiral[sInstance]._width = nextSize;
var outline_mc:MovieClip;
outline_mc = mSelected.createEmptyMovieClip("outlineClip"+i+"_mc", i*10);
outline_mc.moveTo(0,nextSize);
outline_mc.lineStyle(1, 0x000000, 100);
outline_mc.curveTo(0, 0, nextSize, 0);
incrSize = incrSize+nextSize;
nextSize = calcPhi(nextSize);
}
}
function calcPhi(prevLength:Number) {
var newLength:Number = prevLength*(Math.sqrt(5)-1)/2;
return newLength;
}
Edited: 02/16/2007 at 11:25:46 AM by torwalker
[actionscript 2] Drawing API Help With AttachMovie
I hope I can articulate this well. I've been searching forums and the internet for a few days trying to find a way to do the following but with no luck.
I'm creating a mind mapping application and so far I have an interface in which the user can click on a button and a new concept will appear. The button attaches a new copy of a movieclip to the stage. What I want to do now is add a button onto the attached movieclip (its called rectangleDraw in my source) that will draw a line to another instance of the attached movie clip. So essentially the user will click the two movieclips to be linked and a line will be drawn between the two.
I can't seem to figure out a logical way to do this. I am familiar with the drawing API and I'm sure that I can set some variables to do this.
I'd be very grateful if you could help me with the logic behind this concept or even look at my source:
Here
Lineto
ok I have never used the flash drawing things but I can make a line. I just can't figure out how to change its depth :/ heres the simple AS
Code:
onClipEvent (enterFrame) {
_root.createEmptyMovieClip("lines", 1000);
with (_root.lines) {
lineStyle(1, 0x00ff00, 100);
moveTo(_root.startpoint._x, _root.startpoint._y);
lineTo(_root.endpoint._x, _root.endpoint._y);
}
}
I can change the depth of the empty MC but the lines are still drawn over the other things.
LineTo Help..
was messing with the lineTo actions...
Code:
this.lineStyle(3);
this.lineTo("pointB_x","pointB_y");
but I cant seem to get the line to draw from clip "PointA" to "PointB"...
the parameters it accepts is X, Y only..but I have tried using several different ways to get it to work..
Load text file...to get the X & Y location of the 4 clips (points) on the stage.
I have tried using the value imported from the text file., I tried creating my own variables spitting out the X & Y coords... but the line will NOT go to the clip...
OK..I found out I believe the "location" it not "global" comign form _root..it is relative from the clip "drawing the line"...
but now I get "segmented lines" instead of one constant line from PointA to PointB..
example:
Code:
onClipEvent (enterFrame) {
this._x = _root.dataPointA_x;
this._y = _root.dataPointA_y;
this.lineStyle(3);
this.lineTo((_root.dataPointB._x - this._x), (_root.dataPointB._y - this._y));
}
need a text file called:
dataPointLocations.txt
with contents of:
Code:
&dataPointA_x=25&dataPointA_y=100&dataPointB_x=150&dataPointB_y=155&dataPointC_x=225&dataPointC_y=55&dataPointD_x=300&dataPointD_y=125
LineTo.. Or Not? :)
hello..
first of all let me say thankyou for all your great help/input you guys are doing here for us, the one who whish to learn so.. thankyou!
second, here is my challange: I need to create a line between two points, nothing impossible till now but the thing is that the line should represent a telephone wire.. You know.. not a straight line.
Here is how should that work. I have two circles.. when I click one and start dragging towards the second, the whire is created and it starts from one circle to my mouse x, y. As my mouse aproach the second circle, the wire is updated in shape and lenght till finally it connects the 2 circles.
Any ideeas/ tutorials?
Again thankyou and have a great day
LineTo ?
Hi,
I'm having trouble with the lineTo and moveTo functions. I've read the documentation that comes with flash but.... I'm having some problems still. I would be very grateful for any input.
Here's the problem:
I have a center mc clip called "computerVision".
I have 26 other clips on the stage called: cat1,cat2, cat3...... etc
I am trying to draw lines form each one of these clips to the center mc, but it's not working unless I declare each of the little clips statically.
I'm sure I just put something wrong someplace???
I'm going a little bonkers, but I've included the code below.
Thanks so much!
ActionScript Code:
//_________________________________________________
// create clips to draw to
//number of catagories we have
numCat = 26;
for(i = 0; i < numCat; i++){
_root.createEmptyMovieClip("mc"+i, 1);
}
// this function redraws the line
function draw() {
// clear out the old line
for(i = 0; i < numCat; i++){
_root["mc"+i].clear();
// set our line style
_root["mc"+i].lineStyle(1, 0x000000);
// draw the line based on handle locations
_root["mc"+i].moveTo(_root["cat"+i]._x, _root["cat"+i]._y);
_root["mc"+i].lineTo( _root.computerVision._x +100, _root.computerVision._y);
}
}
// call draw every 25 milliseconds
setInterval(draw, 25);
[help] Mc's And LineTo
hello all,
I have the following movie, eventually becoming a flowchart-application:
Basically, it's _root.blocks["block"+i] with i=1 and 2. Inside this block+i movieclip, I got two mc's, input and output, and an empty drawing mc called connection (for drawing into).
What I want to achieve is the following. When a user has made a connection by drawing a line between say, block1 and block2, and afterwards moves one of the blocks, I want the connection-line to move as well. When a connection is made between the output of for instance block1.output and block2.input, a flag, hasConnection, is set, so this property can be tested. So, I have something like this(pseudo):
if( onRelease and hasConnection=1 ) {
onMouseMove = connection.clear;
draw a line between the input and output of these mc's.
}
My problem is this. I can't seem to find the right way to draw a line between the input and the ouput...
I want something like this:
_root.blocks[currentObj].connection.lineTo( _root.blocks[otherObj].output._x, _root.blocks[otherObj].output._y );
But, the empty connection movieclip is inside some other mc's, so I have to juggle the coordinates of all movieclips around, perhaps localToGlobal and globalToLocal. And this juggling goes wrong.
Anyone got an idea?
As3 LineTo Help
is there a way to make this lineTo more smooth so it is more like a brush?
var clip : Shape = new Shape();
addChild (clip);
stage.addEventListener(MouseEvent.MOUSE_DOWN, _handleMouseEvent);
stage.addEventListener(MouseEvent.MOUSE_UP, _handleMouseEvent);
function _handleMouseEvent(evt:MouseEvent):void
{
switch (String(evt.type)) {
case "mouseDown":
stage.addEventListener(MouseEvent.MOUSE_MOVE, _handleMouseEvent);
clip.graphics.lineStyle(5,0x000000);
clip.graphics.moveTo(mouseX,mouseY);
break;
case "mouseUp":
stage.removeEventListener(MouseEvent.MOUSE_MOVE, _handleMouseEvent);
break;
case "mouseMove":
clip.graphics.lineTo(mouseX,mouseY);
break;
}
}
LineTo(x,y,z)?
They have added a lot of 3d properties to flash, including the "z axis". My question is:
It seems to still be "faking" 3d to me, especially since all of the regular drawing api still only uses x and y. Would i have to build my own lineTo functions to draw lines in 3d? or is there something out there that already does it.
Drawing An Outline Of An Object In Flash And Then Animating The Drawing?
I wish to draw an outline of an object in flash? bit by bit a piece of the outline is drawn until the outline is completed, once this has finished then object then appears and the outline disppears (this part I can manage).
I do not know where to begin? So may need a lot of direction on this one.
Scrolling Drawing Board? Drawing Without Moving The Mouse
Hello, I'm new to this board and kind of a flash newbie so you could probably help me out.
What I'm trying to build is what you could call a scrolling drawing board - just like a drawing board but when the mouse comes close to the edge of the window, it scrolls and lets you continue your drawing.
I have no problem creating a drawing board with API, but i can't make it scroll. Usually when i want to scroll a background image i make it move along with the mouse when the cursor is near the edge of the window (for example, if the mouse's coordinates are above a certain number, the background image starts moving in one direction so it "scrolls" in the other direction).
So i wanted to do this with the movieclip of the drawing in a drawing board (make it move according to mouse's coordinates near the edge of the window), but when i scroll i have to stop the mouse at the edge of the window because i cant go any further :p so the drawing moves but it stops drawing. Or maybe what i need is some way to draw even when the mouse is not moving. Is that possible?
I'm sorry it may seem a bit confused (moreover english isnt my native langage :p), I'll try to post an example later. In the meantime, if any of you see how i can do that ... thanks
About The Lineto Function....
ive been looking for a tutorial about this but I haven't been able to find one. Also, I dont know whether this is new in MX or not, sorry if it is. Can some one explain this to me or point me to a tutorial. I'd like to know how to create shapes with actionscript(i don't know the exact code and where to put it) All i remember is bits and peices of the code and also the blank mc..
One more thing, is it possible to generate the mc in AC as well, with the attach method or something. Thanx in advance for answering my questions
LineTo() Command
has anyone here used the lineTo() script? I'd like to see a link to this feature being used if anyone has it. Also, any comment on the difficulty of using this script would be helpful. I just read a little bit from the Actionscript Dictionary regarding this new feature, but it is a little vague for the beginning scripter...
thanks,
myk
LineTo, CurveTo, You Too...
hi,
basically ive got an idea that i just dont know how to realise and was wondering if anyone could help.
basically i need to make a line that is attached to an object's centre point and extends itself when the object is moved.
imagine an octopus that has a box at the end of its legs and as the box is moved the leg stretches and curve's to what ever the position is.
this is basically what i need to do. i know that i need to use curveTo, moveTo and lineTo but am out of my depth when it comes to the new actions in MX.
any help would be greatly appreciated..
LineTo() Issues
Has anyone ever had some problems when using AS Drawing Methods (moveTo() and lineTo()). I'm dynamically drawing a lines for a timeline in the background of a movie, and I have the lines for the appropriate spots being drawn, but sometimes an extra line across the enter screen shows up at just the end.
I guess I'm really asking if anyone knows how to handle extra drawing errors? Is there a way to make sure it stops drawing extra crap?
MoveTo And LineTo
Hi,
I'm using the functions moveTo and lineTo to plot a line graph. The thing is, the graph appears ontop of everything else and stays there even when I change frames. How can I get it to appear behind certain objects and to only appear on a certain frame?
cheers,
dwo
PS: I'm using the call
_root.createEmptyMovieClip("graph", 2);
and plotting the lines inside this movieclip using
with (_root.graph) {
moveTo(a, b);
etc
}
Removing LineTo
Hey freinds.
I was wondering how to keep a lineTo on the screen for one frame and then removing it. problem is, the lineTo is created with another Movieclip. heres the code.
code:
_root.createEmptyMovieClip("line"+_root.ht, _root.ht);
with (eval("_root.line"+_root.ht)) {
lineStyle(1, 0xFFFFFF, 25);
moveTo(startX, startY);
lineTo(endX, endY);
_root.ht++;
}
anyone?
thanks in advance.
waste
LineTo Problem
Hi there,
I have a problem with the lineTo function combined with duplicateMovieClip. I want 2 draw a line from dot 1 to dot 2 etc. and from dot 5 to 1 (making it closed). I was wondering how i should do this. these dots are draggable and i want te line to stay between the dots while I drag them.
this my scrip for making the dots.
code:
_root.onLoad = function () {
_root.attachMovie("punten", "punt", 100)
_root.punt._alpha = 0;
for (i=1; i<6; i++) {
_root["punt"].duplicateMovieClip("punt"+i,10+i);
p = _root["punt"+i];
p.createTextField("textz"+i, i, -7, -7, 20, 20);
p["textz"+i]._visible = 1;
p["textz"+i].font = "Verdana"
p["textz"+i].color = 0xFFFFFF;
p["textz"+i].size = 14;
p["textz"+i].text = i;
p._x = random (640);
p._y = random (480);
p._alpha = 100;
_root["punt"+i].onPress = function () {
this.startDrag(false);
}
_root["punt"+i].onRelease = function () {
this.stopDrag ();
}
}
}
how do I do this? I know how to draw a line but it wont stay connected while i drag them.
plz help me
tia Henke
Is Anyone A LineTo Wizard?
i don't know why but i just can't get the hang of lineTo...
i want a line to start at a given position draw gradualy to another position while turning with a curve at more positions and all this as a function (but mainly its the curve thats got me)
code:
function myLine (MC2_create,startx,starty,finishx,finishy,curve_po ints():array){
}
and then is it possible to reverse that?
any help or tutorials would be good...
Remove Lineto?
Is there a way to remove dynamically created lines? Preferably having them fade out.
I posted in another topic about a week ago, but nobody answered, so I'm going to rephrase what I'm looking for. I already have most of my code set up, but I'm working on aesthetics. Now what I'm doing is creating both an outline, and a square inside of the "mcstatic" that I have on the stage. Currently everything is working perfectly. One small problem though, is that although the lines are created every frame, they aren't dissapearing after they've been created. Now, I'm trying to create a smooth looking effect here, so I want those lines to fade out. I'm tinkering around with this function:
PHP Code:
function linefade2() {
var linesfade = new mx.transitions.Tween(line2_mc, "_alpha", mx.transitions.easing.Strong.easeOut, 100, 0, 1, true);
linesfade.onMotionFinished = function() {
line2_mc.removeMovieClip();
_root.createEmptyMovieClip("line2_mc", 2);
};
}
Now this looks like it should do what I'm looking for. It sets up a function, with a fade time of 1 second and then once that's faded, it removes the movie clip and re-creates another one.
If you need the rest of the code, I'd be glad to show it. Also, it should be known that in the initialisation I create line2_mc, and the lines being drawn is an enterFrame function of line2_mc.
Thanks,
DaVuLF
LineTo And MoveTo
ok hi all..
first of all lets post my AS here
PHP Code:
_root.createEmptyMovieClip("lijn", 1);
_root.lijn.lineStyle(2, 0xFCE443, 100);
var from_x = _root.a._x;
var from_y = _root.a._y;
var to_x = _root.b._x;
var to_y = _root.b._y;
this.onEnterFrame = function() {
if (_root.block.hitTest(_root.lijn)) {
_root.lijn.lineTo(to_x, to_y);
_root.lijn.lineTo(to_x, 100);
// trace("test");
} else {
_root.lijn.moveTo(from_x, from_y);
_root.lijn.lineTo(to_x, to_y);
}
}
i have made 2 MC's calles a and b and a block.
a line will be created from a to b but if something blocks the line, let the line go arrouund the block.
have no idea how to do this..
would be very very thankfull if someone could help me..
[F8] LineTo Causing Serious Lag?
I have some simple code that creates a movie clip and draws a line in it to represent a bullet in my game. Code works great except for the fact that as more and more bulletes get shot, the slower and slower my game gets. I would think that the obvious cause for this problem would be if movie clips were building up and up and up. But I remove the past movie clip and I know they are being removed. If I comment out this code my game runs at a blazing speed so I KNOW that its this code that is causing the problem. I just cant see it. Maybe flash's garbage collector is getting backed up or something.
Code:
unloadMovie(lineTarget);
_root.createEmptyMovieClip("line"+_global.dn_weaponlines,_global.dn_weaponlines);
lineTarget = _root["line"+_global.dn_weaponlines];
_root["line"+_global.dn_weaponlines].lineStyle(.75, 0xFFFFFF, 50);
_root["line"+_global.dn_weaponlines].moveTo(lastCoordX, lastCoordY);
_root["line"+_global.dn_weaponlines].lineTo(targeted._x, targeted._y);
_global.dn_weaponlines++;
EDIT : so it seems I was using the incorrect method/function to remove the movie clip from existance. removeMovieClip fixed my prob
Clear LineTo
PHP Code:
Line.lineStyle(3,0x000000,90);
//This is the script to draw the line
onMouseDown = function (){
Line.moveTo(_xmouse, _ymouse);
onMouseMove = function (){
Line.lineTo(_xmouse, _ymouse);
}
}
onMouseUp=function(){
onMouseMove=null;
}
PHP Code:
//movie clip event
onClipEvent (load) {
onMouseMove=null;
}
on (press) {
Mouse.hide();
this.startDrag(1);
}
i m using a lineTo. but when i put clear() function to the button the lineTo is erased forever. and i want to draw again!
Thanks!
PHP Code:
//button action
on (rollOver) {
Mouse.show();
}
on (press) {
_root.window_mc.container_mc.clip3.container.Line.clear();
}
LineTo Function
Hi ,
How to animate line to function from one point to another........
Duplicating A LineTo
I'm looking for a way to Duplicate a LineTo
I am currently in the works of making a pen tool,
I have each point output its x and y to an array and I have the lines able to
Move to the first point in the array
then draw the line to the 2nd
I haven't been able to figure out how to duplicate that so it can continuously do that all the way down.
LineTo Method
Is there any way to remove a line drawn using the lineTo method, or else to change the starting and ending points of such a line using AS?
LineTo Problem
Hi,
I'm creating a mini drawing app where I want users to be able to connect lines between MCs. I've managed to sort out so that they can draw lines and delete them but I cannot get the lines to connect . Well, I don't actually know how to...could anyone help me please?
Line button:
ActionScript Code:
on (release)
{
_root.isactive = "line";
_root.base.linebutton = _root.activebutton;
}
on (rollOver)
{
_root.base.tooltip.text = "Line Tool";
_root.base.tooltip.textColor = 0;
}
onClipEvent (enterFrame)
{
if (_root.isactive == "line")
{
myColor = new Color(this);
myColorTransform = new Object();
myColorTransform = {ra: "50", rb: "40", ga: "60", gb: "112", ba: "80", bb: "200", aa: "100", ab: "100"};
myColor.setTransform(myColorTransform);
}
else
{
myColor = new Color(this);
myColorTransform = new Object();
myColorTransform = {ra: "100", rb: "0", ga: "100", gb: "0", ba: "100", bb: "0", aa: "100", ab: "100"};
myColor.setTransform(myColorTransform);
} // end if
}
Controller MC on the stage:
ActionScript Code:
onClipEvent (mouseDown)
{
if (_root.layerzero == true)
{
draw = true;
_root.linex = _root._xmouse;
_root.liney = _root._ymouse;
_root.drawing.lineStyle(_root.base.bsize, _root.currentcolor, _root.base.opac);
_root.drawing.moveTo(_root._xmouse, _root._ymouse);
}
}
onClipEvent (mouseMove)
{
if (_root.layerzero == true)
{
if (draw == true && _root.base.helptabs._visible == false)
{
if (_root.isactive == "line")
{
_root.createEmptyMovieClip("linetracker", 2);
_root.linetracker.moveTo(_root.linex, _root.liney);
_root.linetracker.lineStyle(1, _root.currentcolor, 100);
_root.linetracker.lineTo(_root._xmouse, _root._ymouse);
} // end if
} // end if
} // end if
}
onClipEvent (mouseUp)
{
if (_root.layerzero == true)
{
draw = false;
if (_root.isactive == "line")
{
_root.drawing.lineTo(_root._xmouse, _root._ymouse);
_root.linetracker.clear();
} // end if
} // end if
}
Is There Any Alternative To LineTo?
lineTo() is driving me absolutely nuts. I just want something that will draw a line from one absolute position on the screen to another absolute position on the screen. Is there something that does that?
Thanks.
LineTo () Is Slow?
http://www.netizenlabs.com/new/portfolio.swf
take a look, it doesnt always draw it correctly to the square in the middle when you drag it.
PHP Code:
function dragClip(clip, draw, originalX, originalY) {
point = new object();
point.x = originalX;
point.y = originalY;
clip.globalToLocal(point);
clip.createEmptyMovieClip("temp", 10);
updateAfterEvent();
clip.temp.lineStyle (0.5, "0x999999", 25);
clip.temp.moveTo(0 ,0);
clip.temp.lineTo(point.x, point.y);
clip._x = clip._parent._xmouse;
clip._y = clip._parent._ymouse;
}
AND I TRIED THIS AS WELL
function dragClip(clip, draw, originalX, originalY) {
point = new object();
point.x = originalX;
point.y = originalY;
clip.globalToLocal(point);
clip.temp.clear();
clip.temp.lineStyle (0.5, "0x999999", 25);
clip.temp.moveTo(0 ,0);
clip.temp.lineTo(point.x, point.y);
updateAfterEvent();
clip._x = clip._parent._xmouse;
clip._y = clip._parent._ymouse;
}
where clip.temp was created outside
LineTo In Scrollpane Bug?
Anybody ever tried to draw a line longer than 8065 pixel lenght on a scrollpane content?
If I do so the line is cut off at the front.
As work around I draw the line in parts. But strange enought I need to move at the end of the line part before I draw the next part. Otherwise the line is still cut off.
Has anybody a better solution?
Snippit:
var gitter_mc = myFScrollPane.getScrollContent();
var start_x = 0;
var end_x = 8500;
var tmp_start_x = start_x;
while(end_x - tmp_start_x > 8000)
{
tmp_start_x = tmp_start_x + 8000;
gitter_mc.lineTo(tmp_start_x ,my_y);
gitter_mc.moveTo(tmp_start_x,my_y);
}
gitter_mc.lineTo(end_x ,my_y);
myFScrollPane.refreshPane();
LineTo Length
Is there a way to determine the length of a line that was drawn with lineTo?
Tweening Lineto
hello,
well i wanted to know if there is a way by which i could tween the lineto action script to draw lines in flash.....if it is possible then how can it be done....
sfomra
LineTo Not Connecting
I have finally worked out most of the issues with my file after many long hours and much help from the forum. Only to have my lines not connect to the "link" button that they should.
They also don't appear until you click on the movie which is strange since I have them coded to show onLoad I thought.
Can anyone take a look at the code and see if they see what could be causing my line not to connect?
Each node should actually have several lines extending from it based on the XML. XML and FLA are attached.
My AS:
Code:
this.dataArray = new Array();
this.drawNetwork = function(dataSrc){
for (var ID=0;ID < dataSrc.length;ID++){
if (dataSrc[ID] != undefined){
var mc = _root['mc'+ID];
var thisBut = _root['but'+ID];
var prntBut = _root['but'+ dataSrc[ID].prnt];
mc.clear();
mc.lineStyle(2, 0x999999);
mc.moveTo(thisBut._x, thisBut._y);
mc.lineTo(prntBut._x, prntBut._y);
}
}
}
var xmldata = new XML();
var buttons = new Array();
xmldata.ignoreWhite = true;
xmldata.onLoad = function(loaded) {
var tmpxml;
if (!loaded || this.status){
trace ("Not loaded or parse error");
return;
} else {
tmpxml = this.firstChild.firstChild;
do {
buttons.push(Array(tmpxml.attributes.ID, tmpxml.attributes.name, this.getLinks(tmpxml)));
nodeID =Number(tmpxml.attributes.ID);
_level0.dataArray[nodeID] = new Object();
var thisNodeID = _level0.dataArray[nodeID];
name = tmpxml.attributes.name
// can't create two clips at same depth
var newBut = _root.attachMovie('butTemp', 'but'+ nodeID, (nodeID*2)+1);
newBut.but_txt.text = name;
newBut._x = random(600);
newBut._y = random(500);
} while (tmpxml = tmpxml.nextSibling);
trace(buttons);
}
};
xmldata.getLinks = function(tmpxml){
tmpxml = tmpxml.firstChild;
var links = new Array();
do {
links.push(tmpxml.attributes.to);
link = Number(tmpxml.attributes.to);
_level0.dataArray[prnt] = new Object();
var thisNodeLink = _level0.dataArray[prnt];
var prntBut = _root['but'+link];
var mc = _root['mc'+nodeID];
_root.createEmptyMovieClip( 'mc'+nodeID, nodeID*2);
} while (tmpxml = tmpxml.nextSibling);
return links;
trace(links);
}
xmldata.load("node_link3.xml");
_root.onEnterFrame = function (){
if (_root.draggingNode) _level0.drawNetwork(_level0.dataArray);
};
XML:
Code:
<nodes>
<but name="Node 1" ID="1">
<link to="2"></link>
<link to="3"></link>
<link to="4"></link>
<link to="5"></link>
</but>
<but name="Node 2" ID="2">
<link to="3"></link>
<link to="4"></link>
<link to="5"></link>
</but>
<but name="Node 3" ID="3">
<link to="4"></link>
<link to="5"></link>
</but>
<but name="Node 4" ID="4">
<link to="5"></link>
</but>
<but name="Node 5" ID="5">
</but>
</nodes>
Lineto() Chaos
I'm trying to draw a line between 2 Mc when clicked and I seem to be on the way, I'm using lineto();
first I take the _x and _y of the first one:
ActionScript Code:
on(press){
_root.origenx=_root.mc1._x;
_root.origeny=_root.mc1._y;
}
After I draw the line when clicking on the second one:
ActionScript Code:
on(press){
lineStyle (5, 0xFF00FF, 50);
_root.mc2.lineto(_root.origenx, _root.origeny);
}
The problem is line never reaches mc1, it goes it's own way...
|