Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default Help with "For" statement..

    Okay, I am an alright Flash user, using Flash 8 (since we only have Flash 7 at school, I thought 8 was okay.)

    Anyway, I have a problem with my code. All what is meant to happen is the line spins for 180 degrees only, but it keeps going.. forever!!

    Here is my code:
    PHP Code:
    onClipEvent (enterFrame) {
            for(
    i=0i<1i++) { 
            
    this._rotation ++;
            
    trace(i);
        }

    And here is the SWF (link)

  2. #2
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    Whats the trace saying?
    Hi, names James. I am a web developer.

  3. #3
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default

    Oh yeah sorry, it just keeps saying "0"

  4. #4
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    Quote Originally Posted by Blinger View Post
    Oh yeah sorry, it just keeps saying "0"
    Is the for, for a smooth rotation?
    else if not ->

    on (release) {
    _root.mcobj._rotation += 180;
    }
    Hi, names James. I am a web developer.

  5. #5
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default

    I want it to go slowly the 180 degrees.. (it will soon be a random number)...

    I have also tried a while statement, but that went too fast

  6. #6
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    Basically the method your doing is rotating it on each frame enter, so its going to be infinite, so a for loop isn't how your going to do it on a frame enter, give me a few minutes and I'll come up with something.
    Hi, names James. I am a web developer.

  7. #7
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default

    How about,


    onClipEvent(load){
    for(i=0; i<1; i++) {
    this._rotation ++;
    trace(i);
    }
    }


    going to try that


    edit: didn't work, the trace only says "0"
    Last edited by Blinger1; 16-07-2008 at 11:59 AM.

  8. #8
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    This will work, add it to a button call the movieclip your rotating mcobj

    Code:
    on (release)
    {
        for ( var i = 0; i <= 180; i++ )
        {
            inter = setInterval( function () { _root.mcobj._rotation++; clearInterval( inter ); }, 25*i );
        }
    }


    http://www.disasterpiece.co.uk/flahabox.fla
    Last edited by Protege; 16-07-2008 at 12:05 PM.
    Hi, names James. I am a web developer.

  9. #9
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default

    Okay that seemed to make it spin!

    Now, how do I make it stop after it reaches 180 degrees?

  10. #10
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    oo forgot :p
    Code:
    on (release)
    {
        rotation = 180;
        for ( var i = 0; i <= 10; i++ )
        {
            var inter = setInterval( function () { if ( !rotation == 0 ) { rotation--; _root.mcobj._rotation+=1; clearInterval( inter );}} , 25*i );
        }
    }
    Last edited by Protege; 16-07-2008 at 12:19 PM.
    Hi, names James. I am a web developer.

Page 1 of 2 12 LastLast

Posting Permissions

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