A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [CS3] Need help with an AS2 IF Statement ASAP pls!!!

  1. #1
    Registered User
    Join Date
    May 2008

    [CS3] Need help with an AS2 IF Statement ASAP pls!!!

    Hey guys!

    I'm using Adobe Flash CS3, but using Action Script 2. My problem lies within the AS.
    I've created a mini-interactive game whereby the user catches Pixies that appear from random glowbugs around the stage... Everything works perfectly, in fact my scripting has no errors, but the problem is that my IF statement to see if the game is over (Refer to AS comments "See if game is over"), my flash game never goes to the End scene, it just stops once the counter has finished:

    PHP Code:
    onClipEvent (load) {
    // how much time between the pixies appearing
    timeBetweenPixies 2000;
    // calculating the time until the next Pixie
    nextPixie getTimer() + timeBetweenPixies;
    // set scores to zero
    score 0;
    numPixies 0;

    onClipEvent (enterFrame) {
    // see if it is time for the next pixie
    if (getTimer() >= nextPixie) {
    // shorter wait next time
    timeBetweenPixies -= 20;
    // see if the game is over
    if (timeBetweenPixies 1000) {
    // new pixie
    } else {
    // increase the counter and update score
    _root.showScore score "/" numPixies;
    // loop until a pixie is found that is
                // not in use
    while (true) {
    Pixie Int(Math.random()*10);
                    if (
    _root["Pixie"+Pixie]._currentFrame == 1)                     break;
    Is there an error in the code or am I doing something wrong via the stage?
    My End Scene is called "End" and Frame 1 is called "End", I've checked this a million times over, as well as played around with the miliseconds between pixies appearing and I'm still having no luck at all.
    If you've got *any* ideas pls let me know asap, it needs to be completed for tomorrow!!!


  2. #2
    Getting There! bitsk308's Avatar
    Join Date
    Jul 2000
    Phoenix, AZ
    the .gotoAndPlay() method doesn't support scenes and only takes one parameter, a frame number. You need to use the gotoAndPlay() global function which does allow scenes, but it only operates from the root timeline, so you'll have to put it in a function on the root that your conditional statement can call, unless this onEnterFrame is being applied to the root and not an MC


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center