Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 01-19-2010, 03:32 PM   #1
Nugget89
Thomas
 
Join Date: Oct 2009
Location: Ireland
Posts: 10
Default Resize Sprite

Hi, I'm trying to create a slider which will control the radius of a sprite I've created. This is the code I have so far:

var aura:Slider = new Slider();
aura.liveDragging = false;
aura.setSize(120,20);
aura.maximum = 100;
aura.minimum = 0;
aura.snapInterval = 1;
aura.value=50;
aura.x = 335;
aura.y = 615;

addChild(aura);

var circle:Sprite = new Sprite();
var circleradius:Number = aura.value;

circle.graphics.lineStyle(3, 0x000000, 1);
circle.graphics.beginGradientFill(fillType, colors, alphas, ratios, matr, spreadMethod);

circle.graphics.drawCircle(stage.stageWidth*.5 - map.width*.5, stage.stageHeight*.5 - map.height*.5, circleradius);

addChild(circle)


This adds my slider, "aura", and the sprite, "circle", and sets the radius to the slider default value, 50.
I'm just wondering what I need to add to this in order for the sprite to change radius each time I move the slider.
I did manage to get the sprite to change size with the slider but it added a new sprite each time.

Thanks in advance,
Thomas.
Nugget89 is offline   Reply With Quote
Old 01-20-2010, 03:18 AM   #2
hafunui
Registered User
 
Join Date: Jan 2010
Location: Canada
Posts: 22
Default

What I usually do is have an enter_frame function continually redraw my object

ActionScript Code:
myClip.addEventListener(Event.ENTER_FRAME, changeSize); function changeSize():void {     myClip.graphics.clear(); //we clear the graphics then redraw everything     myClip.graphics.lineStyle(1,0x000000); //you'll have to set linestyle again         //rest of drawing function here     }
hafunui is offline   Reply With Quote
Old 01-20-2010, 11:37 PM   #3
Nugget89
Thomas
 
Join Date: Oct 2009
Location: Ireland
Posts: 10
Default

Thanks a million. Got it working perfectly, really appreciate that.
Nugget89 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:15 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.