kingyiren / flex-object-handles

Automatically exported from code.google.com/p/flex-object-handles
0 stars 0 forks source link

mycode #13

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
[Bindable] 
            private var myObjSource:ObjectSource;

            public function drawShape(id:String):void
            {
                var shape:String=id;
                //var myObjShp:ObjectHandlesCanvas  = new ObjectHandlesCanvas();
                var myObjShp:Canvas  = new Canvas();

                //var myObjShpNew:ObjectHandles  = new ObjectHandles();
                //myObjShp.setStyle("borderStyle","none");

                if(shape=="circle")
                {
                       myObjSource = new ObjectSource(  
                        new ClassFactory(
com.roguedevelopment.flowchart.shapes.CircleShape),
                        myObjShp,
                        new Point(300,50)
                     );
                    generic.addChild(myObjShp);
                    /* myObjShp.addEventListener(MouseEvent.CLICK, function
click(e:MouseEvent):void
                    {
                        var obj:ObjectHandlesCanvas = e.currentTarget as ObjectHandlesCanvas;
                        if(obj != null)
                        {
                            selectedShape = obj;
                            selectedObject = null;
                        }
                    }); */
                }
                else if(shape=="rectangle")
                {
                    myObjSource = new ObjectSource(
                    new ClassFactory( com.roguedevelopment.flowchart.shapes.SquareShape),
                    myObjShp,
                    new Point(300,50) );
                    generic.addChild(myObjShp);
                    /* myObjShp.addEventListener(MouseEvent.CLICK, function
click(e:MouseEvent):void
                    {
                        var obj:ObjectHandlesCanvas = e.currentTarget as ObjectHandlesCanvas;
                        if(obj != null)
                        {
                            selectedShape = obj;
                            selectedObject = null;
                        }
                    }); */

                }/* else if(shape=="polygon")
                {
                    var sourceStarShape:ObjectSource = new ObjectSource(
                    new ClassFactory( com.roguedevelopment.flowchart.shapes.StarShape),
                    myObjShp,
                    new Point(0,0) );
                    generic.addChild(myObjShp);
                    myObjShp.addEventListener(MouseEvent.CLICK, function
click(e:MouseEvent):void
                    {
                        var obj:ObjectHandlesCanvas = e.currentTarget as ObjectHandlesCanvas;
                        if(obj != null)
                        {
                            selectedShape = obj;
                            selectedObject = null;
                        }
                    });

                }else if(shape=="traingle")
                {
                    var sourceTriangleOne:ObjectSource = new ObjectSource(
                    new ClassFactory( com.roguedevelopment.flowchart.shapes.TriangleOne),
                    myObjShp,
                    new Point(0,0) );

                    generic.addChild(myObjShp);
                    myObjShp.addEventListener(MouseEvent.CLICK, function
click(e:MouseEvent):void
                    {
                        var obj:ObjectHandlesCanvas = e.currentTarget as ObjectHandlesCanvas;
                        if(obj != null)
                        {
                            selectedShape = obj;
                            selectedObject = null;
                        }
                    });

                }else if (shape=="vline"){

                    var sourceRoundRect4:ObjectSource = new ObjectSource(
                    new ClassFactory( com.roguedevelopment.flowchart.shapes.RoundRect4),
                    myObjShp,
                    new Point(0,0) );
                    generic.addChild(myObjShp);
                    myObjShp.addEventListener(MouseEvent.CLICK, function
click(e:MouseEvent):void
                    {
                        var obj:ObjectHandlesCanvas = e.currentTarget as ObjectHandlesCanvas;
                        if(obj != null)
                        {
                            selectedShape = obj;
                            selectedObject = null;
                        }
                    });

                }else if (shape=="line"){

                    var sourceline:ObjectSource = new ObjectSource(
                    new ClassFactory( com.roguedevelopment.flowchart.shapes.line),
                    myObjShp,
                    new Point(0,0) );

                    generic.addChild(myObjShp);
                    myObjShp.addEventListener(MouseEvent.CLICK, function
click(e:MouseEvent):void
                    {
                        var obj:ObjectHandlesCanvas = e.currentTarget as ObjectHandlesCanvas;
                        if(obj != null)
                        {
                            selectedShape = obj;
                            selectedObject = null;
                        }
                    });

                }else if (shape=="hline"){

                    var sourceRoundRect3:ObjectSource = new ObjectSource(
                    new ClassFactory( com.roguedevelopment.flowchart.shapes.RoundRect3),
                    myObjShp,
                    new Point(0,0) );

                    generic.addChild(myObjShp);
                    myObjShp.addEventListener(MouseEvent.CLICK, function
click(e:MouseEvent):void
                    {
                        var obj:ObjectHandlesCanvas = e.currentTarget as ObjectHandlesCanvas;
                        if(obj != null)
                        {
                            selectedShape = obj;
                            selectedObject = null;
                        }
                    });

                }else if (shape=="roundrect"){

                    var sourceRoundRect2:ObjectSource = new ObjectSource(
                    new ClassFactory( com.roguedevelopment.flowchart.shapes.RoundRect2),
                    myObjShp,
                    new Point(0,0) );

                    generic.addChild(myObjShp);
                    myObjShp.addEventListener(MouseEvent.CLICK, function
click(e:MouseEvent):void
                    {
                        var obj:ObjectHandlesCanvas = e.currentTarget as ObjectHandlesCanvas;
                        if(obj != null)
                        {
                            selectedShape = obj;
                            selectedObject = null;
                        }
                    });

                }else if (shape=="roundrectcon"){

                var sourceRoundRect1:ObjectSource = new ObjectSource(
                    new ClassFactory( com.roguedevelopment.flowchart.shapes.RoundRect1),
                    myObjShp,
                    new Point(0,0) );

                    generic.addChild(myObjShp);
                    myObjShp.addEventListener(MouseEvent.CLICK, function
click(e:MouseEvent):void
                    {
                        var obj:ObjectHandlesCanvas = e.currentTarget as ObjectHandlesCanvas;
                        if(obj != null)
                        {
                            selectedShape = obj;
                            selectedObject = null;
                        }
                    });

                }else if (shape=="polyline"){

                var sourcepolyline:ObjectSource = new ObjectSource(
                    new ClassFactory( com.roguedevelopment.flowchart.shapes.ployline),
                    myObjShp,
                    new Point(0,0) );

                    generic.addChild(myObjShp);
                    myObjShp.addEventListener(MouseEvent.CLICK, function
click(e:MouseEvent):void
                    {
                        var obj:ObjectHandlesCanvas = e.currentTarget as ObjectHandlesCanvas;
                        if(obj != null)
                        {
                            selectedShape = obj;
                            selectedObject = null;
                        }
                    });

                }else if (shape=="wedge"){

                    var sourceellipticalarc:ObjectSource = new ObjectSource(
                    new ClassFactory( com.roguedevelopment.flowchart.shapes.ellipticalarc),
                    myObjShp,
                    new Point(0,0) );

                    generic.addChild(myObjShp);
                    myObjShp.addEventListener(MouseEvent.CLICK, function
click(e:MouseEvent):void
                    {
                        var obj:ObjectHandlesCanvas = e.currentTarget as ObjectHandlesCanvas;
                        if(obj != null)
                        {
                            selectedShape = obj;
                            selectedObject = null;
                        }
                    });

                }else if (shape=="ellipse"){

                    var sourceellipse:ObjectSource = new ObjectSource(
                    new ClassFactory( com.roguedevelopment.flowchart.shapes.ellipse),
                    myObjShp,
                    new Point(0,0) );
                    generic.addChild(myObjShp);
                    myObjShp.addEventListener(MouseEvent.CLICK, function
click(e:MouseEvent):void
                    {
                        var obj:ObjectHandlesCanvas = e.currentTarget as ObjectHandlesCanvas;
                        if(obj != null)
                        {
                            selectedShape = obj;
                            selectedObject = null;
                        }
                    });

                } */

            }
private function Delete():void
             {

                if(selectedObject != null)
                {
                    selectedObject.removeAllChildren();

                }else if(myObjSource.selectedObjectNew !=null)
                {
                    Alert.show("hi"+myObjSource.selectedObjectNew);

//myObjSource.selectedObjectNew.parent.removeChild(myObjSource.selectedObjectNew
);
                }
                /* else if(selectedShape != null)
                {
                    selectedShape.parent.removeChild(selectedShape);
                } */

                if(cnvsParent.parent!= null)
                    cnvsParent.parent.removeChild(cnvsParent);  
             }

package com.roguedevelopment.flowchart
{
    import com.roguedevelopment.objecthandles.ObjectHandleEvent;
    import com.roguedevelopment.objecthandles.ObjectHandles;
    import com.roguedevelopment.objecthandles.SelectionManager;

    import flash.events.Event;
    import flash.geom.Point;

    import mx.containers.Canvas;
    import mx.controls.Alert;
    import mx.core.ClassFactory;

    public class ObjectSource 
    {
        protected var _factory:ClassFactory;
        protected var _position:Point;
        protected var _parent:Canvas;
        public var selectedObjectNew:ObjectHandles=null;

        public function ObjectSource(factory:ClassFactory, parent:Canvas,
position:Point)
        {
            _factory = factory;
            _position = position;
            _parent = parent;

            createObject();

        }

        protected function createObject() : void
        {
            var obj:ObjectHandles = _factory.newInstance() as ObjectHandles;
            obj.removeEventListener(ObjectHandleEvent.OBJECT_MOVING_EVENT, onMoved );

obj.addEventListener(ObjectHandleEvent.OBJECT_SELECTED,OnObjectHandlesSelected1)
;
            obj.x = _position.x;
            obj.y = _position.y;

            SelectionManager.instance.addSelectable(obj);
            _parent.addChild( obj );

        }

        protected function onMoved(event:Event) : void
        {
            var obj:ObjectHandles = event.target as ObjectHandles;
            obj.removeEventListener(ObjectHandleEvent.OBJECT_MOVING_EVENT, onMoved );
            //createObject();
        }

         private function OnObjectHandlesSelected1(event:ObjectHandleEvent):void
        {

            var obj:ObjectHandles = event.currentTarget as ObjectHandles;
            if(obj != null)
            {

                selectedObjectNew = obj;
                //Alert.show("hi"+selectedObjectNew);

            } 
        } 

    }
}

Original issue reported on code.google.com by abidr...@gmail.com on 12 Aug 2009 at 6:29

GoogleCodeExporter commented 8 years ago
I'm unsure what this issue is for.

Original comment by marc.hug...@gmail.com on 22 Dec 2009 at 3:51