Jump to content
Search Community

scaling hairloss [SOLVED]

wind_kind test
Moderator Tag

Recommended Posts

Hi

 

Can anybody please tell me what I am doing wrong cause I'm missing something really easy and stupid here.

my sprite doesn't scale like I want it, instead it just tweens to some position off of the stage.

 

I want to do this if it is possible at all.(uploaded swf)

 

this is my code

 

  art.addEventListener(MouseEvent.CLICK, ClickListener)
		photo.addEventListener(MouseEvent.CLICK, ClickListener)
		project.addEventListener(MouseEvent.CLICK, ClickListener)

		function ClickListener(event:MouseEvent):void
		{
			trace("art button clicked")
			var box:Sprite = new Sprite();
			box.graphics.beginFill(0xffffff, 1);
			box.graphics.drawRect(10, 600, 10, 10);
			box.graphics.endFill();
			cont.addChild(box);
			TweenMax.to(box, 1, {scaleY:3});
		}

 

Thanx for any help

Link to comment
Share on other sites

Keep in mind that all scaling occurs from the registration point. You drew your rectangle so that its x/y position is 10, 600. So when it's at a scaleY of 1, your rectangle starts 600 pixels down from the registration point of its parent. Then, when you tween to scaleY of 3, the rectangle will look like it starts out at a y-coordinate of 1800 (600 * 3).

 

You might want to change it so that the graphics rectangle x/y coordinates are zero, but move the entire Sprite's coordinates down 600 pixels. That way, when you scale it, it'll look like the upper left corner is pinned to where it started.

 

Hope that helps.

Link to comment
Share on other sites

awesome!!

 

Thanx a mill.

 

Great job with TweenMax, it's so easy to understand once you get use to it and a little help into the right direction,

(I'm very new to all this, as you can probably tell by now).

 

thanx again

Link to comment
Share on other sites

sorry but I have another one for you.

 

When I draw the box and I use this:

 

box.graphics.lineStyle(1); to get a border, then when I scale the box the border or line scales in width and height as well. Is there a different way

of doing it?

 

function ClickListener(event:MouseEvent):void
		{
			trace("button clicked:" + event.currentTarget);
			var box:Sprite = new Sprite();
			art.useHandCursor = true;
			box.graphics.beginFill(0x000000, 0.8);
			box.graphics.drawRect(0, 0, 10, 10);
			box.graphics.endFill();
			cont.addChild(box);
			TweenMax.multiSequence
			([ 
				{ target:box, time:0.2, y:625 },
				{ target:box, time:0.5, scaleY:12 },
				{ target:box, time:1, x:35, scaleX:95 }
			]);
		} 

 

I'm going to bed now so I won't bother anybody after this one.

 

thanx

Link to comment
Share on other sites

I'd suggest looking at the Flash Help docs on the Graphics.lineStyle() method. I think it's the 5th parameter that you'd want to set to LineScaleMode.NONE if you don't want it to scale.

 

lineStyle(thickness:Number, color:uint = 0, alpha:Number = 1.0, pixelHinting:Boolean = false, scaleMode:String = "normal", caps:String = null, joints:String = null, miterLimit:Number = 3):void
Link to comment
Share on other sites

  • 1 year later...
I'd suggest looking at the Flash Help docs on the Graphics.lineStyle() method. I think it's the 5th parameter that you'd want to set to LineScaleMode.NONE if you don't want it to scale.

 

lineStyle(thickness:Number, color:uint = 0, alpha:Number = 1.0, pixelHinting:Boolean = false, scaleMode:String = "normal", caps:String = null, joints:String = null, miterLimit:Number = 3):void

 

Thanks Jack, this was the answer to my problem scaling problem.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...