views:

37

answers:

1

Hi,

I am trying to add a link to an image using ActionScript. I do not see the link no matter what. Below is my code, Can you please suggest what am I doing wrong.

  <?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>
+1  A: 

Two suggestions:

  1. The button is being covered up by the image because of the order you are adding them. Add the button after the image instead of before it.

  2. You won't be able to see the button unless you specify a height & width.

Ex:

but.width = 100;
but.height = 100;
Greg W
Try setting the dimensions of `dollLoader` too. Using `UIComponent` as a parent container can give unexpected results. What happens if you change the `UIComponent` to a `Canvas` or `VBox`?
Sly_cardinal
Just setting the width and height .... solved the problem.but.width = 100;but.height = 100;thank you
firemonkey