Results 1 to 6 of 6

Thread: Wrong line height

  1. #1
    Join Date
    Jul 2006
    Posts
    139
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Wrong line height

    Hello I am having a simple problem

    Code:
    
    	  var rectHeight = 37;
    	  
    	  var rectWidth = 37;
    
    		tmp_big.lineStyle(rectWidth,color_tmp,100,true,"none","square", 1);
    	  	tmp_big.moveTo(0, (rectHeight));
    	  	tmp_big.lineTo(0, (-(rectHeight)));
    	  	tmp_big._x = (Stage.width-1280)+ 640; // Just trying to put the shape in a certain position
    		tmp_big._y = Stage.height/2;  // Change registration point
    The width is perfect when i draw the line but the height is 3 times 37. What am i doing wrong?

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    First, you might want to review the recommended syntax for movieclip.lineStyle

    Second, I think if you change
    Code:
    tmp_big.lineTo(0, (-(rectHeight)));
    to
    Code:
    tmp_big.lineTo(0, 0);
    That might fix it.

  3. #3
    Join Date
    Jul 2006
    Posts
    139
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Thanks Medyman. But if I put this:

    Code:
    		tmp_big.lineStyle(rectWidth, color_tmp, 100);
    	  	tmp_big.moveTo(0, rectHeight);
    	  	tmp_big.lineTo(0,0);
    	  	tmp_big._x = (Stage.width-1280)+ 640;
    		tmp_big._y = Stage.height/2;
    The line comes out round and the height has the same problem. So here is a workaround I did.

    Code:
    	/*	tmp_big.lineStyle(1,color_tmp,100,true,"none","square");
    		tmp_big.beginFill(color_tmp, 100);
    		tmp_big.moveTo(0, 0);
    		tmp_big.lineTo(0, rectHeight);
    		tmp_big.lineTo(rectWidth, rectHeight);
    		tmp_big.lineTo(rectWidth,0);
    		tmp_big.lineTo(0,0);
    		tmp_big.endFill();
    	  	tmp_big._x = ((Stage.width-1280)+ 640) - (rectHeight/2);
    		tmp_big._y = (Stage.height/2) - (rectWidth/2);
    The problem with this is that the registration point os no longer middle. Is there a reason ?

    Please help.

  4. #4
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    What is it that you're going for? A 37x37 square?

  5. #5
    Join Date
    Jul 2006
    Posts
    139
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Well the thing is I will give it a certain number for height and width and the registration point should be in the middle. I t could be a square or rectangle.

  6. #6
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Ahh, I see...

    Well, the registration point of any movieclip that is created dynamically will always be in the upper left hand corner. You can't change the registration point with ActionScript.

    You can, of course, change a movieclip's position to mimic the behavior of something that has a registratin point in the center. To do this you would need to create a container around the rectangle/square. Then you'll align the center of the rectangle/square to the upper left hand corner of the container movieclip.

    The commented out actions will center the container on the stage.

    Code:
    var rectHeight:Number = 120;
    var rectWidth:Number = 300;
    
    var container:MovieClip = this.createEmptyMovieClip("container", this.getNextHighestDepth());
    var r:MovieClip = container.createEmptyMovieClip("rectangle", container.getNextHighestDepth());
    r.beginFill(0xee0000, 100);
    r.moveTo(0, 0);
    r.lineTo(rectWidth, 0);
    r.lineTo(rectWidth, rectHeight);
    r.lineTo(0, rectHeight);
    r.endFill();
    
    r._x = -r._width/2
    r._y = -r._height/2
    
    // Centers the container on the stage.
    // container._x = Stage.width/2;
    // container._y = Stage.height/2;

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •