加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

如何将BasicView添加到Flex UIComponent中。

发布时间:2020-12-15 01:36:28 所属栏目:百科 来源:网络整理
导读:原文转载如下: Adding a BasicView to a Flex UIComponent ? While I would always encourage to separate your code into separate classes to follow best OOP practices,the example below will “get the job done”. Since the Flex framework is base

原文转载如下:

Adding a BasicView to a Flex UIComponent

?

While I would always encourage to separate your code into separate classes to follow best OOP practices,the example below will “get the job done”.

Since the Flex framework is based off UIComponents and you can’t directly add Sprites (or BasicViews) to a UIComponent,you have to dig into the UIComponents rawChildren (meaning Sprites) to add Papervision3D.

?

?

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
??? width="640"
??? height="480"
??? xmlns:mx="http://www.adobe.com/2006/mxml"
??? layout="absolute"
??? applicationComplete="applicationComplete()">
??? <mx:Script>
??? ??? <![CDATA[
/*??? ??? ??? There are two similar methods:
??? ??? ??? 1. using rawChildren
??? ??? ??? 2. using $addChild with the mx_interal namespace
??? ??? ??? Method #2 is commented out below
*/???
//??? ??? ??? use namespace mx_internal; //method #2
?
??? ??? ??? import org.papervision3d.objects.primitives.Sphere;
??? ??? ??? import org.papervision3d.view.BasicView;
??? ??? ??? private function applicationComplete():void
??? ??? ??? {
??? ??? ??? ??? var basicView:BasicView = new BasicView();
??? ??? ??? ??? var sphere:Sphere = new Sphere();
??? ??? ??? ??? basicView.scene.addChild(sphere);
??? ??? ??? ??? basicView.startRendering();
??? ??? ??? ??? pv3dPanel.rawChildren.addChild(basicView); //method #1
//??? ??? ??? ??? pv3dPanel.$addChild(basicView); //method #2
??? ??? ??? }
??? ??? ]]>
??? </mx:Script>
??? <mx:Panel id="pv3dPanel" title="Papervision3D Panel" width="640" height="480"/>
</mx:Application>

============================= //add by sing

?

以上代码是flex3下可以正常使用,在flex4下要做如下修改:

例如要将basicView添加到Group中。代码如下:

?

var uicomponent: UIComponent = new UIComponent(); uicomponent.addChild(basicView); sGroup.addElementAt(uicomponent,0);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读