Avatar

Correct answer by
Level 10

Hi ,

I found the problem :). So, basically when you do _sharedButton.publishModel in your code, the model is not synchronized by then and the node is not created the first time. This error is only used to happen when you will run the app the first time in a room. So, on your side, you need to wait till the SharedProperty is synchronized to be on safe side, and our side I will fix it so that it doesn’t throw the exception even the first time.

I am attaching your code modified with the changes. Thanks for reporting.

Hope this helps.

Regards

Hironmay Basu

// ActionScript file

package

{

import com.adobe.rtc.events.CollectionNodeEvent;

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.sharedID = id;

_sharedButton.subscribe();

sharedButton.addEventListener(CollectionNodeEvent.SYNCHRONIZATIONCHANGE,onSyncChange);

addEventListener(MouseEvent.CLICK, onLocalClick);

_sharedButton.addEventListener(SharedPropertyEvent.CHANGE, onRemoteClick);

}

protected function onSyncChange(p_evt:CollectionNodeEvent):void

{

if ( _sharedButton.isSynchronized ) {

_sharedButton.publishModel = UserRoles.PUBLISHER ;

}

}

protected function onLocalClick(p_evt:MouseEvent):void

{

_sharedButton.value = selected;

}

protected function onRemoteClick(s_evt:SharedPropertyEvent):void

{

selected = _sharedButton.value;

}

}

}

View solution in original post