Believe it or not shape framework looks to be pretty well
suited for expanding it for just this sort of thing. It took me a
while to wrap my head around exactly how this works but I think I
have pretty good grasp of it now.
There are 3 things you need to do to add an ImageShape to the
whiteboard...
1) Write an ImageShape Class - this is where you put the code
on how your image displays, which image to use, etc. Initially just
try to imbed an image and don't worry about trying to get dynamic
images (using Loader, Image or SWFLoader) to work.
2) Write an ImageShapeFactory Class - this what will spawn
the ImageShape Instance. Pay special attention to setting
"definitionData" and "propertyData". Start with
WBSimpleShapeFactory and trim it up for your usage to make your
ImageShapeFactory Class.
- definitionData is the data associated with the shape type
for instance if you look at WBSimpleShape you see that
definitionData is simply a string which determines if the shape is
an ellipse, rectangle, or roundedRectangle.
- propertyData deals with the properties of the object,
things like stroke thickness, stroke color, fill color, etc.
propertyData is pulled from a WBPropertiesToolBar or really any
toolbar that implements IWBPropertiesToolBar.
3) Once you have and ImageShapeFactory and an ImageShape
Class, you now need to add an extra Icon to the WBShapesToolBar to
spawn your new ImageShape when the user clicks on it. Initially
just modify WBShapesToolBar.as directly. Ideally you would want to
extend this Class but that can get a bit complicated so for now
just modify the source directly. Around line 177: duplicate the
following line:
{type:"tool", toolTip:_lm.getString("Line Tool"),
icon:ICON_LINE, shapeFactory:arrowFactory,
shapeData:WBArrowShapeFactory.NO_ARROW_HEAD},
and change one of the copies to:
{type:"tool", toolTip:"Image Shape", icon:ICON_LINE,
shapeFactory:imageFactory, shapeData:""},
at the top around line 117 :
protected var arrowFactory:WBArrowShapeFactory = new
WBArrowShapeFactory();
add the following line:
protected var imageFactory:ImageShapeFactory = new
ImageShapeFactory();
Assuming you built ImageFactory and ImageShape right an
ImageShape should be spawned when you click one of the now two line
icons.
I modified my source to hell and gone in an effort to do
"research" or else I would post the version of ImageShape and
ImageShapeFactory that I have. I might make some modifications to
those and post them just so everyone can see an example. I'll post
another reply with the code if I do. I really hope that helped a
little (at least pointed you in the right direction)....
Ves