[]我想把flex项目转为laya ts项目,转换过程 mx.containers.Canvas报错
我想把下面的代码转为laya TS语法
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="144" height="590" mouseEnabled="true">
<mx:Canvas width="144" height="590" x="0" y="0" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<!-- left border -->
<mx:Canvas x="0" y="0" width="4" height="590" backgroundColor="#c9c9c9" borderColor="#000000" borderStyle="solid" borderThickness="1">
</mx:Canvas>
<mx:Canvas x="4" y="8" width="10" height="570" backgroundColor="#eeeeee" borderColor="#999999" borderStyle="solid" borderThickness="1">
</mx:Canvas>
<mx:Canvas x="4" y="0" width="136" height="8" backgroundColor="#c9c9c9" borderColor="#000000" borderStyle="solid" borderThickness="1">
</mx:Canvas>
<!-- main box -->
<mx:Canvas id="cab" width="116" height="570" x="14" y="8"
backgroundColor="#ffffff" borderColor="#000000" alpha="1"
horizontalScrollPolicy="off" verticalScrollPolicy="off"
mouseEnabled="true"
mouseOver="/*trace(this);*/currentCabinet=this;"
>
</mx:Canvas>
<mx:Canvas x="4" y="578" width="136" height="12" backgroundColor="#c9c9c9" borderColor="#000000" borderStyle="solid" borderThickness="1">
</mx:Canvas>
<mx:Canvas x="130" y="8" width="10" height="570" backgroundColor="#eeeeee" borderColor="#999999" borderStyle="solid" borderThickness="1">
</mx:Canvas>
<!-- right border -->
<mx:Canvas x="140" y="0" width="4" height="590" backgroundColor="#c9c9c9" borderColor="#000000" borderStyle="solid" borderThickness="1">
</mx:Canvas>
</mx:Canvas>
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
public var cabId:int = 0;
public var U:int = 42;
public var frameFace:int = 1;
public function add(child:UIComponent):void
{
this.cab.addChild(child);
}
public function getDevices():Array
{
return this.cab.getChildren();
}
public function getHeight():Number
{
return this.cab.height;
}
//获取机柜每U的高度
public function getHeightOfOneU():Number
{
if(this.U<=0) return 0;
return this.cab.height/this.U;
}
private function setCurrentCabinet(ev:MouseEvent):void
{
}
//记录当前机柜
public static var currentCabinet:Cabinet;
public function isInCab():Boolean
{
if(this.cab.mouseX<0 || this.cab.mouseX>this.cab.width) return false;
if(this.cab.mouseY<0 || this.cab.mouseY>this.cab.height) return false;
return true;
}
//对外提供全局坐标到cab容器的本地坐标转换
public function global2Content(p:Point):Point
{
return this.cab.globalToContent(p);
}
]]>
</mx:Script>
</mx:Canvas>
转换过程 mx.containers.Canvas报错
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="144" height="590" mouseEnabled="true">
<mx:Canvas width="144" height="590" x="0" y="0" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<!-- left border -->
<mx:Canvas x="0" y="0" width="4" height="590" backgroundColor="#c9c9c9" borderColor="#000000" borderStyle="solid" borderThickness="1">
</mx:Canvas>
<mx:Canvas x="4" y="8" width="10" height="570" backgroundColor="#eeeeee" borderColor="#999999" borderStyle="solid" borderThickness="1">
</mx:Canvas>
<mx:Canvas x="4" y="0" width="136" height="8" backgroundColor="#c9c9c9" borderColor="#000000" borderStyle="solid" borderThickness="1">
</mx:Canvas>
<!-- main box -->
<mx:Canvas id="cab" width="116" height="570" x="14" y="8"
backgroundColor="#ffffff" borderColor="#000000" alpha="1"
horizontalScrollPolicy="off" verticalScrollPolicy="off"
mouseEnabled="true"
mouseOver="/*trace(this);*/currentCabinet=this;"
>
</mx:Canvas>
<mx:Canvas x="4" y="578" width="136" height="12" backgroundColor="#c9c9c9" borderColor="#000000" borderStyle="solid" borderThickness="1">
</mx:Canvas>
<mx:Canvas x="130" y="8" width="10" height="570" backgroundColor="#eeeeee" borderColor="#999999" borderStyle="solid" borderThickness="1">
</mx:Canvas>
<!-- right border -->
<mx:Canvas x="140" y="0" width="4" height="590" backgroundColor="#c9c9c9" borderColor="#000000" borderStyle="solid" borderThickness="1">
</mx:Canvas>
</mx:Canvas>
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
public var cabId:int = 0;
public var U:int = 42;
public var frameFace:int = 1;
public function add(child:UIComponent):void
{
this.cab.addChild(child);
}
public function getDevices():Array
{
return this.cab.getChildren();
}
public function getHeight():Number
{
return this.cab.height;
}
//获取机柜每U的高度
public function getHeightOfOneU():Number
{
if(this.U<=0) return 0;
return this.cab.height/this.U;
}
private function setCurrentCabinet(ev:MouseEvent):void
{
}
//记录当前机柜
public static var currentCabinet:Cabinet;
public function isInCab():Boolean
{
if(this.cab.mouseX<0 || this.cab.mouseX>this.cab.width) return false;
if(this.cab.mouseY<0 || this.cab.mouseY>this.cab.height) return false;
return true;
}
//对外提供全局坐标到cab容器的本地坐标转换
public function global2Content(p:Point):Point
{
return this.cab.globalToContent(p);
}
]]>
</mx:Script>
</mx:Canvas>
转换过程 mx.containers.Canvas报错
没有找到相关结果
已邀请:
要回复问题请先登录
2 个回复
qian
赞同来自:
zhaokai_5
赞同来自:
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="144" height="590" mouseEnabled="true">
<mx:Canvas width="144" height="590" x="0" y="0" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<!-- left border -->
<mx:Canvas x="0" y="0" width="4" height="590" backgroundColor="#c9c9c9" borderColor="#000000" borderStyle="solid" borderThickness="1">
</mx:Canvas>
<mx:Canvas x="4" y="8" width="10" height="570" backgroundColor="#eeeeee" borderColor="#999999" borderStyle="solid" borderThickness="1">
</mx:Canvas>
<mx:Canvas x="4" y="0" width="136" height="8" backgroundColor="#c9c9c9" borderColor="#000000" borderStyle="solid" borderThickness="1">
</mx:Canvas>
<!-- main box -->
<mx:Canvas id="cab" width="116" height="570" x="14" y="8"
backgroundColor="#ffffff" borderColor="#000000" alpha="1"
horizontalScrollPolicy="off" verticalScrollPolicy="off"
mouseEnabled="true"
mouseOver="/*trace(this);*/currentCabinet=this;"
>
</mx:Canvas>
<mx:Canvas x="4" y="578" width="136" height="12" backgroundColor="#c9c9c9" borderColor="#000000" borderStyle="solid" borderThickness="1">
</mx:Canvas>
<mx:Canvas x="130" y="8" width="10" height="570" backgroundColor="#eeeeee" borderColor="#999999" borderStyle="solid" borderThickness="1">
</mx:Canvas>
<!-- right border -->
<mx:Canvas x="140" y="0" width="4" height="590" backgroundColor="#c9c9c9" borderColor="#000000" borderStyle="solid" borderThickness="1">
</mx:Canvas>
</mx:Canvas>
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
public var cabId:int = 0;
public var U:int = 42;
public var frameFace:int = 1;
public function add(child:UIComponent):void
{
this.cab.addChild(child);
}
public function getDevices():Array
{
return this.cab.getChildren();
}
public function getHeight():Number
{
return this.cab.height;
}
//获取机柜每U的高度
public function getHeightOfOneU():Number
{
if(this.U<=0) return 0;
return this.cab.height/this.U;
}
private function setCurrentCabinet(ev:MouseEvent):void
{
}
//记录当前机柜
public static var currentCabinet:Cabinet;
public function isInCab():Boolean
{
if(this.cab.mouseX<0 || this.cab.mouseX>this.cab.width) return false;
if(this.cab.mouseY<0 || this.cab.mouseY>this.cab.height) return false;
return true;
}
//对外提供全局坐标到cab容器的本地坐标转换
public function global2Content(p:Point):Point
{
return this.cab.globalToContent(p);
}
]]>
</mx:Script>
</mx:Canvas>