Flex 4 通过在打印区域中添加动态项目进行打印(又名:如何将动态命名的元素动态添加到另一个元素)
我有许多动态添加到舞台上的项目。
这些称为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试下面的解决方案吗?如果不起作用请告诉我。让我们假设您有一个 UI 组件:Page1
Can you please try my solution below and let me know if it doesnt work. Let us assume you have an UI Component : Page1