Skip to main content
Participant
August 8, 2013
Question

Need help with AS3 script

  • August 8, 2013
  • 5 replies
  • 683 views

Hey there,

iam making a shell game and found the following code on the web but want to remove one shell so that its 3 shells instead of 4. After removing the myBall = 4 on my own the game wont work right anymore, so sometimes the right shell is not the one it is supposed to be.

Can you help me to remove the myBall = 4 while still keep the logic working?

Pastebin Link

nClipEvent (load) {

    stopped = true;

    myCTR = -1;

    w = 0;

}

onClipEvent (enterFrame) {

    if (myCTR<=_parent.ctr && myCTR>=0) {

        if (stopped) {

            w = Math.ceil((random(60)+1)/10);

            if (w == 1) {

                if (myBall == 1) {

                    myBall = 2;

                } else if (myBall == 2) {

                    myBall = 1;

                }

            } else if (w == 2) {

                if (myBall == 3) {

                    myBall = 4;

                } else if (myBall == 4) {

                    myBall = 3;

                }

            } else if (w == 3) {

                if (myBall == 3) {

                    myBall = 2;

                } else if (myBall == 2) {

                    myBall = 3;

                }

            } else if (w == 4) {

                if (myBall == 3) {

                    myBall = 1;

                } else if (myBall == 1) {

                    myBall = 3;

                }

            } else if (w == 5) {

                if (myBall == 2) {

                    myBall = 4;

                } else if (myBall == 4) {

                    myBall = 2;

                }

            } else if (w == 6) {

                w = random(3)+6;

            }

            gotoAndPlay("f"+String(w));

            myCTR++;

            stopped = false;

        }

    } else if (_parent.ctr>4 && myCTR>_parent.ctr) {

        if (_parent._currentframe != 5) {

            if (w == 1) {

                if (myBall == 1) {

                    myBall = 2;

                } else if (myBall == 2) {

                    myBall = 1;

                }

            } else if (w == 2) {

                if (myBall == 3) {

                    myBall = 4;

                } else if (myBall == 4) {

                    myBall = 3;

                }

            } else if (w == 3) {

                if (myBall == 3) {

                    myBall = 2;

                } else if (myBall == 2) {

                    myBall = 3;

                }

            } else if (w == 4) {

                if (myBall == 3) {

                    myBall = 1;

                } else if (myBall == 1) {

                    myBall = 3;

                }

            } else if (w == 5) {

                if (myBall == 2) {

                    myBall = 4;

                } else if (myBall == 4) {

                    myBall = 2;

                }

            }

            _parent.gotoAndStop(5);

            gotoAndStop("guess");

        }

    }

}

This topic is closed to new replies. Start a new post to keep the conversation going.

5 replies

kglad
Community Expert
Community Expert
August 8, 2013

1. that's not as3 code.

2. that's poorly coded as1/as2 code.

you should rewrite that code in as3.

primoetAuthor
Participant
August 8, 2013

ok but i have no clue about coding AS thats why i need help editing what i have so far.

kglad
Community Expert
Community Expert
August 8, 2013

the adobe forums are good places to get help.  ie, anyone can ask a question and, if there are no files to download and not much code to correct, expect a helpful answer.

but asking someone to do your work for you is not as likely.  you may be lucky and find someone that will that, but you'll need to be patient.

if you don't want to wait, you should hire someone to do your project for you.