[Flashcoders] bitwise question

2009-09-15 Thread Jiri
When i have a 8 bit int where only one of the bit can be 1, what is then the quickest way to get that bit position with value 1? Now I use this. function getBit():int{ var tCount:int = 0; for (var i:int=0; i 8; i++) { if

Re: [Flashcoders] bitwise question

2009-09-15 Thread Hans Wichman
Hey, not sure if it's faster, but this would work as well: var i:Number = 32; trace (Math.log(i)/Math.LN2); returns bit number 5. Lookuptable might be faster in this case. greetz JC On Tue, Sep 15, 2009 at 10:04 AM, Jiri jiriheitla...@googlemail.com wrote: When i have a 8 bit int where only

Re: [Flashcoders] bitwise question

2009-09-15 Thread Paul Andrews
Jiri wrote: When i have a 8 bit int where only one of the bit can be 1, what is then the quickest way to get that bit position with value 1? Now I use this. function getBit():int{ var tCount:int = 0; for (var i:int=0; i 8; i++) { if (8 (1 i))return

Re: [Flashcoders] bitwise question

2009-09-15 Thread Paul Andrews
Paul Andrews wrote: Jiri wrote: When i have a 8 bit int where only one of the bit can be 1, what is then the quickest way to get that bit position with value 1? Now I use this. function getBit():int{ var tCount:int = 0; for (var i:int=0; i 8; i++) { if

Re: [Flashcoders] closures

2009-09-15 Thread Steven Sacks
AS3 is based entirely on closures. Not sure what you mean by it being an option. Anthony Pace wrote: I was wondering if anyone here uses closures in AS3? I like them a ton; yet, I am wondering if they are ever used in a real world development projects in AS3? Can you see an excuse for using

Re: [Flashcoders] bitwise question

2009-09-15 Thread Jiri
Thnx, i tought that there would be some kind of smart bitwise operation to do that. This will do fine. Cheers. Jiri Paul Andrews wrote: Paul Andrews wrote: Jiri wrote: When i have a 8 bit int where only one of the bit can be 1, what is then the quickest way to get that bit position with

Re: [Flashcoders] bitwise question

2009-09-15 Thread Juan Pablo Califano
Another option: function test(value:int):int { // just to be safe... value = value 0xff; switch(value) { case 0x01: return 0; case 0x02: return 1; case 0x04: return 2; case 0x08: return 3; case 0x10: return 4; case 0x20: return 5; case 0x40: return 6; case 0x80: return

Re: [Flashcoders] bitwise question

2009-09-15 Thread Paul Andrews
Juan Pablo Califano wrote: Another option: function test(value:int):int { // just to be safe... value = value 0xff; switch(value) { case 0x01: return 0; case 0x02: return 1; case 0x04: return 2; case 0x08: return 3; case 0x10: return 4; case 0x20: return 5; case 0x40:

Re: [Flashcoders] PHP Socket Question

2009-09-15 Thread mike donnelly
Er, doesn't Flash Media Server do exactly what you want to do? I recommend Influxis hosting, pretty cheap FMS hosting and they're super developer friendly. You have to learn a bit of arcane server-side actionscript. It's actionscript 1, yurrk, with a weird API for manipulating sockets and server

Re: [Flashcoders] bitwise question

2009-09-15 Thread John McCormack
Jiri, I haven't done much bit twiddling yet in AS3 but I think you were fast already, but your i was being incremented and shifted. Also i8 would only get you bits 2,1,0 In binary that would be i1000 How about: function getBit(var numb:int):int { var bit:int=1; var count:int=0; if

Re: [Flashcoders] closures

2009-09-15 Thread Anthony Pace
JS style Function scope instead of classical oop. Steven Sacks wrote: AS3 is based entirely on closures. Not sure what you mean by it being an option. Anthony Pace wrote: I was wondering if anyone here uses closures in AS3? I like them a ton; yet, I am wondering if they are ever used in a

Re: [Flashcoders] bitwise question

2009-09-15 Thread Glen Pike
I think his i 8 was valid as the i is used for the shift, not the value... The only thing that might be faster is using i-- rather than i++ - for some reason decrementing through a loop is suppsoed to be faster. Glen :) John McCormack wrote: Jiri, I haven't done much bit twiddling yet in

[Flashcoders] RegExp vs. CDATA in E4X

2009-09-15 Thread Mendelsohn, Michael
Hi list... I'm debating using a RegExp to search for a value in E4X, or do it by searching the below data within CDATA. I think the RegEx would be cooler to use, making for a smaller XML file, but I wonder if it would be faster to simply loop through an array of these values. Anyone have any

Re: [Flashcoders] closures

2009-09-15 Thread Glen Pike
You mean like button.onRelease = function() { trace(hello from + this); obviously not in AS3, you would have to write few more lines... I guess it's okay as long as it works and does what you want along with the hope that you can easily fix it when it breaks in the latest browser 6 months

Re: [Flashcoders] bitwise question

2009-09-15 Thread John McCormack
It's a little curious loop! i=0 i shifted = 0 i++ gives = 1 binary 0001 i shifted = 2 binary 0010 i++ gives i=3 binary 0011 i shifted=6 binary 0110 i++ gives i= 7 binary 0111 i shifted=14 binary 1110 End of loop because i=8 i++ gives i= 15 binary

RE: [Flashcoders] closures

2009-09-15 Thread Merrill, Jason
JS style Function scope instead of classical oop. You mean like button.onRelease = function() { trace(hello from + this); (I know that was said tongue in cheek, so this is not a criticism...) that's going back to AS1/AS2 anonymous functions - why would anyone in their right mind, unless they

Re: [Flashcoders] closures

2009-09-15 Thread Glen Pike
Hi, I was sort off slightly off the mark with my example, but having read up on function closures in AS3 I can sort of see what Anthony means... From what I gather, Function Closures in AS3 are any functions / methods, but people generally mean functions outside of classes when they

Re: [Flashcoders] RegExp vs. CDATA in E4X

2009-09-15 Thread Steven Sacks
You, sir, are a victim of premature optimization. Write it the easy way. If it proves to be a bottleneck later, optimize it then. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

RE: [Flashcoders] RegExp vs. CDATA in E4X

2009-09-15 Thread Mendelsohn, Michael
Will do, sage advice. - MM Write it the easy way. If it proves to be a bottleneck later, optimize it then. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Re: [Flashcoders] bitwise question

2009-09-15 Thread Jiri
Can't confirm your findings right now, and also wonder which loop you are talking about. My initially posted one? function getBit():int{ var tCount:int = 0; for (var i:int=0; i 8; i++) { if (8 (1 i))return i; } return 0;

Re: [Flashcoders] bitwise question

2009-09-15 Thread Jiri
Cheers. Jiri Paul Andrews wrote: Juan Pablo Califano wrote: Another option: function test(value:int):int { // just to be safe... value = value 0xff; switch(value) { case 0x01: return 0; case 0x02: return 1; case 0x04: return 2; case 0x08: return 3; case 0x10: return 4;

[Flashcoders] help. mouseEvent doesn´t work o n SWF loaded with JavaScript.

2009-09-15 Thread Isaac Alves
solved !! xml problem... thanks . ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

[Flashcoders] RE: Re: time based smooth animation w/ GTween. HELP! (Jack Doyle)

2009-09-15 Thread Isaac Alves
Hi Jack, Thank you for the explanations. I've been gradually changing to TweenLite TweenMax, and so far I'm very happy with it, I've achieved good results with the filter tween and color matrix. yoyo's really cool too. About that other situation, I was trying to have a time-based tween