A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: recursion

  1. #1
    Senior Member
    Join Date
    Sep 2000
    Posts
    252

    recursion

    Hey. I'm trying to do some pathfinding with flash. I think i figured out a way to do pathfinding using recursive functions but the problem is flash will stop after 256 recursions, is there any way i can increase the maximum number of recursions?

    Thanks

  2. #2
    Untitled-1.fla strille's Avatar
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    1,626
    No, you cannot increase the maximum number of recursions. You could send in a depth variable and check that the recursion does not go beyond the limit. This will at least prevent the flash player from showing the message and disabling action script:
    code:

    recursive(1);

    function recursive(depth) {
    if (depth < 255) {
    trace("depth: " + depth);
    recursive(depth+1);
    }
    }


  3. #3
    Senior Member
    Join Date
    Sep 2000
    Posts
    252
    crap. acutally i need flash to go boyond that, it needs to do a maximum of 3600 recursions
    damn i hate flash, it cant do anything good.

    Thanks anyways

  4. #4
    Ihoss
    Guest
    what do u need such a high number for? cant u do:
    code:

    while (i<60){
    while (p<60){
    //stuff
    }
    }


  5. #5
    Senior Member
    Join Date
    Sep 2000
    Posts
    252
    i need a high number for my path finding script, there are around 3600 tiles to search, so i need about 3600 recursions.

    I'd use loops, but loops are alot slower than recursive functions

  6. #6
    Yes we can tomsamson's Avatar
    Join Date
    Sep 2001
    Location
    Team Titan Secret Lair
    Posts
    4,666
    i´m sure you don´t have the whole map on the screen,so it´d be wiser not to search through the whole map but instead just the tiles on the current screen.
    besides that you can use a method like strille suggested to check if you get close to the critical recursion level limit,if so you can stop the current recursive loop and start a sceond one.
    i think you´re wanting to port a concept like A* for your pathfinder,aren´t you?
    You shouldn´t use A* but a more simple pathfinder concept instead,it might not find the ideal way but it´ll be less processor intensive and will also run better in flash (especially when its about "realtime" pathfinding in action oriented game situastions.
    ).
    I suggest you do a search on pathfinding,there are loads of threads on this topic.

  7. #7
    Senior Member Kirill M.'s Avatar
    Join Date
    May 2002
    Location
    Toronto, Canada
    Posts
    711
    Actually in Flash I believe recursion would be slower. Because in Flash it takes a long time to call a function, so I'm pretty sure a loop would be more efficient in that respect.

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