A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Problems with loops

  1. #1
    Junior Member
    Join Date
    Dec 2002
    Location
    _root.home.room.chair
    Posts
    23

    Problems with loops

    Hi.

    I'm having some problems with the for loop. For some reason it's saying that the code is making the movie unresponsive but it only has to loop twice. Any ideas what's wrong with this?

    onClipEvent(load) {
    for(i=0;i<=1;i++) {
    this.duplicateMovieClip("ground","ground"+i,i);
    _root["ground"+i]._x = ground._x + ground._width;
    }
    }
    onClipEvent(enterFrame) {
    this._x -= 20;
    }


    Thanks


  2. #2

  3. #3
    avatar free
    Join Date
    Jul 2002
    Location
    UK
    Posts
    835
    mbenney
    what's that got to do with anything? Beside's he said he wanted it to loop twice, but that will only loop once...

    CTT_Mustapha
    Sorry this isn't any help, i'm stumped why it would cause your movie to crash. But how do you know this is the code that is causeing it? Is this the only code in the movie or something? When i make a movie that crashes it never tells me which bit is causing it... could you explain a bit more perhaps?
    jonmack
    flash racer blog - advanced arcade racer development blog

  4. #4
    avatar free
    Join Date
    Jul 2002
    Location
    UK
    Posts
    835
    OK i just had a quick mess around... are you putting that code on the mc "ground"?

    If so, i know why it'll crash. You copy it.. it fires it's onLoadEvent, which copies it, which fires it's onLoadEvent, which copies it.... Get the idea? El Infinite Loopo.

    You'll have to duplicate that movie someplace else...
    jonmack
    flash racer blog - advanced arcade racer development blog

  5. #5
    Junior Member
    Join Date
    Dec 2002
    Location
    _root.home.room.chair
    Posts
    23
    OK i just had a quick mess around... are you putting that code on the mc "ground"?

    If so, i know why it'll crash. You copy it.. it fires it's onLoadEvent, which copies it, which fires it's onLoadEvent, which copies it.... Get the idea? El Infinite Loopo.

    You'll have to duplicate that movie someplace else...
    Ah, that'd be it. I hadn't thought of that.

    Thanks a lot


  6. #6
    Senior Member mbenney's Avatar
    Join Date
    Mar 2001
    Posts
    2,744
    it was my only idea at the time! i only ever use < or > in a loop so it was a guess as for the solution, well spotted jon

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