- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600"
- creationComplete="switchCase1('cyrq'),switchCase2('cyrq')">
- <mx:Script>
- <![CDATA[
- //正确的用法
- private function switchCase1(string:String):void
- {
- switch (string)
- {
- case "cyrq":
- case "ryrq":
- trace("switchCase1=="+string); //正常打印
- break;
- default:
- break;
- }
- }
- //错误的用法(可恶的是,用或者符号|| 页面中也没有语法错误提示 )
- private function switchCase2(string:String):void
- {
- switch (string)
- {
- case "ryrq" || "cyrq":
- trace("switchCase2=="+string); //不能打印
- break;
- default:
- break;
- }
- }
- ]]>
- </mx:Script>
- </mx:Application>