Hi folks,

I am trying to create a custom Button in AS3 using the Flex 2 SDK. It is pretty simple; I just want it to be a wedge shape that I can rotate to point in an arbitrary direction. My code is attached below, but I'm stuck on two issues:

1. Making it behave as regular buttons do in terms of mouse-over and mouse-down behavior (i.e. draw it differently in these cases).

2. Currently, when I rotate it, e.g.:

          <Arrow_Button height="12" width="12" rotation="45"
                        click="Alert.show('hello');"/>

it rotates around its 0,0 point, causing it to swing out of the area where Flash "thinks" it is, messing up the layout.

I've been wandering through the docs and Google all afternoon, but I haven't figured these things out.

Any help or pointers to appropriate documentation would be very much appreciated.

TIA,

Reid


// This class defines a button which looks like an arrow. It points up // and relies on the rotation property to be pointed in the right
// direction.

package {

   import flash.display.Graphics;
   import mx.controls.Button;
   import mx.core.UIComponent;

   public class Arrow_Button extends Button
   {

      override protected function updateDisplayList(wd:Number,
                                                    ht:Number) :void
      {
         var gr:Graphics = this.graphics;
         gr.clear();
         gr.lineStyle(1);
         gr.beginFill(0xff8800);
         gr.moveTo(0, ht);
         gr.lineTo(wd, ht);
         gr.lineTo(wd/2, 0);
         gr.lineTo(0, ht);
      }

   }

}

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to