First, I am sure there is a smarter way to do this. Would anyone bother to tell me! Secondly and most important: How would I do to draw a line from right to left?
ps: setProperty, though often seen in many tutorials, should not be used anymore. It’s deprecated (ie: future flash players may not know what it means, so don’t bother learning it).
setProperty(“myMC”, _x, 75) can now be replaced by
myMC._x = 75.
And you’ll have to agree that the code looks simpler this way…
Thanks for the answer and I know I can use myMC._x = 75; I didn’t know it was deprecated though. Your code doesn’t solve my question though. My piece of code makes the viewer actually see the line being drawn, you see it grow from left to right (or up to down…). As far as I can see (and that’s why I didn’t make it that way) your square just “pops up”. But since it’s based on a scaling I don’t know how to make the line “grow” backwards (or change the registration point) ie from right to left. maybe I am overlooking how to change my code with the base of the making of a rectangle, because yes, I would like to see a rectangle being drawn at runtime starting from top left continuing clockwise.
Scotty,
thanks for the thread and I am sure it’s probably exactly what I am looking for. Unfortunately I can’t open either of the files(square.fla yours or homePanel.fla). I can download but not open.
If you are getting “unexpected file format” errors then the files are mx2004. If you contact the author and ask really nicely maybe they’ll resave as mx.
Scotty?
Would you have a remedy for this?
I have adapted the code to my needs. Unfortunately the square stops drawing at one point.
I suppose it is because of the way it calculates the distance in relation to the speed. Whatever I do something ends up going wrong. I have tried making multiple mc’s, both 2 that would draw 2 lines each and 4 that would draw 1 line each. I have tried adjusting the if statement so that it won’t contain == for a more “adjustable” condition but nothing really works and I can’t have the square drawn that slowly. (at the moment the swf is at 30fps) My new code:
if (square.markerX>=550 && square.markerY >= 350) {
square.markerX -=20;
As soon as it’s executed once, the statement isn’t true anymore.
Second, try to use a value for increasing/decreasing markerX/Y that’s “compatible” with the values in the if statements, then you can use the “==”.
(with +=20 it will never be exactly 550 or 350, try 10 instead, that will also slow down the drawing)
Yes, that’s what I realize. unfortunately it doesn’t work with 10 either… I guess I’ll just have to keep trying different values or do something different. Thanks anyway!
The weird thing though is that it doesn’t stop at any of the “corners”. When changing to speed 55 for the x drawing and 35 for the y drawing it draws about 70 pixels before it stops. This is actually what happened before too. Why is that?