Jiri, I think Hans's advice will get you what you want.
case RESTRICTION&1 :
tRestrict +="\u0020-\u007E";
trace('all');
break;
case RESTRICTION&2:
tRestrict =" 0-9";
trace('num');
break;
case RESTRICTION&4:
tRestrict =" A-Z a-z";
trace('char');
break;
I think there might be communication confusion.
On Thu, Apr 2, 2009 at 7:44 AM, Jiri <[email protected]> wrote:
> Thanks Hans,
>
> I am aware of that, so if-else would be the only way to go I guess.
>
> Jiri
>
>
>
> Hans Wichman wrote:
>
>> Hi,
>>
>> isn't the absence of break statements messing things up?
>>
>> greetz
>> JC
>>
>> On Thu, Apr 2, 2009 at 12:08 PM, Jiri <[email protected]>
>> wrote:
>>
>> I am new to bitwise operators, so I am trying to learn it.
>>>
>>> I have the following code and it works half. I am using a switch case to
>>> get the result, but this is messing things up. I could revert to and if -
>>> else statement, but I was wondering if there is a more elagant way of
>>> doing
>>> it. I post my code below, and would have some advice.
>>>
>>> var NO_RESTRICTION:int = 1;
>>> var NUM_ONLY:int = 2;
>>> var CHAR_ONLY:int = 4;
>>>
>>> var RESTRICTION:int = NUM_ONLY ;
>>>
>>> function setInputCharRestriction(tInt:int):void {
>>> RESTRICTION = tInt | tInt&2 | tInt&3;
>>> }
>>>
>>> function getRestrict():String{
>>> var tRestrict:String = '';
>>>
>>> trace('all ' , Boolean(RESTRICTION&1))
>>> trace('num ' , Boolean(RESTRICTION&2))
>>> trace('char ' ,Boolean(RESTRICTION&4))
>>>
>>> switch(RESTRICTION){
>>> case RESTRICTION&1 :
>>> tRestrict +="\u0020-\u007E";
>>> trace('all')
>>> case RESTRICTION&2:
>>> tRestrict =" 0-9";
>>> trace('num')
>>> case RESTRICTION&4:
>>> tRestrict =" A-Z a-z";
>>> trace('char')
>>> }
>>> trace('restrict field ' , tRestrict)
>>> return tRestrict;
>>> }
>>>
>>> getRestrict()
>>>
>>> Thank you.
>>>
>>> Jiri
>>> _______________________________________________
>>> Flashcoders mailing list
>>> [email protected]
>>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>
>>> _______________________________________________
>> Flashcoders mailing list
>> [email protected]
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
--
-jonathan howe
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders