lundi 29 février 2016

remove allchild form class in by coding in the class

Ok, so I've been stuck on this for about three hours now and I finally feel like asking for help. i have 2 classes ( Rcircle and Rrect with x = -20 and they go down ) and 2 MovieClip on stage ( Rcar , Bcar ) . on main timeline , i add Children from 2 classes , when any children hit to object or MovieClip ( Rcar , Bcar ) the problem happen here .. when it go to nextFrame to show game over the child of 2 classes than added to stage after just game over still go down in mainframe

addEventListener(Event.ENTER_FRAME,rundm);
function rundm(e:Event)
{
    recttimer.start();

    if (Rcircle.score ==250)
    {
        recttimer.stop();
        removeEventListener(Event.ENTER_FRAME,rundm);
        gotoAndStop(4);
        while (mycircle.numChildren > 0) 
        {
        mycircle.removeChildAt(0);
        }
        while (myrect.numChildren > 0) 
        {
        myrect.removeChildAt(0);
        }
    }
    rectcount = Math.random()*2+1;
    scoree.text = String(Rcircle.score);
}

in class

function rectmove (e:Event)
            {

                var mysoundChannelPosition:Number = 0; 

                if(hitTestObject(Rcar))
                {
                    if (hit)
                    {
                        mychannel=mysound.play()
                        gotoAndPlay(3);
                        this.visible = false;
                        this.y = -3000;
                        hit=false;
                        MovieClip(parent).gotoAndPlay(3);
                        removeEventListener(Event.ENTER_FRAME,rectmove);
                    }
                }
                else if (hitTestObject(Bcar))
                {
                    if (hit)
                    {
                        mychannel=mysound.play()
                        gotoAndPlay(3);
                        this.visible = false;
                        this.y = -3000;
                        hit=false
                        MovieClip(parent).gotoAndPlay(3);
                        removeEventListener(Event.ENTER_FRAME,rectmove)
                        //mychannel.stop()
                    }
                }

so i hope to help me

Aucun commentaire:

Enregistrer un commentaire