質問

mxmlクラスを使用していましたが、構築時にいくつかのプロパティを渡す必要があるため、簡単にするためにas3コードに変換します。

クラスはRectangleShapeであり、単に四角形を描画します。

元のmxmlの動作

<?xml version="1.0" encoding="utf-8"?>
<BaseShape name="rectangle"
    xmlns="org.edorado.edoboard.view.components.shapes.*" 
    xmlns:mx="http://www.adobe.com/2006/mxml" 
    xmlns:degrafa="http://www.degrafa.com/2007"
    xmlns:objecthandles="com.roguedevelopment.objecthandles.*">

    <mx:Script>
        <![CDATA[

            import org.edorado.edoboard.view.components.shapes.IShape;
            import mx.events.FlexEvent;

            override public function drag(movePt:Point):void {
                this.width = movePt.x - this.x; 
                this.height = movePt.y - this.y; 
            }

            override public function updateFillColor(color:int):void {
                solidFill.color = color;
            }

        ]]>
    </mx:Script>

    <degrafa:Surface >
        <degrafa:GeometryGroup id="geo">
            <degrafa:fills>
                <degrafa:SolidFill id="solidFill" color="white" alpha="0.3"/>
            </degrafa:fills>

            <degrafa:strokes>
                <degrafa:SolidStroke id="stroke1" color="white"/>
            </degrafa:strokes>

            <degrafa:RegularRectangle 
                id="rect" 
                fill = "{solidFill}"
                width="{width}" 
                height="{height}"
                stroke="{stroke1}" />
        </degrafa:GeometryGroup>        
    </degrafa:Surface>
</BaseShape>

AS3への私の試み

パッケージorg.edorado.edoboard.view.components.shapes {     import com.degrafa.geometry.RegularRectangle;     import com.degrafa.paint.SolidFill;     import com.degrafa.paint.SolidStroke;     import com.degrafa.GeometryGroup;     import com.degrafa.Surface;     import flash.geom.Point;

public class RectangleShape extends BaseShape 
{
    public var surface:Surface = new Surface(); 
    public var geoGroup:GeometryGroup = new GeometryGroup();
    public var solidFill:SolidFill = new SolidFill("white");
    public var solidStroke:SolidStroke = new SolidStroke("black");
    public var rect:RegularRectangle = new RegularRectangle(); 

    public static const name:String = "rectangle";

    public function RectangleShape() {
        addChild(surface);
        //surface.addChild(geoGroup);
        surface.graphicsCollection.addItem(geoGroup); 

        solidFill.alpha = 0.3;
        rect.fill = solidFill;
        rect.stroke = solidStroke;
        rect.width = this.width;
        rect.height = this.height;
        geoGroup.geometry = [rect];
        geoGroup.draw(null, null); 
    }

    override public function drag(movePt:Point):void {

        this.width = movePt.x - this.x; 
        this.height = movePt.y - this.y; 
        trace('dragging ', this.width, this.height);
    }

    override public function updateFillColor(color:int):void {
        solidFill.color = color;
    }
}

}

問題は、シェイプがもう描画されておらず、BaseShapeコンテナがそこにあり、トレースドラッグが動作しているのを見ることができますが、長方形はもう動作しないことです。

見逃した明らかなものはありますか? ありがとう

役に立ちましたか?

解決

BindingUtilsクラスを使用してバインディングを設定してみてください。

例:

BindingUtils.bindProperty(component, "height", this, "height"); 

他のヒント

問題を特定したと思います。 以前のmxmlバージョンでは、

width =&quot; {width}&quot; height =&quot; {height}&quot;

また、degrafaの長方形は自動的に親に適合します。

ただし、ASバージョンにはありません。 Asで{width}と{height}を再現しようとする必要があります。 mxmlをasに変換するツールはありますか?

RectangleShapeにChildを追加しましたか?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top