1

我有一个名为 SuperImage.mxml 的组件

   <?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
         xmlns:s="library://ns.adobe.com/flex/spark"
         xmlns:mx="library://ns.adobe.com/flex/mx"
         xmlns:client="com.asfdfdfd.chat.client.*"
         xmlns:component="com.asfdfdfd.chat.client.component.*">
    <fx:Script>
        <![CDATA[
            import com.asfdfdfd.chat.client.managers.Red5CommandNetConnectionManager;
            import com.gyaro.utils.PathUtils;

            import mx.controls.Image;
            import mx.controls.SWFLoader;
            import mx.controls.VideoDisplay;
            import mx.core.UIComponent;
            import mx.events.ResizeEvent;
            import mx.events.VideoEvent;

            private var _swfLoader:SWFLoader=null;

            private var _loader:Loader=null;

            private var _source:Object=null;

            public function get source():Object
            {
                return _source;
            }

            public function set source(value:Object):void
            {
                for (var i:int=0; i < numElements; i++)
                {
                    removeElementAt(0);
                }

                _source=value;

                if (!_source)
                {
                    return;
                }

                var className:String=flash.utils.getQualifiedClassName(value);
                var classType:Object=flash.utils.getDefinitionByName(className);

//                trace(className);

                if (classType == UIComponent)
                {
                    var uiComponent:UIComponent=value as UIComponent;
                    uiComponent.percentWidth=100;
                    uiComponent.percentHeight=100;

                    addElement(uiComponent as UIComponent);
                }
                else if (classType == String)
                {
                    createItem(value as String);
                }
                else if (classType == URLRequest)
                {
                    createItem((value as URLRequest).url);
                }
                else if (classType == Image)
                {
                    var image:Image=value as Image;
                    image.percentWidth=100;
                    image.percentHeight=100;

                    addElement(image as Image);
                }
            }

            private function createItem(url:String):void
            {
                if (PathUtils.getFileExt(url) == "flv" || url.search("rtmp://") == 0)
                {
                    if (url.search("rtmp://") == 0)
                    {
                        url+=".flv";

                        var ns:NetStream=new NetStream(Red5CommandNetConnectionManager.instance.netConnection);
                        ns.addEventListener(NetStatusEvent.NET_STATUS, function(e:NetStatusEvent):void
                        {
                            switch (e.info.code)
                            {
                                case "NetStream.Play.Stop":
                                    ns.seek(0);
                                    break;
                            }
                        });
                        ns.client=new Object();
                        ns.client.onMetaData=function(data:Object):void
                        {
                        }
                        ns.bufferTime=0.0001;
                        ns.play(PathUtils.getFileName(url));

                        var video:Video=new Video();
                        video.attachNetStream(ns);

                        var uic:UIComponent=new UIComponent();
                        uic.addEventListener(ResizeEvent.RESIZE, function(e:ResizeEvent):void
                        {
                            video.width=uic.width;
                            video.height=uic.height;
                        });
                        uic.percentWidth=100;
                        uic.percentHeight=100;
                        uic.addChild(video);

                        addElement(uic);
                    }
                    else
                    {
                        var videoDisplay:VideoDisplay=new VideoDisplay();
                        videoDisplay.autoRewind=true;
                        videoDisplay.autoPlay=true;
                        videoDisplay.volume=0;
                        videoDisplay.percentWidth=100;
                        videoDisplay.percentHeight=100;
                        videoDisplay.maintainAspectRatio=false;
                        videoDisplay.bufferTime=0.001;
                        videoDisplay.addEventListener(mx.events.VideoEvent.COMPLETE, function(e:mx.events.VideoEvent):void
                        {
                            videoDisplay.play();
                        });

                        videoDisplay.source=url;

                        addElement(videoDisplay);
                    }
                }
                else
                {
                    var swfLoader:SWFLoader=new SWFLoader();

                    swfLoader.addEventListener(Event.COMPLETE, function(e:Event):void
                    {
                        addElement(swfLoader);
                    });

                    swfLoader.soundTransform=new SoundTransform(0);
                    swfLoader.scaleContent=true;
                    swfLoader.maintainAspectRatio=false;
                    swfLoader.load(url);
                    swfLoader.percentWidth=100;
                    swfLoader.percentHeight=100;
                }
            }
        ]]>
    </fx:Script>
</s:Group>    

现在,此代码允许使用重定向链接等脚本上传用户外部 swf 文件。我正在使用此代码在个人资料图片中上传 swf。

我想禁用用户在 swf 文件中添加的重定向代码。我怎样才能 ?

请回复完整代码。

4

0 回答 0