Flex 4 通过在打印区域中添加动态项目进行打印(又名:如何将动态命名的元素动态添加到另一个元素)

发布于 2024-12-13 02:22:30 字数 1066 浏览 3 评论 0原文

我有许多动态添加到舞台上的项目。

这些称为 flexShapeXXX,其中 xxx 通常是唯一 ID。

现在我创建了一个组件来存储它们以进行打印,我可以将其视为虚拟页面,以便我可以布置要打印的内容。

看起来像这样:

    <?xml version="1.0"?>
<!-- myComponents\MyPrintView.mxml -->
<mx:VBox xmlns:fx="http://ns.adobe.com/mxml/2009" 
         xmlns:s="library://ns.adobe.com/flex/spark" 
         xmlns:mx="library://ns.adobe.com/flex/mx" 
         backgroundColor="#FFFFFF" 
         height="300" width="500" 
         paddingTop="50" paddingLeft="50" paddingRight="50">


</mx:VBox>

现在到目前为止一切顺利,然后我把我的小打印是 vbox 组件:

var formPrintView:MyPrintView = new MyPrintView();
formPrintView.width = printJob.pageWidth - 50;
formPrintView.height = printJob.pageHeight - 50;    
addElement(formPrintView);

这工作正常,它添加了一个很好的工作空间。

现在我希望能够做这样的事情:

formPrintView.addElement(dashPreview["flexShape" + TheID]);
printJob.addObject(formPrintView);

该部分失败了。

所以我的问题是如何通过动态名称从舞台添加元素。 这样我就可以打印它们。

请并感谢您提供的任何帮助。

克雷格

I have a number of items I add to the stage dynamically.

These are called flexShapeXXX where xxx is typically a unique ID.

Now I have created a component to store them in for printing, that I can treat as a virtual page so I can lay out stuff for printing.

This looks like this:

    <?xml version="1.0"?>
<!-- myComponents\MyPrintView.mxml -->
<mx:VBox xmlns:fx="http://ns.adobe.com/mxml/2009" 
         xmlns:s="library://ns.adobe.com/flex/spark" 
         xmlns:mx="library://ns.adobe.com/flex/mx" 
         backgroundColor="#FFFFFF" 
         height="300" width="500" 
         paddingTop="50" paddingLeft="50" paddingRight="50">


</mx:VBox>

Now so far so good I then take my little print are vbox component:

var formPrintView:MyPrintView = new MyPrintView();
formPrintView.width = printJob.pageWidth - 50;
formPrintView.height = printJob.pageHeight - 50;    
addElement(formPrintView);

This works fine it add a nice space to work in.

Now I want to be able to do something like this:

formPrintView.addElement(dashPreview["flexShape" + TheID]);
printJob.addObject(formPrintView);

That part fails.

So my question is how do I addelements from the stage via dynamic names.
So that I may print them.

Please and thank you for any help you can offer.

Craig

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十雾 2024-12-20 02:22:30

您可以尝试下面的解决方案吗?如果不起作用请告诉我。让我们假设您有一个 UI 组件:Page1

var page1:VBox = new VBox();

// Convert class name to Class object.
var cls:Class = getDefinitionByName(page1) as Class;
// Create a new instance of the class.
var instance:UIComponent = new cls();

var formPrintView:MyPrintView = new MyPrintView();
formPrintView.width = printJob.pageWidth - 50;
formPrintView.height = printJob.pageHeight - 50;   
formPrintView.addElement(instance);
printJob.addObject(formPrintView);

Can you please try my solution below and let me know if it doesnt work. Let us assume you have an UI Component : Page1

var page1:VBox = new VBox();

// Convert class name to Class object.
var cls:Class = getDefinitionByName(page1) as Class;
// Create a new instance of the class.
var instance:UIComponent = new cls();

var formPrintView:MyPrintView = new MyPrintView();
formPrintView.width = printJob.pageWidth - 50;
formPrintView.height = printJob.pageHeight - 50;   
formPrintView.addElement(instance);
printJob.addObject(formPrintView);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文