A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: GotoAndSotp number in array.

  1. #1
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976

    GotoAndSotp number in array.

    I have 2 mcs on the stage one is the duplicate of the other so they have the same actions. On the main timeline i have an array.


    number = new Array( 4,2,1,5,7,3,7,6,4);

    on the movieclips i have an if statement that when they reach a certian _y cord for them to gotoAndStop at the next corrorsponding frame according to the array. But instead of going to the next number in the array i want it to move 2 so just say its last number was number[1] which equals 2 the next postition for it to go to is number[1] + 2; which means its next position is number[3] which equals 5. I have tried this over and over but it doesnt seem to work properly it adds 2 to the number[#] instead of moveing 2 in the array can anyone help.

    Thanks in AdvancE

  2. #2
    Jordan Berry
    Join Date
    Oct 2002
    Posts
    307
    Code:
    place+= 2;
    numbers[place];
    The only time u need numbers[var or number + 2]; is when u want to just temp check that number in the array.. But u dont u want a number that u can use the next turn around so u need to use a var.. that is if i got the question right?

    edit: make sure u _root. sence this is on a mc.. Just didnt see it so i thought id add that..
    Last edited by xDrunkCowx; 03-24-2003 at 11:51 PM.
    I'm back.

  3. #3
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    thanks for that, it worked but only works once

  4. #4
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    i doubt if this is the problem but isn't "number" a reserver word (used for a method) in flash?
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  5. #5
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    ignore that i didt it agian and a diff way but thanks ne way for ur help Works now :P

    Wah 800 Posts.

    Yeah it is blink. i was just using number as an example :P

  6. #6
    Senior Member
    Join Date
    Jun 2002
    Location
    Manchester, UK
    Posts
    2,357
    Well put it for everyone else!!

    PHP Code:
    //
    // Initialise vars
    i=0
    number 
    = [421573764]
    //
    // The function
    onEnterFrame = function() {
       
    newFrame number[i]+2
       gotoAndStop
    (newFrame)

    That should be about right???? Changing [i] would affect the positions of the array!
    Last edited by RipX; 03-25-2003 at 04:18 AM.

  7. #7
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Thats what i use but not in a function. I had it working fine but now i muddled with some of the code in the game and its stuffed

    what it does now is

    trak = new Array(1,2,3,4,5,6,7,8,9,10);

    it starts off fine it goes like this 1,2,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10.

    it kind of stuffs up at the end :P but i think i have it worked out.

  8. #8
    Senior Member
    Join Date
    Jun 2002
    Location
    Manchester, UK
    Posts
    2,357
    Yeah probably need to keep it within the array
    PHP Code:
    if(< array.length) {
      
    The code


  9. #9
    Jordan Berry
    Join Date
    Oct 2002
    Posts
    307
    hey,
    so it does work u want it to do taht 1,2,3,3,4,4 thang?
    I'm back.

  10. #10
    Senior Member mbenney's Avatar
    Join Date
    Mar 2001
    Posts
    2,744
    shouldnt it be numbers[i+2]; ? if it was numbers[i]+2 it would take numbers[i] and add two to that value, not pick the array value 2 along from i
    [m]

  11. #11
    Senior Member
    Join Date
    Jun 2002
    Location
    Manchester, UK
    Posts
    2,357
    Originally posted by mbenney
    shouldnt it be numbers[i+2]; ? if it was numbers[i]+2 it would take numbers[i] and add two to that value, not pick the array value 2 along from i
    [m]
    That's right - I thought he wanted to add two to the frame not take contents of the array two ahead!!! That's what happens when you don't read properly and look at his example

    PHP Code:
    //
    // Initialise vars
    i=0
    number 
    = [421573764]
    //
    // The function
    onEnterFrame = function() {
       
    newFrame number[i+2]
         if(
    number.length 2) {
             
    gotoAndStop(newFrame)
         }  

    RipX

  12. #12
    Senior Member
    Join Date
    Jun 2002
    Location
    Manchester, UK
    Posts
    2,357
    You could always just set [i] to 2 but I don't actually know how your implimenting this so it's hard to know what to put in term of code!!

    RipX

  13. #13
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Really appretiate the help. Just fiddling with a old engine for a game i made a while back.

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