|
-
Help - I'm DRAWING a blank ;),
Greetings and thanks for any assist (Especially Bret - I'm standing on your coded shoulders),
I am in over my head in my attempts to master AS. As such, I am constantly piecing together bits of code to learn and accomplish my immediate tasks. Following is a chunk of code that Bret posted several years ago to graphically draw point-by-point any color line (cool ! I simplified the coordinate set to draw a rectangle and a triangle. While this was not written with KoolMoves in mind, it works fine.
What I wish to accomplish is to ad a bit of code to trace a "pencil" bmp/jpeg element around the screen so that the appearance is that the "pencil" draws the line as it is being scripted. The best I can do is display a pencil element that just sits there. I do not yet have the grasp of embedding the graphic into the script to make it move.
I am totally open to being directed to an example that demonstrates that which I wish to achieve, and I apologize if this is a redundant request. I simply can not locate the answer on my own. If someone would be so kind as to throw me a coded bone . . .
Namaste - FlashPast (Baran)
function drawit(coords){
if (idx<coords.length){//Not the end of the Array?
if (coords[idx]>=1000){//it's a moveTo
trace("MOVE");
//Move it
canvas.moveTo(coords[idx]/1000,coords[idx+1]/1000)
}//End if Move
if (coords[idx]==-1){//it's a Change Color
trace("color");
canvas.lineStyle (3,coords[idx+1],100)//assume line width of 1 and Alpha of 100
}//end if Change Color
if (coords[idx]>-1 && coords[idx]<1000){//It's a lineTo
// trace("line");
//draw the line to the coordinates
canvas.lineTo(coords[idx],coords[idx+1]);
} //end If lineTo
}//end if
idx=idx+2;
}//end function
var idx=0;
var coords = new Array();
coords[0]=150000
coords[1]=200000
coords[2]=150
coords[3]=200
coords[4]=350
coords[5]=200
coords[6]=350
coords[7]=500
coords[8]=150
coords[9]=500
coords[10]=150
coords[11]=200
coords[12]=550000
coords[13]=250000
coords[14]=-1
coords[15]=50000
coords[16]=550
coords[17]=250
coords[18]=650
coords[19]=350
coords[20]=450
coords[21]=350
coords[22]=550
coords[23]=250
_root.createEmptyMovieClip ("canvas", 1);
canvas.lineStyle(3,0,100);
stop();
mytimer=setInterval(drawit,250,coords);
-
Are you exporting this as AS1 or AS3?
-
KoolMoves Moderator
Acutally when you realize that the coords are just x and y positions it's easy.
just add
function drawit(coords){
if (idx<coords.length){//Not the end of the Array?
if (coords[idx]>=1000){//it's a moveTo
trace("MOVE");
//Move it
canvas.moveTo(coords[idx]/1000,coords[idx+1]/1000)
mc1._x=coords[idx]/1000;
mc1._y=coords[idx+1]/1000;
}//End if Move
if (coords[idx]==-1){//it's a Change Color
trace("color");
canvas.lineStyle (3,coords[idx+1],100)//assume line width of 1 and Alpha of 100
}//end if Change Color
if (coords[idx]>-1 && coords[idx]<1000){//It's a lineTo
// trace("line");
//draw the line to the coordinates
canvas.lineTo(coords[idx],coords[idx+1]);
mc1._x=coords[idx];
mc1._y=coords[idx+1];
} //end If lineTo
}//end if
idx=idx+2;
}//end function
where mc1 is a movieclip with a pencil image aligned on the center of the movieclip (there is one in the clipart)
-
Sometimes I overthink . . . I think?
Bret,
Thank you for the (now) obvious solution to my problem. I was trying all sorts of "solutions" . . . a regular Thomas Edison just approaching the concept of: light bulb.
Thank you, also, for all that you contribute on this forum in your thousands of posts. As we learn that which we teach, you are surely the "pro from Dover" in AS3.
Namaste - Flash Past
-
KoolMoves Moderator
You are welcome, I'm no pro in AS3. Just a hack but I try to be helpful and I love solving problems.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|