Avatar

Level 3

This is a copy of SharedButton.as

Thank you.

package
{
    import com.adobe.rtc.events.SharedPropertyEvent;
    import com.adobe.rtc.messaging.UserRoles;
    import com.adobe.rtc.sharedModel.SharedProperty;
   
    import flash.events.MouseEvent;
   
    import mx.controls.Button;

    public class SharedButton extends Button
    {
        public function SharedButton()
        {
            super();
        }
       
        protected var _sharedButton:SharedProperty;
       
        override protected function createChildren():void
        {
            super.createChildren();
            toggle = true;
            _sharedButton = new SharedProperty();           
            _sharedButton.publishModel = UserRoles.PUBLISHER;
            _sharedButton.sharedID = id;

            _sharedButton.subscribe();
            addEventListener(MouseEvent.CLICK, onLocalClick);
            _sharedButton.addEventListener(SharedPropertyEvent.CHANGE, onRemoteClick);
        }
       
        protected function onLocalClick(p_evt:MouseEvent):void
        {           
            _sharedButton.value = selected;
        }
       
        protected function onRemoteClick(s_evt:SharedPropertyEvent):void
        {
            selected = _sharedButton.value;
        }
               
    }
}

I then instantiate it like this...

<l:SharedButton id="_mybutton" label="My shared button" />

Thanks again for your help