Share Posted July 17, 2008 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 More sharing options...
Share Posted July 17, 2008 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 More sharing options...
Author Share Posted July 17, 2008 thanx I'll give it go. Link to comment Share on other sites More sharing options...
Author Share Posted July 17, 2008 that seems to work but I have another question. Can I do the tweens sequentially and how is this done? Link to comment Share on other sites More sharing options...
Share Posted July 17, 2008 Can I do the tweens sequentially and how is this done? Sure. Look at the documentation for the sequence() and multiSequence() functions. Example: TweenMax.multiSequence([ {target:mc1, time:1, x:300, y:100}, {target:mc2, time:2.5, scaleX:2, autoAlpha:0} ]); Documentation is at www.TweenMax.com Link to comment Share on other sites More sharing options...
Author Share Posted July 17, 2008 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 More sharing options...
Author Share Posted July 17, 2008 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 More sharing options...
Share Posted July 18, 2008 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 More sharing options...
Share Posted July 25, 2009 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now