因此,在我的一个模块中,名为numDays的变量是通过循环一些XML数据并查找xml字段的最大值来调用days来创建的。找到numDays变量后,我用它来查找画布的宽度:
wrapper.width = numDays * parentApplication.oneDay;
(oneDay是通过将窗口宽度除以14确定的值)
所以,现在我知道包装画布的宽度,我可以开始填充它了。我有四个项目进入包装器:1)角色描述,2)左控制器,3)名称文本框(自动建议组件),4)右控制器。角色描述的宽度为30px。左右控制器各20个。因此,为了获得名称文本框的宽度,我有一个执行以下操作的函数:
nameTextbox.width = wrapper.width - 70;
由于某种原因,当我这样做时,应用程序不会完全加载。它几乎停滞不前。我有30个“项目”,每个项目中有15个“职位”。 wrapper.width描述了一个位置的宽度,因此有450个名称文本框试图找出来。这是为什么它搞乱了吗?
修改的
因此,从主应用程序中调用项目模块。在项目模块中,创建一个列表,其数据源为“positionsAC”:
<mx:List id="wholePosition" dataProvider="{positionsAC}" width="100%" height="100%" paddingBottom="0" paddingLeft="0" paddingRight="0" paddingTop="0" backgroundAlpha="0" verticalScrollPolicy="off" itemRenderer="modules.position" useRollOver="false" selectable="false">
下面是整个位置模块的c / p
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:components="com.hillelcoren.components.*" dataChange="allData = data as Array" layout="absolute" creationComplete="init();" horizontalScrollPolicy="off">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
[Bindable] public var positionInfo:Array;
[Bindable] public var wholePositionID:Number;
[Bindable] public var allData:Array;
[Bindable] public var positions:XML;
[Bindable] public var startOffset:Number;
[Bindable] public var numDays:Number;
[Bindable] public var role:String;
[Bindable] public var studentID:Number;
[Bindable] public var conflict:Number;
[Bindable] public var studentType:String;
[Bindable] public var showInPrinciple:Number;
[Bindable] public var positionX:Number = 0;
[Bindable] public var positionWidth:Number = 0;
[Bindable] public var sName:String = new String;
[Bindable] public var asAC:ArrayCollection = new ArrayCollection;
[Bindable] public var conflictBG:uint = 0xffffff;
[Bindable] public var roleColor:uint = 0x000000;
private function init():void
{
if (allData)
{
getInfo(allData);
setBGColor();
getPositionX();
getPositionWidth();
getRightStudents();
}
}
private function getInfo(a:Array):void
{
var tempArray:Array = new Array;
startOffset = Number(a[0]);
numDays = Number(a[1]);
positionWidth = parentApplication.oneDay * numDays;
setStudentNameW();
role = a[2];
studentID = Number(a[3]);
tempArray = parentApplication.studentsDBIDDict[String(studentID)] as Array;
conflict = Number(a[4]);
studentType = a[5];
sName = "test";
showInPrinciple = a[6];
}
private function setStudentNameW():void
{
if (numDays == 1)
{
studentName.width = 55;
studentName.x = 37;
contractLeft.visible = false;
contractRight.visible = false;
}
else if (numDays == 2)
{
Alert.show("HI");
studentName.width = 133;
}
else if (numDays == 3)
studentName.width = 230;
else if (numDays == 4)
studentName.width = 330;
if (numDays > 1)
{
studentName.x = 47;
contractLeft.visible = true;
contractRight.visible = true;
}
}
public function setBGColor():void
{
if (conflict == 1)
conflictBG = parentApplication.errorColor;
else if (conflict == 2)
conflictBG = parentApplication.okErrorColor;
else
conflictBG = 0xFFFFFF;
}
private function getPositionX():void
{
positionX = parentApplication.oneDay * startOffset - 1;
}
private function getPositionWidth():void
{
positionWidth = parentApplication.oneDay * numDays;
}
private function getRightStudents():void
{
if (studentType == "freshman")
makeASAC(parentApplication.freshmanAC);
else if (studentType == "bfa1")
makeASAC(parentApplication.bfa1AC);
else if (studentType == "bfa2")
makeASAC(parentApplication.bfa2AC);
else if (studentType == "bfa3")
makeASAC(parentApplication.bfa3AC);
else if (studentType == "mfa1")
makeASAC(parentApplication.mfa1AC);
else if (studentType == "mfa2")
makeASAC(parentApplication.mfa2AC);
else if (studentType == "mfa3")
makeASAC(parentApplication.mfa3AC);
else if (studentType == "mfaw1")
makeASAC(parentApplication.mfaw1AC);
else if (studentType == "mfaw2")
makeASAC(parentApplication.mfaw2AC);
else if (studentType == "mfaw3")
makeASAC(parentApplication.mfaw3AC);
}
private function makeASAC(students:ArrayCollection):void
{
for (var i:int = 0; i < students.length; i++)
asAC.addItem(parentApplication.getStudentName(students.getItemAt(i)));
}
private function posLength(whichSide:String, expandContract:String):void
{
if (whichSide == 'l')
{
if (expandContract == 'e')
{
if (startOffset > 0)
{
numDays++;
startOffset--;
getPositionX();
getPositionWidth();
}
}
else if (expandContract == 'c')
{
if (numDays > 1)
{
numDays--;
startOffset++;
getPositionX();
getPositionWidth();
}
}
}
else if (whichSide == 'r')
{
if (expandContract == 'e')
{
if (numDays + startOffset < parentDocument.projectLength)
{
numDays++;
getPositionX();
getPositionWidth();
}
}
else if (expandContract == 'c')
{
if (numDays > 1)
{
numDays--;
getPositionX();
getPositionWidth();
}
}
}
//parentApplication.conflicts();
}
]]>
</mx:Script>
<mx:Canvas id="positionWrapper" width="{positionWidth}" height="25" backgroundColor="#ffffff" horizontalScrollPolicy="off" borderColor="#000000" borderStyle="solid" borderThickness="1">
<mx:Text id="roleText" text="{role}" width="25" y="3" color="{roleColor}" fontSize="11" fontWeight="bold" click="parentApplication.getDictLen(parentApplication.studentsDBIDDict)" />
<mx:Canvas id="leftSide" x="25" width="22" height="100%" mouseOver="expandLeft.visible = true; contractLeft.visible = true;" mouseOut="expandLeft.visible = false; contractLeft.visible = false;" backgroundColor="{conflictBG}" horizontalScrollPolicy="off">
<mx:Image id="expandLeft" source="images/addRed.png" y="5" click="posLength('l', 'e')" mouseOver="parentApplication.switchCursor(true);" mouseOut="parentApplication.switchCursor(false);" visible="false" />
<mx:Image id="contractLeft" source="images/minusRed.png" x="10" y="5" click="posLength('l', 'c')" mouseOver="parentApplication.switchCursor(true);" mouseOut="parentApplication.switchCursor(false);" visible="false" />
</mx:Canvas>
<components:AutoComplete id="studentName" textAlign="center"
dataProvider="{asAC}"
x="47" y="3"
/>
<mx:Image id="showSNW" source="images/searchicon.png" x="{(studentName.width + studentName.x) - 12}" y="5" visible="false" mouseOver="parentApplication.switchCursor(true); studentName.enabled = false;" mouseOut="parentApplication.switchCursor(false); studentName.enabled = true; showSNW.visible = false;" />
<mx:Canvas id="rightSide" x="{positionWrapper.width - 22}" width="20" height="100%" mouseOver="expandRight.visible = true; contractRight.visible = true;" mouseOut="expandRight.visible = false; contractRight.visible = false;" backgroundColor="{conflictBG}" horizontalScrollPolicy="off">
<mx:Image id="contractRight" source="images/minusRed.png" y="5" click="posLength('r', 'c')" visible="false" mouseOver="parentApplication.switchCursor(true);" mouseOut="parentApplication.switchCursor(false);" />
<mx:Image id="expandRight" source="images/addRed.png" x="10" y="5" click="posLength('r', 'e')" visible="false" mouseOver="parentApplication.switchCursor(true);" mouseOut="parentApplication.switchCursor(false);" />
</mx:Canvas>
</mx:Canvas>
答案 0 :(得分:0)
最好得到一个调试器。 Flash Builder 4非常不错,它们甚至还提供免费的标准许可证
此外,获取最新Flash Player here
的调试版免费标准可能需要一段时间,但您可以随时使用免费试用版。
调试时,请检查nameTextBox是否为空。