A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Code not working in Flash 8

  1. #1
    Junior Member
    Join Date
    Nov 2003
    Location
    Sydney
    Posts
    17

    Code not working in Flash 8

    Hi

    I used to have this very simple code below that used to loop my movie clip x times.

    i++;

    if (i == 3) {

    return;

    } else {

    gotoAndPlay(3);

    }

    Since moving to V8 the code no longer works, if i downgrade the file to MX - it appears to work, but then will show the MC (as its video encoded using on2 VP6)

    can someone please help me, im desperate to get this finished today as its part of a project thats going live tomorrow mornig..

    thankss!!

  2. #2
    Flash Gordon McUsher's Avatar
    Join Date
    Mar 2001
    Location
    Krautland
    Posts
    1,560
    you need to initialize a variable first.

    put:

    var i:Number=0;
    before using it for the first Time

  3. #3
    Junior Member
    Join Date
    Nov 2003
    Location
    Sydney
    Posts
    17
    Thanks, that doesnt seem to work though :-(

    Should it be on the first frame... and do i put just the one line.

    ta
    chris

  4. #4
    Flash Gordon McUsher's Avatar
    Join Date
    Mar 2001
    Location
    Krautland
    Posts
    1,560
    Hmm, as you don't post, of what kind your error is, i can just guess.

    Of course that line should be before frame 3, as everytime your flash
    will enter the frame that line is in, it would be set to 0 again...

  5. #5
    Junior Member
    Join Date
    Nov 2003
    Location
    Sydney
    Posts
    17
    hi

    sorry for not being clearer...

    basically i have a movie clip that plays a video.

    on frame 1 i have a preloader
    on frame 2 i have a STOP - and a button to play the video (ie goto frame 3)
    on frame 3 to 375 i have the video
    on frame 376 i have a frame that has the following code:

    i++;

    if (i == 2) {

    return;

    } else {

    gotoAndPlay(3);

    }

    Then on the last frame - 377 - i have a STOP and an end message.

    When I play it, it just loops the video forever. But do not receive an error message.

    I cant help think its related to it being studio 8. Im sure it worked fine before!

  6. #6
    Flash Gordon McUsher's Avatar
    Join Date
    Mar 2001
    Location
    Krautland
    Posts
    1,560
    grmbl.. as i said, you got to initialize the variable first...

    Flash7 had no problems, if it found "++" on an undefined variable,
    it would just guess "ok, the user want me to count this thing one up,
    hmm, i dunno what i is.. well.. i guess it is zero... ". Flash8 is strict now,
    it doesn't know your "i" and will do the following:
    undefined++ = undefined + 1 = undefined
    and that will never equal 2


    Just put var i:Number = 0;
    in your first Frame and there u go..

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