Changing Linestyle.
Hi,
I have several lineStyle created MCs. Can I change the lineStyle after it has been set? I have a pencil tool that allows a user to set colour, width and draw, and would like to be able to change the colour and width after the line has been drawn by the user. Any ideas?
Any help would be great.
Steven.
FlashKit > Flash Help > Flash ActionScript
Posted on: 04-23-2005, 04:48 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Changing LineStyle
I'm dynamically creating a movie clip and drawing a line. After it's been drawn initially I would like to be able to change it's lineStyle during runtime. If I just call the lineStyle method on that MovieClip it doesn't seem to change the line. Is there a way to force the line to redraw, or do I manually have to clear the MovieClip and then call lineStyle, moveTo, lineTo, etc. and recreate the line?
Changing LineStyle At Run-time
hello,
i have created a triangle at run-time.
now my problem is that, i want to change the lineStyle of the triangle to 3.
how should i go about it
------------------------------------------------
_root.createEmptyMovieClip( "triangle", 1 );
with ( _root.triangle )
{
lineStyle( 5, 0xff00ff, 100 );
moveTo( 200, 200 );
lineTo( 300,300 );
lineTo( 100, 300 );
lineTo( 200, 200 );
// change the border thickness to 3
lineStyle( 3, 0xff00ff, 100 );
}
--------------------------------------------------
Dynamically Changing LineStyle
I am allowing the user to draw on a loaded movie clip (photo) . I have a color picker component that allows the user to pick the color for this simple drawing.
But once I get the variable (hex color) from the component, I can't get the lineStyle to change for the drawing. Basically, the drawing/line color stays the same color as it is in the original lineStyle.
Shouldn't the code below work (where c = hex color)?
ActionScript Code:
_root.frame.photo_frame.line.lineStyle(5,c,100);
LineStyle
I have been working with dynamic line creation for a site I’m working on. The problem I am having is that the lines are pill shaped, and I was wondering if anyone knew how to make them rectangles.
Thanks.
LineStyle Help
Hi,
I'm designing a Drawing API program in Flash that allows users to choose colors, line styles, opacity, etc. I've got the color part down pat but I can't seem to figure out how to get the thickness and opacity parts to work.
Line.lineStyle(10,0x000000, 100);
I've got two dynamic text fields set up for the alpha and the thickness respectively. I would like to take the numbers from the text box and place them in the lineStyle string. How would I do that?
to see an example go to http://www.ogdesignlab.com/cmoran/pp/pinMask.swf
Thanks in advance
Using LineStyle
Hi, is it possible to draw a dynamic line with a dashed or any of the other line styles that use can use with the built in drawing tool?
Rather than just beinh able to define tickness...
M@?
Using LineStyle()
can you use any of the other standard line styles when using lineStyle(). straight lines are all well and good, but i wouldn't mind a ragged or dotted one occasionally.
anyone know?
if yes... anyone know how?
Linestyle Query
I am fiddling about with creating graphics thru a/s, and so I'm trying things with, lineto, curveto etc etc.
The thing is if I create a shape on the stage I have several linestyles to choose from, but using linestyle from a/s only gives me thickness, colour, alpha.
Anyway to call the different 'styles' from script?
Glow On LineStyle?
Hello, I found this tutorial that tells me how to create a painting application in flash: here
anyways I think the lines get a little to edgy so i thought it would get better if I added some glow around the line if thats possible with actionscript?
The lineStyle looks like this now:
Line.lineStyle(2,0x990000,100);
PS:
I think i need to use import flash.filters.GlowFilter if im not wrong but i've never used it before.
edit:
Okay found out how it worked, I just added:
import flash.filters.GlowFilter;
var filter:GlowFilter = new GlowFilter(0x000000, 100, 4, 4, 2, 15, false, false);
Line.filters = [filter];
No Linestyle After ColorTransform?
I created a dynamic rectangle by doing
PHP Code:
key.graphics.lineStyle(4, 0x000000); key.graphics.moveTo(0, 0); key.graphics.beginFill(0xFFFFFF, 1); key.graphics.drawRect((stage.stageWidth/8) * i , 0, (stage.stageWidth/8), stage.stageHeight); key.graphics.endFill();
Later on, I want to change the fill color of the rectangle. When I do this the outline/linestyle is gone (or transparent). How can I fix it so there is still a linestyle?
This is the code I used to change the fill color:
PHP Code:
var colorTransform:ColorTransform = transform.colorTransform; colorTransform.color = 0xFF4D4D;key.transform.colorTransform = colorTransform;
Tapered Linestyle
Is it possible to draw a tapered linestyle with AS 2/3.0 ? graphics.lineStyle has a weight parameter, but I don't think it's possible to animate its value without changing the whole drawn line. I can think of just one solution, which is duplicating a bunch of circles and scaling their size gradually, but wouldn't be a fast and economic solution ...
Thanks.
SetRGB And Linestyle
I have this function that blends 2 colors of a MC, however I want to keep a 3 px stroke of white around the MC, how do I keep the border from getting changed too?
PHP Code:
Number.prototype.HEXtoRGB = function(){
return {rb:this >> 16, gb:(this >> 8) & 0xff, bb:this & 0xff};
}
Color.prototype.blendRGB = function(c1,c2,t){
if (arguments.length == 2){
t = c2;
c2 = this.getRGB();
}
if (t<-1) t=-1;
else if (t>1) t=1;
if (t<0) t=1+t;
c1 = c1.HEXtoRGB();
c2 = c2.HEXtoRGB();
var ct = (c1.rb+(c2.rb-c1.rb)*t) << 16 | (c1.gb+(c2.gb-c1.gb)*t) << 8 | (c1.bb+(c2.bb-c1.bb)*t);
this.setRGB(ct);
return ct;
}
mc5.lineStyle(3, 0xFFFFFF, 100, true, "none", "round", "miter", 1);
Chinging LineStyle Of An MC On The Stage
I have had a fair bit of success with creating lines using a/s and have had no dificulty with most aspects of changing colour, thickness etc.
I have now created a fairly complex line drawing (which was actually sourced from 3DSMax) and I want to be able to change some aspects from code (rather than manually change the 50 or so frames)
I am able to change the colour using MC.setRGB(), but I can't change the line thickness.
Anyone got a way around this?
LineStyle Change Slows Down App
Hi there,
I have an application where part of the animation loop is as follows :
Code:
graphics.lineStyle(2.0, color);
graphics.drawRect(bounds.x, bounds.y, bounds.width, bounds.height);
With the lineStyle set method on the FPS starts to drop to 1 after about 10 seconds, with that first line commented FPS stays high and stable.
I've found a number of posts outlining the problem and everybody seems to think it's the actual drawing of the outline that causes the slowdown, but setting the lineStyle only once while always drawing the outline is also fast. I'm left to conclude it's the lineStyle call itself that's causing issues.
Anyone have any explanation for this?
P.S. Funny detail, people working in .NET apparently run into the exact same problem. Windows API call problem perhaps?
ColorTransform Clobbering LineStyle
Howdy,
When I apply a colorTransform to a programatically created Sprite (lineStyle, beginFill, moveTo, lineTo....), the vector line I used to draw the sprite with gets clobbered. For the time being, I'm having to delete the sprite and recreate it with the new color in order to keep the sprite with the proper outline, but it seems like there's a more elegant solution to this. Anyone have any ideas?
Thanks in Advance,
John
Linestyle With BitmapData ** Challenge**
I am wondering if anyone could have the solution for this problem.
I am creating the line trough "lineStyle" method but I need that instead of color on the fill I want to use an image.... something like the beginBitmapFill ... well I tried everything and could not fin a solution for that...
even the " lineGradientStyle" does not supprt the bitmap fill...
PLEASE SOMEONE HELP ME
Graphics.lineStyle And Arrays
Hey!
I have this script I wrote for AS2 and remade it for AS3. I still don't know like anything really with AS3, but was just trying things out. I chose an example I had made in AS2 that just uses line drawing techniques to create the image on the stage.
So I used
this.graphics.lineStyle(1,0x000000,0.1);
Which is drawn about 20 times a frame and it just as laggy as in AS2, which is a disapointment to me because I thought it would draw much faster, but it doesn't. I might be doing somthing wrong, and I don't know what information I should put here but any comments would be welcome!
Also how can I create the variables:
var curX:Array = [];
var curY:Array = [];
In a list form like this:
var curX:Array, curY:Array...
because I tried it and the actionscript has a spastic on me becuase it wants the = [];
Thanks for all the help,
Dan
Removing LineStyle On Press?
Hi,
I'm using duplicateMovieClip and each time the user drags a second one a line connects the two clips together. I have also added a removeMovieClip so users can get rid of a clip should it be in the way. However, this does not remove the lineStyle. How can I do that, please? Code is below:
Code:
xlocs=new Array()
function drawlines(dragged_mc)
{
for(n=0;n<xlocs.length;n++)
{
if(xlocs[n][2]==dragged_mc){xlocs[n][0]=Math.round(dragged_mc._x+100);xlocs[n][1]=Math.round(dragged_mc._y)}
}
xlocs.sort(Array.NUMERIC)
bounce=100;
drawthem()
}
bounce=100
thetoggle=1
function drawthem()
{
for(n=0;n<(xlocs.length-1);n++)
{
this.createEmptyMovieClip("canvas_mc"+n, n+100);
_root["canvas_mc"+n].lineStyle(1, 0x000000, 100);
_root["canvas_mc"+n].moveTo(xlocs[n][0]-100, xlocs[n][1]);
//_root["canvas_mc"+n].lineTo(xlocs[n+1][0]-100, xlocs[n+1][1]);
if(xlocs[n+1][0] != 999){_root["canvas_mc"+n].curveTo((xlocs[n+1][0]-100)-(bounce*thetoggle), (xlocs[n+1][1])-(bounce*thetoggle),xlocs[n+1][0]-100, xlocs[n+1][1]);}
}
circle1._x - circle1.stringVib, circle1._y - circle1.stringVib, circle1._x, circle1._y
}
Joint Style From LineStyle() Using LineTo()
Hi,
I am trying to create a simple drawing app. I am using Flash 9.0 with ACtion Script 3 inside the CS3 environment. Here is my code snippet that I am having a problem with:
var childLine:Shape=new Shape;
childLine.graphics.beginFill(cp.selectedColor,1*(s lider_val/num_alpha_intervals));
childLine.graphics.lineStyle((halfSize*2)+2,cp.sel ectedColor,1*(slider_val/num_alpha_intervals),
false,LineScaleMode.VERTICAL,CapsStyle.ROUND, JointStyle.ROUND);
childLine.graphics.moveTo(x_origin,y_origin);
childLine.graphics.lineTo(x_new_origin+(halfSize), y_new_origin+(halfSize));
childLine.graphics.endFill();
addChild(childLine);
Here is the output of the Flash Movie:
The alpha value of the line being drawn here is set to about 0.50.
So the problem appears to be the joints on the beginning and end of each new line are doubling up. By that I mean the starting joint of the new line seems to be overlayed on the end joint of the previous line.
I wan to use JointStyle = ROUND becuase it creates the smooth transition I want from one line to the next. I have tried various setting for the JointStyle in conjunction with the CapStyle, but non seem to prevent the joint from each line from doubling up.
Should I use a different technique altogether to accomplish a line drawing app. Would the Pen object be a better choice for this app?
Thanks very much
MovieClip.lineStyle Method Problem
Hi,
I am trying to create a small application where users drag a number of MCs around and where a line is drawn to each one when an MC is released. Now, I would like to change the look of the line so that it appears to be 'dotted', is this even possible?
This is my code so far:
ActionScript Code:
function drawthem()
{
for(n=0;n<(xlocs.length-1);n++)
{
this.createEmptyMovieClip("canvas_mc"+n, n+100);
_root["canvas_mc"+n].lineStyle(1, 0x000000, 100);
_root["canvas_mc"+n].moveTo(xlocs[n][0]-100, xlocs[n][1]);
_root["canvas_mc"+n].lineTo(xlocs[n+1][0]-100, xlocs[n+1][1]);
if(xlocs[n+1][0] != 999){_root["canvas_mc"+n].curveTo((xlocs[n+1][0]-100)-(bounce*thetoggle), (xlocs[n+1][1])-(bounce*thetoggle),xlocs[n+1][0]-100, xlocs[n+1][1]);}
}
circle1._x - circle1.stringVib, circle1._y - circle1.stringVib, circle1._x, circle1._y
}
Create Gradient LineStyle With Drawing Api
hi there
does anyone know whether it is possible to apply a gradient lineStyle?
I would like to create a look and feel very much like the brush in photoshop, which drops opacity on either side of the stroke.
I was hoping to achieve this with lineGradientStyle, but it doesnt really work.
does anyone have an idea of how to approach this
thanks for your help
J
Removing Antialias From Graphics.linestyle
I have this function:
Code:
function drawLine(x1, y1, x2, y2, color) {
canvas.graphics.lineStyle(1, color, 1.0, true);
canvas.graphics.moveTo(x1, y1);
canvas.graphics.lineTo(x2, y2);
}
Which works just fine, but I don't like that it antialiases the line. Is there any way I can stop it from doing this?
Tweening Is Increasing Shape Linestyle
I have a shape that, when I tween the width, the linestyle (the border around a roundrect) that it uses also tweens and gets really big and fat. I want the shape to just get wider. Is there any way to get around this?
this function draws the shape:
public function redraw():void {
border.graphics.clear();
border.graphics.beginFill(fillColor);
border.graphics.lineStyle(borderLineWidth,color);
border.graphics.drawRoundRect(0,0,expandedWidth,expandedHeight,cornerRad,cornerRad);
border.graphics.endFill();
}
when I tween it like this I have no problem, the shape expands and moves to a new location:
myTween1 = new Tween(border, "x", Elastic.easeOut, border.x, p.x, 25, false);
myTween2 = new Tween(border, "y", Elastic.easeOut, border.y, p.y, 25, false);
myTween3 = new Tween(border, "width", Elastic.easeOut, 0, expandedWidth, 25, false);
myTween4 = new Tween(border, "height", Elastic.easeOut, 0, expandedWidth, 25, false);
myTween4.addEventListener(TweenEvent.MOTION_FINISH, presented);
but the second time I tween it to expand the width, the border expands with the width:
myTweenz = new Tween(border, "width", Elastic.easeOut, border.width, slidingWidth, 7, false);
is something wrong with tween?
More Specific Line Thickness Then With LineStyle(#)?
i'm working on a movie and i have a line generated with the lineStyle.moveTo, lineTo commands, but i want this line to get gradually thinner over time and i think you can only specify the thickness in increments of .5 or something like that, which is annoying because it gives you these sudden drastic changes in thickness when your line is relatively thin when using lineStyle(variable,...). does anyone know of any better way to specify line thickness?
How To Add A Linestyle And A Dropshadow To A Dynamically Loaded Image
hi
this is the code that loads them and sets the x and y positions. i need to give these images a border and a dropshadow effect
Code:
for (i=1; i<=num_img; i++) {
_root.imgClip0.duplicateMovieClip("img_"+i, _root.getNextHighestDepth());
eval("_root.img_"+i)._x = sc_width;
eval("_root.img_"+i)._y = sc_height;
}
can anyone help me?
Thanks
How To Add A Linestyle And A Dropshadow To A Dynamically Loaded Image
hi
this is the code that loads them and sets the x and y positions. i need to give these images a border and a dropshadow effect
Code:
for (i=1; i<=num_img; i++) {
_root.imgClip0.duplicateMovieClip("img_"+i, _root.getNextHighestDepth());
eval("_root.img_"+i)._x = sc_width;
eval("_root.img_"+i)._y = sc_height;
}
can anyone help me?
Thanks
Changing Height Of Movie Clip Without Changing Width
Im using flash MX, and i needed to know if it was possible to change the height of a movie clip without changing the width of it. i have a 1px wide line, and i want to change the height of it, but i want to keep it 1px wide. is it possible to do this without having to redraw it everytime i want to change it?
Changing Stage Color When Changing From Scene
Hi,
I would like to change the color of my stage when I get in my next scene, is it possible?
So when people look to the movie Scene one should be black and scene 2 white. Don't tell me to put a big white square at the button of scene 2 coz when put it online I want all my window to change from color.
Thx
_name Property Changing But Not Changing
I am working on an application where a user can select a movieclip that has been dynamically placed on the stage and then choose Send to Front or Send to Back (compared to the other objects on the stage with it).
As part of this process I am renaming the instances using code that basically looks like this: setProperty(myMovieClip, _name, newMovieClipName);
Using the debugger I noticed something unusual. In the properties tab the _name property changes to the newMovieClipName value I am assigning it. But the target it shows remains unchanged (_level0.container_mc.myOldMovieClipName).
I think this is causing problems elsewhere when I try to target these movie clips. Does anyone know how to completely change an instance's name, or is this just the way it works? Any insights are appreciated.
RGB Changing Is Working But Not Changing All The Time
basically when you load the .swf it changed everytime u re-load it , i want it to keep on changing even when the user hasnt reloaded the image
onClipEvent (load) {
for (i=1; i<5; i++) {
_root["r"+i+"New"] = random(255);
_root["g"+i+"New"] = random(255);
_root["b"+i+"New"] = random(255);
_root["b"+i+"New"] = random(255);
}
}
onClipEvent (load) {
myNum = _name;
}
onClipEvent (enterFrame) {
_root["r"+myNum+"Diff"] = _root["r"+myNum+"New"]-_root["r"+myNum+"Old"];
_root["r"+myNum+"Change"] = _root["r"+myNum+"Diff"]/10;
_root["g"+myNum+"Diff"] = _root["g"+myNum+"New"]-_root["g"+myNum+"Old"];
_root["g"+myNum+"Change"] = _root["g"+myNum+"Diff"]/10;
_root["b"+myNum+"Diff"] = _root["b"+myNum+"New"]-_root["b"+myNum+"Old"];
_root["b"+myNum+"Change"] = _root["b"+myNum+"Diff"]/10;
swatchColor = new Color(this);
swatchColor.setRGB(_root["r"+myNum+"Change"]<< 16 | _root["g"+myNum+"Change"] << 8 |
_root["b"+myNum+"Change"]);
_root["r"+myNum+"Old"] -= _root["r"+myNum+"New"]-_root["r"+myNum+"Change"];
_root["g"+myNum+"Old"] -= _root["g"+myNum+"New"]-_root["g"+myNum+"Change"];
_root["b"+myNum+"Old"] -= _root["b"+myNum+"New"]-_root["b"+myNum+"Change"];
}
Changing An Array Name W/o Changing The Content
I have a generated array called foo, now what I would like to do is change the name of the array, without changing the content of the array itself. I am trying to make the name of the array, so it can be made part of a count. Like this.
from foo = ["Room,150,1"]; to T1=["Room,150,1"];
Thank you in advance for any help
Killin
[MX]Clip Changing With OnEnterFrame Not Changing With "setInterval"
Hi,
I have built a simple site where the logo at the top of the page has been constructed as a masked grid, the idea being that the logo is revealed as each cell in the logo has it's color changed.
The color is changed via a tween in each individual cell & I originally triggered this to happen with the following “onEnterFrame” script (newHold_array[k] being the array that holds the clips);
k = 0;
_root.onEnterFrame = function() {
thisOne = newHold_array[k];
this.holdit_mc.nhold_mc[thisOne].play();
k++;
if (k>=353) {
break;
}
};
The above code works fine but I wanted to speed up the rate of change so put a similar function in to a “setInterval” fired script
function lightUp(){
thisOne = newHold_array[k];
trace(thisOne);
this.holdit_mc.nhold_mc[thisOne].play();
k++;
if (k>=353) {
clearInterval(lightInt)
}
}
which although firing ok & able to trace out the correct cell with “trace(thisOne);” will not get the correct or any cell to play?
Fla attached.
Changing Variables Without Changing Them All
lets say I have _root.vehicle = "car-xyz" all throughout a movie
but I want to change all car's to truck's
to read like this: _root.vehicle = "truck-xyz" . Is there a way to do this without going into each script and manually typing truck over the car text?
Can this be done in the start of a movie so that all instances of car turn to truck even if the script still reads vehicle=car?
A little difficult to explain, so let me know if you need more info.
thanks
"Clip Changing With "onEnterFrame" Event Now Not Changing With "setInterval.”
Hi,
I have built a simple site where the logo at the top of the page has been constructed as a masked grid, the idea being that the logo is revealed as each cell in the logo has it's color changed.
The color is changed via a tween in each individual cell & I originally triggered this to happen with the following “onEnterFrame” script (newHold_array[k] being the array that holds the clips);
ActionScript Code:
k = 0;_root.onEnterFrame = function() {thisOne = newHold_array[k];this.holdit_mc.nhold_mc[thisOne].play();k++;if (k>=353) {break;}};
The above code works fine but I wanted to speed up the rate of change so put a similar function in to a “setInterval” fired script
ActionScript Code:
function lightUp(){thisOne = newHold_array[k];trace(thisOne);this.holdit_mc.nhold_mc[thisOne].play();k++;if (k>=353) {clearInterval(lightInt)}}
which although firing ok & able to trace out the correct cell with “trace(thisOne);” will not get the correct or any cell to play?
Fla attached.
FPS Changing...
Hi,
I've got an animation that is set to 12 fps (frames per second).
I had to copy and paste a scene from someone else's animation into mine -- BUT I've come to find that this other animation was set to 30 fps.
What can I do?? My animation has many more scenes...and this is only one scene that I've had to add. It's gonna ruin the entire thing, unless there is something I don't know about.
Any advice?
Thanks!
FPS Changing.
Well I have a little intro, a nice affect with tweens, but very graphicy. It has 12 layers or so with 60 key frames each. And a tween on each. The fps start going from 20 down to 1.6 or so. is there anything I can do? And it's also happened to my friend...I doubt it's my computer....Anyway thanks in advance.
-bb
Please Help (Changing .fla To .swf)
I just finished making a short Flash movie, and when I play it as .fla it all looks fine.
However, when I change it into a .swf file and play it, the
text in the movie looks fuzzy and doesn't show the fading effect at all! Everything is basically screwed up.
I really can't figure out what I did wrong...
Does anyone know what I could do to change the .fla file into
.swf without screwing the movie?
Thank you very much!
Changing
How can you make one movie clip change into another one?
Changing A Sqf
i have a little problem..
if anybody can help me i'll be gratefull
i've made a guestbook that uses a cgi script..
and i've lost the sources... the domain that hosted my site expired.. and now i can't use the guestbook on another site couse i've done the stupid think of writing the absolute adress of the cgi script.. not the relative one..
is there a way of changeing that adress only?
i don't wanna change anything else.. just that adress of the cgi script..
thx a lot to anyone that can help me
Changing MCs'
How do i do this so that when my MC(Kirby) touches another MC(random enemy) Kirby will change into a different MC????
simpler: how do i change an Mc into another one of my choice?
Changing FPS
I'm working on a large, all Flash e-learning site. We're featuring a number of Flash cartoons in the site.....the bulk of the site runs at 30fps...the cartoons are done at 15fps. I've noticed that when the cartoons are loaded, the parent SWF matches the frame rate of the child movies...When a 30fps is loaded back in, the parent movie returns to 30fps. There is not too much motion in the parent movie so it looks OK, but is there any danger in changing the frame rate back and forth like this?
Second question, does anyone know if Flash recognizes fractional frame rates? The site features a lot of video, so the template runs at 29.97fps to match the video.
Thanks in advance!
Larry
Why Does It Keep Changing?
On my screen I have simply drawn a man and every time I turn him into a movie or a graphic it changes all his lines around and makes it look like crap. Why is it doing this and how can i make it stop? Thank you. And I am running FMX04.
MC's Are Changing My Fps
My fps is set to 50 fps and it starts out fine, but then i have about 3 instances of 6 movie clips, and that's when it goes down to 30 and then hovers around 20 fps. They're all necessary so any tips for avoiding this deceleration? Thanks!
Var No Changing
Code:
onClipEvent (load) {
var bdelay = 1;
}
in an mc on the last frame.
Code:
if (bdelay == 0){bdelay = 1};
what am i doing wrong?
Changing CSS
Flash CS3 Pro, AS2...
I have a flash, with a variable known as mySkin, which has 4 values, each the name of a color. Anyway when the user presses buttons it changes the values, while also changing colors of the flash. Anyway I plan to have 4 CSS files made, each slightly different, so that they go with the colors on the flash. I also need it for multiple pages, I've already set up a sharedObject for mySkin.
This means that I need it to communicate between the flash and the website some how. Change which CSS file the website is getting the CSS from when they press the buttons. And also remember for the other pages what has been changed.
I'm new to server side stuff, I have plenty of experiance with CSS and html, some Javascript, but no php or xml or anything like that.
If I need to I can have some friends help me out with those sort of things, they just don't know at all how to write for flash...
|