How to decrease the size of a button which contains an image?

How to decrease the size of a button which contains an image?

I have a button in which it contains an image.But my problem here is i am unable to decrease the width of the button along with image.

If you observer in the screen shot all images are small excpet the line image.

If possible provide me some sample code.

Below is my sample code:

 <mx:Button id="line" toggle="true" paddingLeft="1" paddingRight="1" icon="@Embed(source='Images/line.png')" toolTip="Line" useHandCursor="true" buttonMode="true" click="doDrawEnable()" ></mx:Button>

Thanks,
Alam.
Demo.doc
alamflexAsked:
Who is Participating?
 
dgofmanCommented:
Try this

<?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" width="100%" height="100%">
      <fx:Script>
            <![CDATA[
                  import mx.core.IFlexDisplayObject;
                  import mx.core.mx_internal;
                  import mx.events.FlexEvent;

                  protected function changeIconSize(event:FlexEvent):void
                  {
                        var button:Button = event.target as Button;
                        var icon:IFlexDisplayObject = button.mx_internal::currentIcon;
                        icon.width = 20;
                        icon.height = 20;
                        button.invalidateDisplayList();
                  }

            ]]>
      </fx:Script>

      <mx:Button id="line" toggle="true" paddingLeft="1" paddingRight="1"
                     icon="@Embed(source='Images/line.png')" toolTip="Line"
                     useHandCursor="true" buttonMode="true"
                     click="doDrawEnable()" creationComplete="changeIconSize(event)"/>
</s:Application>
0
 
alamflexAuthor Commented:
Hi Thanks for your reply,

I don't want zooming effect. just i need constant button which contains line image over it.The code which you have provided is zooming. I want a button like it should be pressed when we click on line button similar to toggle button on/off effect should be there.so that user user can come to know whether that button is pressed or not.
0
 
dgofmanCommented:
set explicite width and height

  <mx:Button width="100" height="100"/>
0
 
dgofmanCommented:
What solution are you looking for?>
0
 
WallyModCommented:
No response from the OP so proceeding with applicable solution

WallyMod
Community Support Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.