comp.addChild(sprite);
cavas1.addChild(comp); 这样flash控件就能正常在flex组件里显示了。
举个例子我在as文件中这么写:
Java代码![复制代码](http://hiphotos.baidu.com/everthingandnothing/pic/item/f8d758ad4ba9dbbffaed50a6.jpg)
- <SPAN style="FONT-SIZE: medium">package components
- {
- import flash.display.*;
- import flash.net.URLRequest;
- public class Main extends Sprite {
- public function Main( ) {
- var loader:Loader = new Loader( );
- addChild( loader );
- loader.load( new URLRequest( "img/aa.jpg" ) );
- }
- }
- }</SPAN>
然后具体显示就想上面说的那样 Xml代码
![复制代码](http://hiphotos.baidu.com/everthingandnothing/pic/item/0958ab753fb5235fb151b9a7.jpg)
- <SPAN style="FONT-SIZE: medium"><?xml version="1.0" encoding="utf-8"?>
- <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:s="library://ns.adobe.com/flex/spark"
- xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="init()">
- <fx:Declarations>
- <!-- 将非可视元素(例如服务、值对象)放在此处 -->
- </fx:Declarations>
- <fx:Script>
- <![CDATA[
- import components.Main;
- import mx.core.UIComponent;
- function init():void{
- var comp: UIComponent = new UIComponent();
- var main:Main=new Main();
- comp.addChild(main);
- this.addElement(comp);
- }
- ]]>
- </fx:Script>
- </s:Application>
- </SPAN>