-
How to control only portion of mc-line?
Dear All,
Code:
//this code will create a line on stage from(x1=10, y1=10) to (x2=200, y2=200).
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.moveTo(10, 10);
mc.lineStyle(1.5, 0xFF0000, 100);
mc.lineTo(200, 200);
Is there any way to control just portion of this created line. What needed is to give (_alpha=0) ONLY to the portion of the line which is greater than (x=100, y=100)???
Thanks!
-
.
Hi,
Haven't figured a way to do it dynamically, but you can simply do this, or something similar;
PHP Code:
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
var minX:Number = 100;
var minY:Number = 100;
var maxX:Number = 300;
var maxY:Number = 300;
mc.moveTo(10,10);
mc.lineStyle(5.5,0xFF0000,10);
mc.lineTo(minX,minY);
mc.lineStyle(1.5,0xFFCC00,100);
mc.lineTo(maxX,maxY);
was wondering why have it drawing more if you are not going to see it anyway - setting _alpha to zero
Last edited by fruitbeard; 04-26-2015 at 02:13 PM.
-
Originally Posted by fruitbeard
Hi,
was wondering why have it drawing more if you are not going to see it anyway - setting _alpha to zero
it is for a game where its borders isn't the stage borders. lines are drawn in a random way, and the part of any line which is outside the borders of the game should be invisible by setting alpha to zero.
thank you,
your code is a good starting point for starting to figure out how to make it dynamic.
-
.
Hi,
Does this help any further, I'm not so sure on the drawing type stuff, don't rwally use it that much.
PHP Code:
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
var minX:Number = 100; var minY:Number = 100;
var maxX:Number = 300; var maxY:Number = 287;
function doDraw(a:Number, b:Number, c:Number, d:Number):Void { mc.moveTo(10,10);
mc.lineStyle(5.5,0xFF0000,25); mc.lineTo(a,b);
if ((c > a) && (d > b)) { mc.lineStyle(1.5,0xFFCC00,100); mc.lineTo(c,d); } }
doDraw(minX,minY,maxX,maxY);
-
Originally Posted by fruitbeard
Hi,
Does this help any further, I'm not so sure on the drawing type stuff, don't rwally use it that much.
PHP Code:
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
var minX:Number = 100; var minY:Number = 100;
var maxX:Number = 300; var maxY:Number = 287;
function doDraw(a:Number, b:Number, c:Number, d:Number):Void { mc.moveTo(10,10);
mc.lineStyle(5.5,0xFF0000,25); mc.lineTo(a,b);
if ((c > a) && (d > b)) { mc.lineStyle(1.5,0xFFCC00,100); mc.lineTo(c,d); } }
doDraw(minX,minY,maxX,maxY);
Some adjustment to your code:
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
var minX:Number = 100;
var minY:Number = 100;
var maxX:Number = 300;
var maxY:Number = 300;
var boundaryX:Number = 200;
function doDraw(xmin:Number, xmax:Number, ymin:Number, ymax:Number, xboundary:Number):Void {
mc.moveTo(xmin, ymin);
//Think about the boundary as a vertical line fron top of stage to the bottom, at e.g. x=200
if (xmax>xboundary) {
//Make Interpolation, to get yboundary. (xboundary, yboundary) the point at which the drawn line crosses the boundary(vertical line).
var yboundary:Number = ymax-((xmax-xboundary)*(ymax-ymin)/(xmax-xmin));
mc.lineStyle(5.5, 0xFF0000, 25);
mc.lineTo(xboundary, yboundary);
mc.lineStyle(1.5, 0xFFCC00, 100);
mc.lineTo(xmax, ymax);
} else {
mc.lineStyle(5.5, 0xFF0000, 25);
mc.lineTo(xmax, ymax);
}
}
doDraw(minX, maxX, minY, maxY, boundaryX);
try it with e.g.
var boundaryX:Number = 200;
and
var boundaryX:Number = 350;
-
.
I knew you would figure it out
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
|