A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Noted about Array speeds...

  1. #1
    Senior Member SirN's Avatar
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    142

    Noted about Array speeds...

    For anyone interested in checking out the time it takes for a flash to create an array consisting of 8000 numbers and then transferring those numbers to another array (8000 array twice that is) you can visit:

    http://www.sdax.se/travsidan/kjellboy1.htm

    Instructions:
    1. Put 99 in all editboxes
    2. tick all boxes green next to the numbers
    3. Input 1 instead of 35 down where it sais vildhet %
    4. Press the button 'Slumpa...' and then it starts - when you see the 3 numbers picked as winner runner up and third place finisher then it is done.

    To me it is a long time (13 seconds)!
    Last edited by SirN; 02-15-2010 at 02:37 AM.

  2. #2
    Member
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    76
    Maybe you should think of another concept to calculate the result. It's really helpful not to let the program do everything on a single frame. Then the users browser won't begin to lag (as Firefox did on my netbook...)

    If you need further help with this, let me know.

  3. #3
    Senior Member SirN's Avatar
    Join Date
    Apr 2003
    Location
    Sweden
    Posts
    142
    Yes, I have given it some thoughts, but this is the way I have achieved my objective - and I'm sure that there would be possible to do more effective code.

    But I don't know about the array's. There is at maximum 15 horses in an swedish trotting race (which there can be betting on), and I need random to pick the winner of the race and I want the random pick to be affected by the 4 inputs made to each horse( e/k/placefinish and wildness)...

    If there is a way to make the input 99 99 checked and wildness 35 greater than 50 50 checked and wildness 35 and a way for a random pick to be more likely to pick the first (99 one) then I am interested hearing about it! My solution is to (roughly speaking) fill an array with 99 spots of the first one and 50 spots of the other one and let a random pick do it from that array - and it is never a question of more than (roughly speaking again) 1000 spots in the array in an realistic use of the application - soo it never takes much more than an second or two for the whole proccess to happen in an realistic example.

    I was just letting you know that 99 in all fields and everything checked and with wildness at 1 creates an array consisting of 8000 spots which is transferred over to another array - and letting you know that this is the time it takes for that .

    My programming right now looks like this:
    Code:
    if (fas2 == 99)
    			{
    			platsjustering = 150;
    				}
    		else if (fas2 == 98)
    			{
    			platsjustering = 148;
    				}
    		else if (fas2 == 97)
    			{
    			platsjustering = 146;
    				}
    		else if (fas2 == 96)
    			{
    			platsjustering = 144;
    				}
    		else if (fas2 == 95)
    			{
    			platsjustering = 140;
    				}
    and that written out 99 times with different *platsjustering and I think that an array with the *platsjustering numbers and a way to just pick the right one based on what *fas2 is - that would be better code...

    This is just one example and several times in my code I make this bad code....
    Last edited by SirN; 02-17-2010 at 10:28 AM. Reason: Adding code example

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