LOADING
Loading
Hi , welcome back.
LogoutLOGOUT
 
  Lost password?  
Hi
 




 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-20-2008, 02:17 PM
clem_c_rock clem_c_rock is offline
Registered User
 
Join Date: Jul 2004
Posts: 60
Rep Power: 9
clem_c_rock is on a distinguished road
Nested Shapes vs. Nested Sprites in AS 3.0

Nested Shapes vs. Nested Sprites in AS 3.0

Hello,
I'm trying to learn Actionscript 3.0 from the ground up. I am trying to figure out why I can't create nested shape objects in the manner that's demonstrated below w/ Sprite objects.

var container:Shape = new Shape();


When I change the below from a Sprite to a Shape I get this error:

"Call to a possibly undefined method addChild through a reference with static type flash.display:Shape."


var container:Sprite = new Sprite();
container.graphics.lineStyle(0,0xFF6600);
container.graphics.beginFill(0xFF3300);
container.graphics.moveTo(0, 0); // start line @ 10._x and 0 Y
container.graphics.lineTo(100, 0); // move to left 65 x and 0 y
container.graphics.lineTo(100, 100); // from 65 x to 20 y
container.graphics.lineTo(0,100); // 0 x to 20 y

this.addChild(container);
container.x = 140;
container.y = 140;


var box_1:Sprite = new Sprite();
box_1.graphics.lineStyle(0,0xFFFFCC);
box_1.graphics.beginFill(0xFFFF00);
box_1.graphics.moveTo(0, 0); // start line @ 10._x and 0 Y
box_1.graphics.lineTo(80, 0); // move to left 65 x and 0 y
box_1.graphics.lineTo(80, 80); // from 65 x to 20 y
box_1.graphics.lineTo(0,80); // 0 x to 20 y

container.addChild(box_1);
box_1.x = 10;
box_1.y = 10;

var box_2:Sprite = new Sprite();
box_2.graphics.lineStyle(0,0x92E9FE);
box_2.graphics.beginFill(0x92E9FE);
box_2.graphics.moveTo(0, 0); // start line @ 10._x and 0 Y
box_2.graphics.lineTo(60, 0); // move to left 65 x and 0 y
box_2.graphics.lineTo(60, 60); // from 65 x to 20 y
box_2.graphics.lineTo(0,60); // 0 x to 20 y

box_1.addChild(box_2);
box_2.x = 10;
box_2.y = 10;

Thanks,
Eric

Last edited by clem_c_rock : 05-20-2008 at 03:31 PM
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
eventhandling for nested movie clips |_vanishing of runtime shapes while scaling tbuer Actionscript 2.0 1 11-26-2004 07:14 PM




All times are GMT. The time now is 07:54 AM.