[Flashcoders] Two for loops and one if statement into one for loop.
Is there a way to edit the code below to be included into just one for loop and would it actually be faster? On a side note any site/book recommendations on how to for this kind of odd sequences.. TIA ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Two for loops and one if statement into one for loop.
The way its currently written, its zero lines of code, I dont think it can get more efficient than that! ;) .m On Mon, Apr 7, 2008 at 11:12 AM, Helmut Granda [EMAIL PROTECTED] wrote: Is there a way to edit the code below to be included into just one for loop and would it actually be faster? On a side note any site/book recommendations on how to for this kind of odd sequences.. TIA ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Re: Two for loops and one if statement into one for loop.
Normally you get unexpected (or expected, depends on how you look at it) results when having two for loops and using the same iterator, for the outher loop try using i, and the inner loop try using j. See what happends :) Cheers Sidney On Apr 7, 2008, at 5:13 PM, Helmut Granda wrote: oh yeah forgot the loop: var defaultSection: Number = 3; var maxSection: Number = 6; for (var i : Number = defaultSection ; i maxSection + 1 ; i ++ ) { trace ( - + i ) ; } if (defaultSection maxSection) { for (var i : Number = 1 ; i defaultSection ; i ++ ) { trace ( - + i ) ; } } On Mon, Apr 7, 2008 at 10:12 AM, Helmut Granda [EMAIL PROTECTED] wrote: Is there a way to edit the code below to be included into just one for loop and would it actually be faster? On a side note any site/book recommendations on how to for this kind of odd sequences.. TIA -- ...helmut ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Two for loops and one if statement into one for loop.
I don't think anything would be faster than having no code to execute ;) You forgot to paste it. On Mon, Apr 7, 2008 at 11:12 AM, Helmut Granda [EMAIL PROTECTED] wrote: Is there a way to edit the code below to be included into just one for loop and would it actually be faster? On a side note any site/book recommendations on how to for this kind of odd sequences.. TIA ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Re: Two for loops and one if statement into one for loop.
oh yeah forgot the loop: var defaultSection: Number = 3; var maxSection: Number = 6; for (var i : Number = defaultSection ; i maxSection + 1 ; i ++ ) { trace ( - + i ) ; } if (defaultSection maxSection) { for (var i : Number = 1 ; i defaultSection ; i ++ ) { trace ( - + i ) ; } } On Mon, Apr 7, 2008 at 10:12 AM, Helmut Granda [EMAIL PROTECTED] wrote: Is there a way to edit the code below to be included into just one for loop and would it actually be faster? On a side note any site/book recommendations on how to for this kind of odd sequences.. TIA -- ...helmut ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Re: Two for loops and one if statement into one for loop.
I suppose you want to act properly if the counter is lower or higher than defaultSection. If so: for (var i:Number = 0; i maxSection; i++) { if (i defaultSection) { trace(lower + i); } else { trace(higher + i); } } If you absolutely want to run the higher part before you run the lower part, you can do some code abuse ;) for (var i:Number = defaultSection; i (maxSection * 2 - defaultSection); i++) { if (i % maxSection = defaultSection) { trace(higher + i % maxSection); } else { trace(lower + i % maxSection); } } Please correct me if that's not what you want On Mon, Apr 7, 2008 at 12:13 PM, Helmut Granda [EMAIL PROTECTED] wrote: oh yeah forgot the loop: var defaultSection: Number = 3; var maxSection: Number = 6; for (var i : Number = defaultSection ; i maxSection + 1 ; i ++ ) { trace ( - + i ) ; } if (defaultSection maxSection) { for (var i : Number = 1 ; i defaultSection ; i ++ ) { trace ( - + i ) ; } } On Mon, Apr 7, 2008 at 10:12 AM, Helmut Granda [EMAIL PROTECTED] wrote: Is there a way to edit the code below to be included into just one for loop and would it actually be faster? On a side note any site/book recommendations on how to for this kind of odd sequences.. TIA -- ...helmut ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] [AS3] deselecting textbox
How easy is it to deselect a textbox when clicking on anything other than the textbox using actionscript? SM ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] [AS3] deselecting textbox
Take a look at the FocusManager class. B. On Mon, Apr 7, 2008 at 9:07 AM, Stuart (FunkDaWeb) [EMAIL PROTECTED] wrote: How easy is it to deselect a textbox when clicking on anything other than the textbox using actionscript? SM ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Re: Two for loops and one if statement into one for loop.
Great.. that is what I was after.. some how I couldn't see it into one for loop. Thanks! On Mon, Apr 7, 2008 at 10:59 AM, Wagner Amaral [EMAIL PROTECTED] wrote: I suppose you want to act properly if the counter is lower or higher than defaultSection. If so: for (var i:Number = 0; i maxSection; i++) { if (i defaultSection) { trace(lower + i); } else { trace(higher + i); } } If you absolutely want to run the higher part before you run the lower part, you can do some code abuse ;) for (var i:Number = defaultSection; i (maxSection * 2 - defaultSection); i++) { if (i % maxSection = defaultSection) { trace(higher + i % maxSection); } else { trace(lower + i % maxSection); } } Please correct me if that's not what you want On Mon, Apr 7, 2008 at 12:13 PM, Helmut Granda [EMAIL PROTECTED] wrote: oh yeah forgot the loop: var defaultSection: Number = 3; var maxSection: Number = 6; for (var i : Number = defaultSection ; i maxSection + 1 ; i ++ ) { trace ( - + i ) ; } if (defaultSection maxSection) { for (var i : Number = 1 ; i defaultSection ; i ++ ) { trace ( - + i ) ; } } On Mon, Apr 7, 2008 at 10:12 AM, Helmut Granda [EMAIL PROTECTED] wrote: Is there a way to edit the code below to be included into just one for loop and would it actually be faster? On a side note any site/book recommendations on how to for this kind of odd sequences.. TIA -- ...helmut ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- ...helmut ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Re: Two for loops and one if statement into one for loop.
Your if statement is pointless because defaultSection is ALWAYS less than maxSection because you're not altering either of those variables. That being said, this is much faster: var defaultSection:int = 3; var maxSection:int = 6; var i:int = maxSection + 1; var j:int = defaultSection; while (i--) { trace( - + i ); if (defaultSection maxSection) { while (j--) { trace( - + j); } } } Helmut Granda wrote: oh yeah forgot the loop: var defaultSection: Number = 3; var maxSection: Number = 6; for (var i : Number = defaultSection ; i maxSection + 1 ; i ++ ) { trace ( - + i ) ; } if (defaultSection maxSection) { for (var i : Number = 1 ; i defaultSection ; i ++ ) { trace ( - + i ) ; } } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Re: Two for loops and one if statement into one for loop.
Well Steven, your code would enter into an infinite loop. It would trace the first i, then the if will be true, and it will loop till j is false (reaches zero). Then while(i--) runs again, the if will be true again, and the while(j--) will run forever, since j will start at -1, which is true. (Actually not forever, since eventually an int will overflow and become false again...) On Mon, Apr 7, 2008 at 2:05 PM, Steven Sacks [EMAIL PROTECTED] wrote: Your if statement is pointless because defaultSection is ALWAYS less than maxSection because you're not altering either of those variables. That being said, this is much faster: var defaultSection:int = 3; var maxSection:int = 6; var i:int = maxSection + 1; var j:int = defaultSection; while (i--) { trace( - + i ); if (defaultSection maxSection) { while (j--) { trace( - + j); } } } Helmut Granda wrote: oh yeah forgot the loop: var defaultSection: Number = 3; var maxSection: Number = 6; for (var i : Number = defaultSection ; i maxSection + 1 ; i ++ ) { trace ( - + i ) ; } if (defaultSection maxSection) { for (var i : Number = 1 ; i defaultSection ; i ++ ) { trace ( - + i ) ; } } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Re: Two for loops and one if statement into one for loop.
Right. I should have set j inside in the if statement each time. var defaultSection:int = 3; var maxSection:int = 6; var i:int = maxSection + 1; var j:int; while (i--) { trace( i = + i ); if (defaultSection maxSection) { j = defaultSection; while (j--) { trace( j = + j); } } } However, somebody managed to suss out what Helmut was really trying to achieve. Their second example, however, was the exact opposite of what Helmut wanted, which was an efficient loop. Doing any kind of math or function call in the comparison function of a loop is the polar opposite of efficiency. ;) ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Re: Two for loops and one if statement into one for loop.
On Mon, Apr 7, 2008 at 2:49 PM, Steven Sacks [EMAIL PROTECTED] wrote: Doing any kind of math or function call in the comparison function of a loop is the polar opposite of efficiency. ;) Very true! I Missed the efficient part of the question, oops! Here's the best I've got so far (according to flasm): var defaultSection:Number = 3; var maxSection:Number = 6; var i:Number = maxSection + 1; while(--i) { if (i defaultSection) { trace(lower + i); } else { trace(higher + i); } } This, of course, supposing he doesn't care about the order of execution. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] possible reasons for crash on compile in flashcs3?
What might be some possible reasons why the flash IDE crashes on compile? The problem is that it doesn't crash EACH time, just once in a blue. This just started though recently when i took an item that was a class (the path was: landingpage.modules.browser.BrowserContainer), and broke it into a subclass of a GenericBrowser class (the path was: utils.browser.GenericBrowserContainer)... Suddenly it crashes, usually on the second compile, it's pretty frustrating even though i save often so i have no lost any data. What might be some possible things that could be causing this crash? Maybe something to do with variable names? The subclass has to do it's own imports even if the super class imports those same classes right? (I'm just trying to rule out EVERYTHING since its kind of becoming annoying at this point). Anyone have any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders