Stop Dragging TitleWindow

I was under a bit of time pressure and trying to stop dragging of a TitleWindow PopUp. I tried all sorts of funky stuff like intercepting the onMouseDown Event and using Event.stopImmediatePropogation() to no avail. I also wanted access to the titleBar exclusively so here is an extended TitleWindow which enables both my requirements and stops the dragging of a TitleWindow.

Actionscript:
  1. package com.newtriks.view.components.utils
  2. {
  3.     import flash.events.MouseEvent;
  4.     import mx.containers.TitleWindow;
  5.     import mx.core.IUIComponent;
  6.     import mx.core.UIComponent;
  7.  
  8.     public class PopUpTitle extends TitleWindow
  9.     {
  10.         public function PopUpTitle()
  11.         {
  12.             super();   
  13.         }
  14.        
  15.         override protected function startDragging( event:MouseEvent ):void
  16.         {
  17.         }
  18.        
  19.         override protected function updateDisplayList( unscaledWidth:Number, unscaledHeight:Number ):void
  20.         {
  21.             super.updateDisplayList( unscaledWidth, unscaledHeight );
  22.             if ( numChildren )
  23.             {
  24.                 var child:IUIComponent = IUIComponent( getChildAt(0) );
  25.                 child.setActualSize( unscaledWidth, child.getExplicitOrMeasuredHeight() );
  26.             }
  27.         }
  28.        
  29.         public function getTitleBar():UIComponent
  30.         {
  31.             return super.titleBar;
  32.         }
  33.     }
  34. }

This entry was posted in AS3, Flex and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

4 Comments

  1. Flex Man
    Posted August 28, 2009 at 3:38 pm | Permalink

    A simpler solution would be to set the "isPopUp" property to true for the TitleWindow.

    i.e. On the TitleWindow component call the following function with the creationComplete event:

    ...
    private function init():void{
    this.isPopUp = true;
    }

  2. Posted August 28, 2009 at 3:50 pm | Permalink

    Thanks for the comment, but isPopUp = true won't stop the TitleWindow from dragging!

  3. Flex Man
    Posted September 2, 2009 at 8:32 am | Permalink

    Whoops, sorry for the mistake - you have to set isPopUp to FALSE to stop dragging ;)

    i.e. On the TitleWindow component call the following function with the creationComplete event:

    ...
    private function init():void{
    this.isPopUp = false;
    }

  4. Posted September 2, 2009 at 8:48 am | Permalink

    Yeh a few ways to skin a cat indeed, what you where trying to explain can be seen fully by the fantastic resource known to many Flex Examples - Peter deHaan!

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • FreeAgent sign-up


  • Recent Posts

  • Categories