removeChild in Sandy?

All the technical questions concerning the AS3 3.x versions of Sandy.

removeChild in Sandy?

Postby jimmeah » Wed Oct 10, 2007 11:20 am

i cant seem to execute removeChild from my group g

Code: Select all
public function RemoveChildren()
            {
               
               for (var i=0; i<countLvl1; i++)
                  {
                  g.removeChild(myArray[i]);
               }
            }


ReferenceError: Error #1069: Property removeChild not found on sandy.core.scenegraph.Group and there is no default value.
at SimpleMove/RemoveChildren()
at SimpleMove/::enterFrameHandler()
jimmeah
 
Posts: 24
Joined: Sun Oct 07, 2007 5:09 pm
Location: Hyper Island, Sweden

Re: removeChild in Sandy?

Postby kiroukou » Wed Oct 10, 2007 12:04 pm

No there's no removeChild method.

Please refer to the documentation ;)
Image
User avatar
kiroukou
Development Team Leader
Development Team Leader
 
Posts: 1301
Joined: Sun Sep 02, 2007 9:04 am

Re: removeChild in Sandy?

Postby jimmeah » Wed Oct 10, 2007 8:42 pm

ArgumentError: Error #1063: Argument count mismatch on sandy.core.scenegraph::Node/remove(). Expected 0, got 1.
at SimpleMove/RemoveChildren()
at SimpleMove/::enterFrameHandler()


Code: Select all
public function RemoveChildren():void
            {
               
            for (var i=0; i<countLvl1; i++)
                  {
                  g.remove(myArray[i]);
               }

            }

jimmeah
 
Posts: 24
Joined: Sun Oct 07, 2007 5:09 pm
Location: Hyper Island, Sweden

Re: removeChild in Sandy?

Postby Petit » Wed Oct 10, 2007 9:22 pm

HI!

If you look at the documentation, you will see that the remove method() is inherited from the Node class and takes no argument.
It removes the Node ( Group, Shape3D ) that you call the method on.

So if you have a Shape3D called shape1 and you go shape1.remove(), shape1 will be removed, not its eventual children.
" Removes this node from the node tree, saving its child nodes.
NOTE that remove method only remove the current node and NOT its children!
To remove the current node and all its children please refer to the destroy method.
The child nodes of this node becomes child nodes of this node's parent."

There are also methods for removing children, like removeChildByID() and removeChildByName().

Good luck!
/Petit
User avatar
Petit
Support Team Member
Support Team Member
 
Posts: 812
Joined: Sun Sep 02, 2007 11:07 am
Location: Borgholm, Sweden

Re: removeChild in Sandy?

Postby jimmeah » Thu Oct 11, 2007 12:25 am

thanks!

but im still confused, myArray generates sprite2d s like this

Code: Select all
var myArray:Array = new Array([mySprite1, mySprite2, mySprite3, mySprite4, mySprite5]);

for (var i=0; i<countLvl1; i++)
             {
               
            

                var lBmd:BitmapData = new gifBall(0,0) as BitmapData;
                var displayObject:Bitmap = new Bitmap(lBmd);
            
                myArray[i] = new Sprite2D ("Circle" + i, displayObject, 1);           

               degreex += (360/_amount);
               degreey += (360/_amount);
         
               var radianx = (degreex/180)*Math.PI;
               var radiany = (degreey/180)*Math.PI;
             
               myArray[i].x = xcenter+Math.cos(radianx)*radius;
                myArray[i].z = ycenter-Math.sin(radiany)*radius;
            
            myArray[i].scale = 1.2;

                g.addChild(myArray[i]);
               
            
               trace(myArray[i].name + " ry: " + radiany);

             }




so i just can go like myArray[i].remove();?

when i do that, there is no error, but the 2d sprites still appear on stage

next the nodes are able to rotate as you can see in the topic, database generated sprites
but when a certain action occurs, i need new nodes. but when i make the new ones are created, the old ones just stay there and stick...
You do not have the required permissions to view the files attached to this post.
jimmeah
 
Posts: 24
Joined: Sun Oct 07, 2007 5:09 pm
Location: Hyper Island, Sweden

Re: removeChild in Sandy?

Postby kiroukou » Thu Oct 11, 2007 7:21 am

Why don't you simply do :
Code: Select all
public function RemoveChildren():void
            {
               
            for (var i=0; i<countLvl1; i++)
            {
                  (g.myArray[i] as Sprite3D).remove());
               }

            }

should work better.
Image
User avatar
kiroukou
Development Team Leader
Development Team Leader
 
Posts: 1301
Joined: Sun Sep 02, 2007 9:04 am

Re: removeChild in Sandy?

Postby jimmeah » Thu Oct 11, 2007 7:29 am

doesnt work?

i can send you some FLA and AS if you want to, im currently working over the deadline already, the exhibition already started.


we will thank you 100.000 thousand times if you manage to make it work, and we already thank you 50.000 times for all the help :mrgreen:
You do not have the required permissions to view the files attached to this post.
jimmeah
 
Posts: 24
Joined: Sun Oct 07, 2007 5:09 pm
Location: Hyper Island, Sweden

Re: removeChild in Sandy?

Postby kiroukou » Thu Oct 11, 2007 7:52 am

I'm sorry, I don't have Flash CS3...

I can simply help you with the AS code, but since I can't test it, would not be fast...
Image
User avatar
kiroukou
Development Team Leader
Development Team Leader
 
Posts: 1301
Joined: Sun Sep 02, 2007 9:04 am

Re: removeChild in Sandy?

Postby kiroukou » Thu Oct 11, 2007 8:04 am

Oh!!
I get it :) It is a bug in the RC0. I have fixed it on the svn !

If you can't use the svn version, I'll tell you what to fix!

BTW in your code I see Sprite3D in the removeChildren method. Is it not a Sprite2D ?
Image
User avatar
kiroukou
Development Team Leader
Development Team Leader
 
Posts: 1301
Joined: Sun Sep 02, 2007 9:04 am

Re: removeChild in Sandy?

Postby jimmeah » Thu Oct 11, 2007 8:11 am

can i hit you on msn mail ?

kasper@stijlfigurant.nl for msn
jimmeah
 
Posts: 24
Joined: Sun Oct 07, 2007 5:09 pm
Location: Hyper Island, Sweden

Next

Return to 3.x technical help

Who is online

Users browsing this forum: No registered users and 1 guest