This is G o o g l e's cache of http://www.flashsandy.org/forum/index.php?act=Print&client=printer&f=17&t=397 as retrieved on 1 Aug 2007 10:26:53 GMT.
G o o g l e's cache is the snapshot that we took of the page as we crawled the web.
The page may have changed since that time. Click here for the current page without highlighting.
This cached page may reference images which are no longer available. Click here for the cached text only.
To link to or bookmark this page, use the following url: http://www.google.com/search?q=cache:_fMZPz4ewtkJ:www.flashsandy.org/forum/index.php%3Fact%3DPrint%26client%3Dprinter%26f%3D17%26t%3D397+act%3DPrint+%22index+php%22+-lofiversion+site:www.flashsandy.org&hl=en&ct=clnk&cd=51


Google is neither affiliated with the authors of this page nor responsible for its content.
These terms only appear in links pointing to this page: act print index php

Printable Version of Topic

Click here to view this topic in its original format

Sandy's Forum _ AS2 1.x versions _ removing a child from a transform group

Posted by: kyuzo Mar 22 2007, 01:29 PM

hi

my scene contains 2 objects; i want to aply a transformation on each when i click on them; so i use a transform group on wich i add the selected object as a child, and remove the other object (the previously selected one). removeChild() doesnt seem to work for me, and the tranformation gets aplied to the both spheres.

here's some code, hopefuly easier to understand than my english smile.gif

CODE

import sandy.view.Camera3D;
import sandy.core.World3D;
import sandy.primitive.*;
import sandy.core.data.*;
import sandy.core.group.Group;
import sandy.core.transform.*;
import sandy.core.group.TransformGroup;
import sandy.util.Ease;
import sandy.events.*;
import sandy.core.*;
import sandy.math.*;

class Main{
    
    var tg:TransformGroup;
    
    public function Main(){
        
        tg=new TransformGroup();
        
        var camera:Camera3D=new Camera3D(600,600);
        camera.setPosition(-50,50,-150);
        camera.lookAt(0,30,0);
        World3D.getInstance().setCamera(camera);
        var root:Group=new Group();
        
        var tg1:TransformGroup=new TransformGroup();
        var c1:Sphere=new Sphere(3,3);
        c1.enableEvents(true);
        tg1.addChild(c1);
        c1.addEventListener(ObjectEvent.onPressEVENT,this,onClick);

        var tg2:TransformGroup=new TransformGroup();
        var t2:Transform3D=new Transform3D();
        t2.translate(-30,0,20);
        tg2.setTransform(t2);
        var c2:Sphere=new Sphere(3,3);
        c2.enableEvents(true);
        tg2.addChild(c2);
        c2.addEventListener(ObjectEvent.onPressEVENT,this,onClick);

        root.addChild(tg1);
        root.addChild(tg2);
        root.addChild(tg);

        World3D.getInstance().setRootGroup(root);
        World3D.getInstance().render();
        
    }
    
    public function onClick(e:ObjectEvent){
        var c:Box=e.getTarget();
        tg.removeChild(c.getId()); //what should i use here?
        var ease:Ease=new Ease();
        var ri:RotationInterpolator=new RotationInterpolator(ease.create(),20,0,35);
        ri.setAxisOfRotation(new Vector(0,1,0));
        var ti1:PositionInterpolator=new PositionInterpolator(ease.create(),20,new Vector(0,0,0),new Vector(30,50,20));
        var s:Sequence3D=new Sequence3D();
        s.addChild(ri);
        s.addChild(ti1);        
        tg.addChild(c.getParent());        
        tg.setTransform(s);        
    }
    
    static function main(){
        var main=new Main();
    }
    
}



http://tcornel.googlepages.com/sandy1.swf

i would appreciate any help.
thank you.

Posted by: kiroukou Mar 22 2007, 02:19 PM

Hi,
I think someone else did notice that problem too.
As far as I remember, it was a stupid bug in the remove method of the Node class.

I've to say that I don't remember everything since I'm in the new version for a while already smile.gif
Maybe you can give it a look. Otherwise I'll do that, and update the svn with the fixed problem.

Thanks for the report.

Posted by: kyuzo Mar 22 2007, 08:09 PM

hi

looks like the removeChild method expect the children to have successive id's, beginning with 0, which doesnt happens.
instead of tg.removeChild() i use tg.getChildList().splice(0), which in my case get the job done. i'll use this hack for now.
thanks for responding.

Posted by: kiroukou Mar 23 2007, 07:41 AM

Ok thanks for your investigation...
I do remember that something wrong was remaining there... I'll note that smile.gif

Thanks

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)