Apache flex 我正在尝试在图像上添加链接

Apache flex 我正在尝试在图像上添加链接,apache-flex,actionscript-3,Apache Flex,Actionscript 3,我正在尝试使用ActionScript向图像添加链接。无论发生什么,我都看不到链接。下面是我的代码,你能告诉我我做错了什么吗 <?xml version="1.0" encoding="utf-8"?> <mx:Application creationComplete="application1_creationCompleteHandler(event)" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute

我正在尝试使用ActionScript向图像添加链接。无论发生什么,我都看不到链接。下面是我的代码,你能告诉我我做错了什么吗

  <?xml version="1.0" encoding="utf-8"?>
<mx:Application creationComplete="application1_creationCompleteHandler(event)" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600">
    <mx:Script>
        <![CDATA[
            import mx.controls.Button;
            import mx.controls.Image;
            import mx.events.FlexEvent;

            protected function application1_creationCompleteHandler(event:FlexEvent):void
            {               
                var but:Button = new Button();
                but.label = "BUT";
                uic.addChild(but);
                      var dollLoader:Loader=new Loader();  
                                dollLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, dollCompleteHandler);  
                                var dollRequest:URLRequest =  new URLRequest("http://www.google.com/intl/en_ALL/images/logo.gif");  
                                dollLoader.load(dollRequest);  
                                uic.addChild(dollLoader);  

                }

            private function dollCompleteHandler(event:Event):void   
                        {  


                        }  

        ]]>
    </mx:Script>

    <mx:UIComponent id="uic" width="100%" height="100%">

    </mx:UIComponent>

</mx:Application>

两条建议:

  • 由于您添加按钮的顺序,该按钮被图像覆盖。将按钮添加到图像后,而不是图像前

  • 除非指定高度和宽度,否则无法看到该按钮

  • 例:


    也可以尝试设置
    dollLoader
    的尺寸。使用
    UIComponent
    作为父容器可能会产生意外的结果。如果将
    ui组件
    更改为
    Canvas
    VBox
    ,会发生什么情况?只需设置宽度和高度。。。。解决了这个问题。但是,宽度=100;但是,高度=100;非常感谢。
    but.width = 100;
    but.height = 100;