Join 95,475 Programmers for FREE!. Ask your question and get quick answers from Dream.In.Code experts. There are 978 online right now! We're the #1 programming help community on the internet! Registration is fast and FREE... Join Now!
Ah ok, two more: - positioned at: does it mean the position of the upper left corner, or the center of the rectangle? - rectangle: is this the border of the rectangle, or a filled one? - although looking at the more advanced questions I think you mean the border only.
Haha, looks-like I'm hijacking this thread So another question: In #4 and #5 you write "When pressed and dragged, the side should move and follow the mouse along one axis." Is that the parallel, or the perpendicular axis relative to the dragged side?
I could have done this a bit smarter, but eh.......
also this is centered, just copy and paste into actionscript
CODE
var nSquareWidth:Number = 200; var nSquareHeight:Number = 100; var nStageHeight:Number = 400; var nStageWidth:Number = 550;
var nTop:Number = 0 - (nSquareHeight/2) var nRight:Number = nSquareWidth/2 var nBottom:Number = nSquareHeight/2 var nLeft:Number = 0 -(nSquareHeight/2)
var sColUp:String ="000099" var sColOver:String ="990000" var sColDown:String = "009900"
var nDepth:Number =100;
var mcSquare:MovieClip = this.createEmptyMovieClip("square_mc",100);
Good one... Code works great... and you're right, it can still be simplified. But, a good example of thinking ahead. Part I can be done simply by doing...
.. but you did something I was hoping someone would do and that was to prepare for the next Parts right at the beginning. It may take more time somtimes, but creating "modules" like yours increases productivity and function of the overall project.
Your way is one of two main ways of doing small "modules". There is another way, very similar to a function, but is a bit more flexible
(there are three actually, but the third is a bit more advanced and requires external files and Flash preferences modification.. won't go into it just yet)
Are you attempting parts IV and V?
--------------------
http://www.piosko.hostings.pl I'm starting a company. Need a good name. Keywords: Graphic designer, programmer, websites, australia, poland... Go! ;)
Yea I could have made some classes to handle this but oh well........
im using nDepth to control the depth of the mc's on the stage... this gets around the getNextHighestDepth bug in flash 6
This is very long winded, again could have streamlined alot but here it is.....
Just copy and paste in to actionscript
Note: this also centers the box in the stage
CODE
stop();
var isDown:Boolean = false; var isDragging:Boolean = false; var nSquareWidth:Number = 200; var nSquareHeight:Number = 200; var nStageHeight:Number = 400; var nStageWidth:Number = 550;
var isTop:Boolean = false var isRight:Boolean = false var isBottom:Boolean = false var isLeft:Boolean = false
var nTextFeildLength:Number = 50 var nTextFeildHeight:Number = 20 var nTextFeildSpace:Number = 20
var nTop:Number = 0 - (nSquareHeight/2) var nRight:Number = nSquareWidth/2 var nBottom:Number = nSquareHeight/2 var nLeft:Number = 0 -(nSquareHeight/2)
var sColUp:String ="000099" var sColOver:String ="990000" var sColDown:String = "009900"
var nDepth:Number =100;
var mcSquare:MovieClip = this.createEmptyMovieClip("square_mc",100);
var txtFmt:TextFormat = new TextFormat(); txtFmt.align = "center" mcSquare.topWidth_txt.setTextFormat(txtFmt); mcSquare.bottomWidth_txt.setTextFormat(txtFmt);
#1 - You can't have negative lengths This is simple to fix. Just but a Math.abs() around your values.
#2 - There is a significant delay in redrawing the rectangle when moving a side. The sides that are being resized aren't catching up with the moving side. It may be detail but clients/editors don't accept it and 99% of the time will tell you to fix it.
If you want, fix it.. or move on to Part V and leave it for somebody else to try and fix/simplify your code
Overall, great job.. especially for not using library objects. Two thumbs up.
--------------------
http://www.piosko.hostings.pl I'm starting a company. Need a good name. Keywords: Graphic designer, programmer, websites, australia, poland... Go! ;)