【发布时间】:2011-04-27 03:52:47
【问题描述】:
我正在使用 Flash Builder 4 编写 Flex 应用程序,但我在使用 AS3 对象时遇到了一些问题。本质上,它是一个 BorderContainer,带有一些按钮和图像,以及确定它们如何与彼此和数据库交互的编程逻辑。
我想要做的是使用 MXML 和 CSS 配置内部组件的布局/样式。我可以配置继承的对象,但不能配置我定义的对象...
例如,在我的 MXML 中。我可以像这样修改 myContainer 的(继承的)borderstroke 变量;
<IE:MyContainer>
<IE:borderStroke>
<s:LinearGradientStroke weight="10" rotation="270">
<s:GradientEntry color="0xF655E5"/>
<s:GradientEntry color="0x6600CC"/>
</s:LinearGradientStroke>
</IE:borderStroke>
</IE:MyContainer>
但是,我不能像这样编辑 nextButton 变量(Button 类型);
<IE:MyContainer>
<IE:nextButton width="100" height="30" left="10%" bottom="10%"/>
</IE:MyContainer>
如果我尝试,我会收到编译错误“无法解析为组件实现”。
我需要做什么才能完成这项工作?!
提前致谢, 艾丹
编辑: 这里是 MyContainer 的主要方法(实际命名为 InvestigativeEnvironment)。 对 defineTestInvestigativeEnvironment() 的调用负责设置对象和动作侦听器等。我想要做的是改变这些可视化组件在 MXML 中的布局和外观(nextButton、prevButton、toolbox、displayArea)。我希望能够设置它们的高度、宽度、背景、x、y、horizontalCenter 等,就像我可以通过 MXML 添加到容器中的按钮一样。
public class InvestigativeEnvironment extends BorderContainer
{
private var toolbox:Toolbox;
private var bodySystem:BodySystem;
public var nextButton:Button;
public var prevButton:Button;
private var displayArea:Group;
private var image:Image;
private var toolDisplayArea:Group;
public function InvestigativeEnvironment()
{
super();
//create 'Next' button and event listener
nextButton = new Button();
nextButton.addEventListener(MouseEvent.CLICK, nextViewAngle);
nextButton.label = "Next";
this.addElement(nextButton);
//create 'Prev' button and event listener
prevButton = new Button();
prevButton.addEventListener(MouseEvent.CLICK, prevViewAngle);
prevButton.label = "Prev";
this.addElement(prevButton);
//define investigative environment by creating models.
defineTestInvestigativeEnvironment();
//Instantiate the Group that contains the model image and tool overlays
displayArea=new Group();
//Instantiate the image that is used to display the model
image = new Image();
image.source=bodySystem.getImage();
image.horizontalCenter=0;
image.verticalCenter=0;
displayArea.addElement(image);
//add toolOverlayContainer to the display area ABOVE the model image
toolDisplayArea = new Group();
toolDisplayArea.verticalCenter=0;
toolDisplayArea.horizontalCenter=0;
displayArea.addElement(toolDisplayArea);
this.addElement(displayArea);
//add toolbox to display
toolbox = new Toolbox(toolDisplayArea);
toolbox.replaceTools(bodySystem.getToolGroup());
this.addElement(toolbox);
}
【问题讨论】:
-
请添加代码,列出您的编辑内容以及特别是哪一行会产生此错误。
-
发布你的代码
-
@Constantiner 等一下……在 cmets 中添加代码并不顺利。我会将其添加到原始问题中。
-
@The_asMan 我已经添加了代码,谢谢。
标签: actionscript-3 layout flex4 mxml flash-builder