Expand my Community achievements bar.

SharedWBModel.addShape

Avatar

Level 4

i have just this minute managed to successfully call this method and programmatically add an arrow to the whiteboard. looking at the output in the AFCS Dev Console i worked out i could do this:

var someShape:WBShapeDescriptor = new WBShapeDescriptor();

var shapeData:Object = new Object()
shapeData.basePercentX = 0;
shapeData.basePercentY = 0;
shapeData.headPercentX = 1;
shapeData.headPercentY = 1;

var propertyData:Object = new Object()
propertyData.alpha = 1
propertyData.dropShadow = true
propertyData.gradientFill = true
propertyData.htmlText = ""
propertyData.lineColor = 3815994
propertyData.lineThickness = 10

someShape.definitionData = shapeData;
someShape.propertyData = propertyData;
someShape.factoryID = "com.adobe.coreUI.controls.whiteboardClasses.shapes::WBArrowShapeFactory";
someShape.height = 200;
someShape.width = 200;
someShape.x = 125;
someShape.y = 125;

meetingRoom.whiteBoard.model.addShape(someShape);

it doesn't seem to me  that this is ideal tho. is this the right way to be going about this or not?

2 Replies

Avatar

Former Community Member

Hi dubya,

This is the right way - obviously the whiteboard is a complicated beast, and generating shapes programmatically wasn't high on our list of priorities. One thing I'm noticing (in WBArrowShape) is that we currently force you to add definitionData and propertyData, even though you're just using the default values here. That could be a lot easier.

What we can consider is to make subclasses of WBShapeDescriptor such that you can include code like this :

var arrowShape:WBArrowShapeDescriptor = new WBArrowShapeDescriptor();

arrowShape.dropShadow = false;

// etc.. All properties could be exposed at the top level.

arrowShape.width = arrowShape.height = 200;

meetingRoom.whiteBoard.model.addShape(arrowShape);

Does this seem more like you'd expect?

nigel

Avatar

Level 4

yeah, im surprised that it is the right way because you do have to jump through those definitionData and propertyData hoops. if they could be tidied away some how, like in the way you suggest, that would be preferable, sure. in fact, it would make sense if all the properties had defaults, so you could just do:

var someShape:WBShapeDescriptor = new WBShapeDescriptor();

meetingRoom.whiteBoard.model.addShape(someShape);