あけましておめでとうございます!
新年あけましておめでとうございます!
本年もどうぞよろしくお願いいたします。
そして、みなさんにとって去年よりもいい年になりますよういちFlash好きとして願ってます。
せっかくなので新年早々のお土産でCocomoアプリを(^−^)
ちょっと年越しをみんなでわいわいしたいなぁって思って作ってみました。
サンプルをいじってくっつけただけなので、そんなに手を加えてないです。
こんな感じ。
http://moeten.info/flex/20081231_cocomoWaiwai/bin-release/main.html
アカウントと部屋番号が必要でっす。
アカウントや部屋についてはこの辺を参考
みんなでわいわいできるのが特徴でっす。
Cocomoならこういったアプリが30分とかでできちゃうのでぜひぜひ。
ソースはこちら
整理してないのできちゃないです(@_@;)
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:rtc="CocomoNameSpace" backgroundGradientColors="[0xffffff,0x999999]" creationComplete="init()"> <mx:Script> <![CDATA[ import com.adobe.rtc.authentication.AdobeHSAuthenticator; import mx.controls.Button; import mx.core.UITextField; import mx.controls.LinkButton; import mx.containers.VBox; import com.adobe.coreUI.controls.CameraUserBar; import com.adobe.rtc.collaboration.WebcamSubscriber; import com.adobe.rtc.messaging.UserRoles; import com.adobe.rtc.events.SharedPropertyEvent; import com.adobe.rtc.events.ConnectSessionEvent; import com.adobe.rtc.events.UserEvent; import com.adobe.rtc.sharedManagers.StreamManager ; import com.adobe.rtc.sharedManagers.descriptors.StreamDescriptor ; import com.adobe.rtc.sharedModel.SharedProperty; private var currentSubscriber:WebcamSubscriber ; private var sharedProperty:SharedProperty ; private function init():void{ } private function onNameInput():void{ myShow.play(); myName.enabled = false; auth.userName = myName.text; cSession.roomURL = myRoom.text; cSession.login(); } private function onCreationComplete():void { myCanvas.visible = false cSession.roomManager.autoPromote = true ; cSession.roomManager.guestsHaveToKnock = false ; sharedProperty = new SharedProperty(); sharedProperty.isSessionDependent = true ; sharedProperty.sharedID = "webcamShare2" ; sharedProperty.connectSession = cSession ; sharedProperty.subscribe(); sharedProperty.addEventListener(SharedPropertyEvent.CHANGE,onChange); cSession.userManager.addEventListener(UserEvent.USER_REMOVE,onUserRemove) } /** * @private */ protected function onUserRemove(p_event:UserEvent):void { if ( sharedProperty.value && p_event.userDescriptor.userID == sharedProperty.value[0]) { sharedProperty.value = [] ; } } /************** * When the main big stream changes, all users can view it via the sharedProperty. * *********************/ private function onChange(p_evt:SharedPropertyEvent):void { if ( currentSubscriber != null ) { clickedContainer.removeChild(currentSubscriber); currentSubscriber.close(); currentSubscriber = null ; } if ( sharedProperty.value == null || sharedProperty.value.length == 0 ) { return ; } currentSubscriber = new WebcamSubscriber(); currentSubscriber.connectSession = cSession ; currentSubscriber.subscribe(); currentSubscriber.webcamPublisher = webCamPub ; currentSubscriber.publisherIDs = sharedProperty.value ; currentSubscriber.addEventListener(UserEvent.USER_BOOTED,onCleared); currentSubscriber.addEventListener(UserEvent.STREAM_CHANGE,onCameraPause); clickedContainer.addChild(currentSubscriber); invalidateDisplayList(); } /************************ * If the big image is stopped, clear it. * ********/ private function onCleared(p_evt:UserEvent):void { if ( cSession.userManager.myUserRole == UserRoles.OWNER ) { sharedProperty.value = [] ; } } /*********** * Clicking on the small image below makes it large. *****/ private function onClick(p_evt:MouseEvent):void { if ( (p_evt.currentTarget is WebcamSubscriber) && !(p_evt.target.parent is CameraUserBar)) { sharedProperty.value = (p_evt.currentTarget as WebcamSubscriber).publisherIDs; } } override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth,unscaledHeight); if ( currentSubscriber ) { currentSubscriber.percentWidth = 100 ; currentSubscriber.percentHeight = 100 ; currentSubscriber.width = 240; currentSubscriber.height = 180; } } /**** * Handler for a user stopping the camera. */ private function onBooted(p_evt:UserEvent):void { if ( (p_evt.currentTarget is WebcamSubscriber) && (p_evt.userDescriptor.userID == cSession.userManager.myUserID || cSession.userManager.myUserRole == UserRoles.OWNER)) { webCamPub.stop(); if ( (p_evt.currentTarget.parent as VBox).getChildAt(1) is Button ){ ((p_evt.currentTarget.parent as VBox).getChildAt(1) as Button).label = "Start" ; } if ( sharedProperty.value && (sharedProperty.value as Array)[0] == p_evt.userDescriptor.userID ) { sharedProperty.value = [] ; } } } /** * Handler for a user pausing the camera. */ protected function onCameraPause(p_evt:UserEvent):void { var userStreams:Array = cSession.streamManager.getStreamsForPublisher(p_evt.userDescriptor.userID,StreamManager.CAMERA_STREAM); if (userStreams.length == 0) { trace("onCameraPause: no userStreams"); return; } for (var i:int = 0; i< userStreams.length ; i++ ) { if (userStreams[i].type == StreamManager.CAMERA_STREAM ) { break; } } var streamDescriptor:StreamDescriptor = userStreams[i]; if ( streamDescriptor.streamPublisherID == cSession.userManager.myUserID ) { cSession.streamManager.pauseStream(StreamManager.CAMERA_STREAM,!streamDescriptor.pause,streamDescriptor.streamPublisherID); } } /***** * Handler for the stop and start buttons. *******/ private function onBtnClick(p_evt:MouseEvent):void { if ( p_evt.currentTarget.label == "Start" ) { webCamPub.publish(); p_evt.currentTarget.label = "Stop" ; }else if (p_evt.currentTarget.label == "Stop" ){ webCamPub.stop(); p_evt.currentTarget.label = "Start" ; } } import mx.effects.easing.*; ]]> </mx:Script> <mx:Sequence id="myShow" target="{myCanvas}"> <mx:Blur blurXFrom="0" blurXTo="100" blurYFrom="0" blurYTo="100"/> <mx:Fade alphaTo="0"/> </mx:Sequence> <mx:Parallel id="myShow2" target="{myCanvas}"> <mx:Zoom zoomWidthFrom="0.1" zoomWidthTo="1.0" easingFunction="Back.easeOut"/> </mx:Parallel> <mx:VBox id="myCanvas" borderColor="0xcccccc" borderStyle="solid" borderThickness="3" dropShadowEnabled="true" horizontalCenter="0" verticalCenter="0" creationCompleteEffect="myShow2"> <mx:HBox> <mx:Label text="名前を入れてね!" width="100"/><mx:TextInput id="myName"/> </mx:HBox> <mx:HBox> <mx:Label text="部屋名" width="100"/><mx:TextInput id="myRoom" text="http://connectnow.acrobat.com/名前/部屋"/> </mx:HBox> <mx:Button click="onNameInput()" label="入室"/> </mx:VBox> <rtc:AdobeHSAuthenticator id="auth"/> <rtc:ConnectSessionContainer id="cSession" authenticator="{auth}" width="100%" height="100%" autoLogin="false" > <mx:Panel title="簡単チャット" width="100%" height="100%" backgroundColor="0x333333" paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10" creationComplete="onCreationComplete()"> <rtc:WebcamPublisher id="webCamPub" width="10" height="5"/> <mx:VDividedBox width="100%" height="100%" dividerColor="0x333333" dividerThickness="3"> <mx:Canvas width="100%" height="30%"> <mx:HBox horizontalGap="10" verticalGap="15" paddingLeft="10" paddingTop="10" paddingBottom="10" paddingRight="10" width="100%" height="100%" backgroundColor="0xcccccc" horizontalAlign="left"> <mx:Repeater id="rp" dataProvider="{cSession.userManager.userCollection}" width="100%" height="100%" > <mx:VBox width="100%" height="15%" horizontalAlign="center" horizontalGap="5"> <mx:Button label="Start" click="onBtnClick(event)" visible="{rp.currentItem.userID==cSession.userManager.myUserID}" /> <rtc:AudioPublisher id="audioPub"/><rtc:AudioSubscriber/> <rtc:WebcamSubscriber webcamPublisher="{webCamPub}" publisherIDs="{[rp.currentItem.userID]}" width="150" height="120" click="onClick(event)" userBooted="onBooted(event)" streamChange="onCameraPause(event)"/> </mx:VBox> </mx:Repeater> </mx:HBox> </mx:Canvas> <mx:HDividedBox width="100%" height="70%"> <mx:Canvas width="30%" height="100%"> <rtc:SimpleChat width="100%" height="100%"/> </mx:Canvas> <mx:Canvas width="70%" height="100%"> <rtc:SharedWhiteBoard width="100%" height="100%"/> </mx:Canvas> </mx:HDividedBox> </mx:VDividedBox> </mx:Panel> <mx:VBox width="400" height="100%" id="clickedContainer" visible="false"/> <mx:TextArea id="myLog" width="431" height="155" visible="false"/> </rtc:ConnectSessionContainer> </mx:Application>