Charles Parcell wrote:
>

Hi Charles,

Thanks for your help!

I am not very versed on Flex Builder it self, but my first question is to
ask why you are importing UICompnent? I can only guess that you have not
pasted in all of your code here.

That's because I was trying to decide whether to subclass Button or UIComponent -- so far, they seem to work the same, but subclassing Button results in a gradiented roundrect being drawn over my own stuff. It's all there; just substitute UIComponent for Button when you read the code. :)

Second, why not draw your arrow so that its center is at 0,0?

This helps, but the layout is still kind of wonky. This also seems like an odd solution to me; this would mean that people drawing components would have to always work in four quadrants of the Cartesian plane instead of just one.

Thanks,

Reid

On 12/22/06, Reid Priedhorsky <[EMAIL PROTECTED]> wrote:

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);
       }

    }

}

_______________________________________________
[email protected]
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