A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: declaring new variables within a switch statement

  1. #1
    destructor
    Join Date
    Aug 2009
    Posts
    38

    declaring new variables within a switch statement

    hello,

    does anyone know if declaring new variables within a switch statement (inside of case: break actually creates new variables inside those switch statements, or are the variable declarations moved to the top of the function when compiled?

    i know that when declaring new variables inside a for or while loop, the compiler declares those variables at the beginning of the function. is it the same for if or switch statements?

  2. #2
    Member
    Join Date
    Oct 2009
    Location
    Ontario
    Posts
    98
    Is this a question of how the compiler works, or whether you'd have access to the newly declared variable within the scope of the function, after the switch-case, for use in returning or for some other purpose?

  3. #3
    destructor
    Join Date
    Aug 2009
    Posts
    38
    i'm wondering how the compiler works... mainly, if i have a huge switch statement full of tons of different cases and each creates a lot of new variables within, does it heavily slow down the main program, or just each separate case branch?

  4. #4
    Member
    Join Date
    Oct 2009
    Location
    Ontario
    Posts
    98
    I'm not much of an engineer when it comes to this type of stuff, so I really can't answer that question. Wish I could help!

    I'm sure someone will come along and take a look eventually and have an answer for you. =)

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