View Full Version : Trying to draw concentric circles - not working as told
zdvdla
06-08-2007, 10:40 AM
sampleSprite.graphics.lineStyle();
sampleSprite.graphics.drawCircle(100, 100, 50);
sampleSprite.drawCircle(100, 100, 100);
throws an error
1120: Access of undefined property sampleSprite.
sasxa
06-08-2007, 11:18 AM
you have to make sprite b4 you start drawing in it... add
var sampleSprite:Sprite = new Sprite();
// your code
addChild(sampleSprite);
zdvdla
06-09-2007, 06:14 PM
well...I added those lines..
var sampleSprite:Sprite = new Sprite();
sampleSprite.drawCircle.lineStyle();
sampleSprite.drawCircle(100, 100, 50);
addChild(sampleSprite);
I get............................................... ................
Compiler errors
1119: Access of possibly undefined property drawCircle through a reference with static type flash.display:Sprite.
zdvdla
06-09-2007, 06:20 PM
sorry..got cut off...
well...I added those lines..
var sampleSprite:Sprite = new Sprite();
sampleSprite.drawCircle.lineStyle();
sampleSprite.drawCircle(100, 100, 50);
addChild(sampleSprite);
I get............................................... ................
Compiler errors
1119: Access of possibly undefined property drawCircle through a reference with static type flash.display:Sprite.
1061: Call to a possibly undefined method drawCircle through a reference with static type flash.display:Sprite.
zdvdla
06-09-2007, 08:19 PM
Began a new project...
typed in ...................
import flash.display.Graphics;
import flash.display.MovieClip;
var sampleSprite:MovieClip = new MovieClip();
sampleSprite.drawCircle.lineStyle();
sampleSprite.drawCircle(100, 100, 50);
addChild(sampleSprite);
got.....................
Warning: 1060: Migration issue: The method drawCircle is no longer supported. For more information, see the Graphics class..
is this true???
danielgrad
06-09-2007, 08:33 PM
to draw circles you need to use the graphics propery of the movie clip:
var sampleSprite:MovieClip = new MovieClip();
sampleSprite.graphics.drawCircle.lineStyle(1);
sampleSprite.graphics.drawCircle(100, 100, 50);
sampleSprite.graphics.drawCircle(100, 100, 100);
stage.addChild(sampleSprite);
I also added 1 as the line width, otherwise you won't get any line around the circles.
zdvdla
06-09-2007, 10:16 PM
well,
I gave up on that approach, and did it the old Irish way...
built it from the ground up..
not concentric but thats easy enough from here....
function DrawSprite():void
{
graphics.beginFill(0xFFCC00);
graphics.drawCircle(100, 100, 50);
graphics.endFill();
}
DrawSprite();
works fine...thanks for your help though!!
zdvdla
06-09-2007, 10:24 PM
function DrawSprite():void
{
graphics.beginFill(0xFFCC00);
graphics.drawCircle(300, 200, 200);
graphics.endFill();
graphics.beginFill(0x0000FF);
graphics.drawCircle(300, 200, 150);
graphics.endFill();
graphics.beginFill(0xA9A9A9);
graphics.drawCircle(300, 200, 100);
graphics.endFill();
graphics.beginFill(0x8A2BE2);
graphics.drawCircle(300, 200, 50);
graphics.endFill();
}
DrawSprite();
|
vBulletin® v3.8.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.