Core IAnimator in Spark

Man, it's very difficult to customize the animation system in spark.  I realize that a lot of effort is going into it, but why not take a look at how simple and powerful openflux solved the problem?
For instance, in Spark, mixed into the core of the ScrollBar and the Slider are "private" variables for an "Animation" object that controls animating scrolling.  Hardcore...  There are a few things difficult about this approach:
1) You don't have access to that animator, other than through hard-coded instance methods that, if that philosophy were applied everywhere in Flex would get totally unmanageable.
2) There is no consistency in the design in which these animators are used, no interface, it's almost like they're just there to solve some super specific case, but good luck trying to solve the next.
3) It's built into the scrollbar, like the Scrollbar was built into the Flex 3 Container, and that wasn't the best idea.  A "ScrollBar" doesn't by nature need an animator that animates its scrolling.  That's an add-on.
If the UIComponent just had an IAnimator property that stored an object that could animate anything (or "play" "Animation" instances), that would be much more flexible.  And I could use TweenMax or Tweener if I'd like, or Away3D's animation stuff using Flex's IAnimator interface.
In addition, this would make it extremely easy to animate layout properties, and animate between layouts (from Vertical to Horizontal for instance).  To wire that up right now would be tough:  I'd have to create my own Vertical and Horizontal Layouts and implement this whole system, or hack together something that would be hard to reuse or customize.  All you'd need to do is add a controller to a component that grabbed a layoutElement position token and ran it through the animator, and the animator could do the fancy matrix/layout bound stuff.
I don't see why that's an issue.  If someone has a reason why they don't want to do this, please let me know, because from my experience it's been a wonderful tool and makes development exciting and much easier.
Best,
Lance

Thanks for the great reply Chet.
Makes a lot of sense about wanting to get something out there, I know what it's like to try to take on too grand a task at once.
The question of whether or not there should be an 'animator' property applies to a lot more than just that.  It's definitely arguable that the UIComponent doesn't need an IAnimator built in, but then again it doesn't need a 'tooltip', 'errorString', 'cursorManager', or 'repeater' either.  Those would be attached to components through controllers, IAttachables, or something.  That's somewhat how the effects work.
I would put the 'animator' into the UIComponent just for simplicity, so you don't have to import it every time you want to use it, and so it doesn't have to be a manager.  Plus it now has a direct "target" it is attached to.  If it were like the effect, and you wanted every component to be animated, you would either have to create a ton of IAnimator objects manually, or do some tricky 'findById" business in your document if you wanted to abstract it away.
My only thing is I can easily animate state changes in the skin, and changes in/between layouts, using a simple Animator that's built into the Container/Group that the layout has access too.  Here's how I did the layouts (off the top of my head):
VerticalLayout:
// keeps calculations very formal
public function getToken(child:IVisualElement, index:int):Object
     var token:Object = {};
     ... calculate x and y like normal, but just for the current index (we're basically in the for-loop now
     token.x = x;
     token.y = y;
     return token;
public function updateDisplayList():void
     for (i; i < numElements; i++)
          var child:IVisualElement = layoutElements[i];
          var token:Object = getToken(child, i);
          if (target.animator)
               target.animator.animate(child, token);
          else
               child.setLayoutBoundsPosition(token.x, token.y);
... It would be even easier for developers if they just passed in the animation token (could be a typed object) and the child into the IAnimator, and it figured out if we wanted to animate it (from CSS or wherever), and if not, just did the "setLayoutBounds..." stuff.  That's how I'm doing it now.  Once I translate the VerticalLayout and HorizontalLayout into it I'll post it up, I'm working on the Coverflow now.
But basically, this is the API I'm using for layouts (only showing the 'updateDisplayList' part now).  I don't have to customize this in subclasses:
public function updateDisplayList():void
     for (i; i < numElements; i++)
          var child:IVisualElement = layoutElements[i];
          var token:Object = getToken(child, i);
          if (layoutModifier != null)
               layoutModifier(token, child, i); // function so you can customize layout variables just before they are set.
          animator.animate(child, token);
Then the developer just implements the "getToken(child, index)" method, keeping it simple, and giving you access to the token if you wanted to customize it in your MXML view.  To make a StepLayout from the VerticalLayout following this pattern, you'd just do something like this:
<spark:VerticalLayout layoutModifier="makeItStep"/>
public function makeItStep(token:Object, child:IVisualElement, index:int):void
     token.x = token.x * i;
.. or into an arc, you'd just do some trigonometry stuff, and you could add all kinds of state logic, animation between layouts, etc., without ever copy-pasting code or extending core layout classes, which are not easy to make.
I would love to try out maybe making it a manager or something, but that just makes it so the manager has to keep track of a billion things, and I have to import that everywhere I want to use it (which is everywhere).  I don't really like the idea of making it like the effects, where you have to have 50 lines of MXML just to make a ball bounce, or a button to do some interesting stuff with key frames.  Or to animate skins with tons of fills and gradients, it would get crazy.  That can be solved like this:
protected function stateChangeHandler(event:StateChangeEvent):void
     if (event.newState != event.oldState)
          for (i; i < numElements; i++)
               var child:IVisualElement = skin.layoutElements[i];
               var token:Object = getToken(child, i);
               animator.animate(child, token);
And that token can either be an IEffect, or something used by TweenMax, Tweener, etc, and the animator will figure out how to "play" or run that.
Having it part of the UIComponent would just make it so we didn't have to think about how to animate things, it would just "work".  Otherwise it's a little more complicated, that's probably why not many people use really designer effects/animations with Flex right now.
Best,
Lance

Similar Messages

  • Using swf for source of spark image

    Hi, I'm not sure if something changed in flex 4.5.1 but I have a published version of my app from earlier (flex 4.0) that uses a spark image control and I'm able to assign a swf as the source and it displays no problem. I just tried in my newest version and I recieve an error "Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@e523f91 to flash.display.Bitmap". I'm not trying to access any properties -- just setting '.source = abc.swf'.
    Anyone have any idea why I can't assign a swf to an image control anymore?

    Yeah, it was harder than I thought it would be.  I got it to display with this subclass of BitmapImage, but I didn’t beat it up so there might be other issues:
    package
    import flash.display.Sprite;
    import flash.display.LoaderInfo;
    import spark.core.IGraphicElement;
    import spark.core.DisplayObjectSharingMode;
    import spark.primitives.BitmapImage;
    import mx.events.FlexEvent;
    public class MyBitmapImage extends BitmapImage
        private var imageWidth:Number;
        private var imageHeight:Number;
        override protected function measure():void
            super.measure();
            measuredWidth = imageWidth;
            measuredHeight = imageHeight;
        override public function canShareWithPrevious(element:IGraphicElement):Boolean
            return false;
        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
            super.updateDisplayList(unscaledWidth, unscaledHeight);
        override protected function contentComplete(content:Object):void
            var loaderInfo:LoaderInfo = content as LoaderInfo;
            // For untrusted content we must host the acquired Loader
           // instance directly as our DisplayObject.
           displayObjectSharingMode = DisplayObjectSharingMode.OWNS_UNSHARED_OBJECT;
            invalidateDisplayObjectSharing();
            // Create a content holder to use as our display object.
           var contentHolder:Sprite = new Sprite();
            setDisplayObject(contentHolder);
            contentHolder.addChild(loaderInfo.loader);
            // Retain our source image width and height.
           imageWidth = loaderInfo.width;
            imageHeight = loaderInfo.height ;
            // Update
           if (!explicitHeight || !explicitWidth)
                invalidateSize();
            invalidateDisplayList();
            // Dispatch ready event
           dispatchEvent(new FlexEvent(FlexEvent.READY));

  • Group degradation in perceived performance

    Hi there,
    We recently upgraded to SDK 4.5.1 and noticed that our application took a hit in perceived responsiveness in the process. After digging around a bit I ran into a change in the Group class that is responsible for this degradation, the change itself is in bold:
        override public function set scrollRect(value:Rectangle):void    {        // Work-around for Flash Player bug: if GraphicElements share        // the Group's Display Object and cacheAsBitmap is true, the        // scrollRect won't function correctly.         var previous:Boolean = canShareDisplayObject;        super.scrollRect = value;         if (numGraphicElements > 0 && previous != canShareDisplayObject)            invalidateDisplayObjectOrdering();          if (mouseEnabledWhereTransparent && hasMouseListeners)        {                    // Re-render our mouse event fill if necessary.            redrawRequested = true;            super.$invalidateDisplayList();        }    }
    Below please find a small application that illustrates this problem. Note that I have monkey patched Group in the default package so that it is possible to compile with and without the code above. I find that a large screen and Chrome help showcase the problem.
    The part that I am not getting is what was the code in bold trying to fix in the first place?
    Thanks!!
    ~ Miguel
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application
        minWidth="955" minHeight="600"
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/mx"
        xmlns:local="*">
        <fx:Script>
            <![CDATA[
                private var _moveMode:Boolean = false;
                protected function monkeypatchedgroup1_mouseMoveHandler(event:MouseEvent):void
                    // TODO Auto-generated method stub
                    if (_moveMode)
                        redBox.x = event.stageX;
                        redBox.y = event.stageY;
                protected function bordercontainer1_mouseDownHandler(event:MouseEvent):void
                    // TODO Auto-generated method stub
                    _moveMode = true;
                protected function monkeypatchedgroup1_mouseUpHandler(event:MouseEvent):void
                    // TODO Auto-generated method stub
                    _moveMode = false;
            ]]>
        </fx:Script>
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <local:MonkeyPatchedGroup
            width="100%" height="100%"
            mouseMove="monkeypatchedgroup1_mouseMoveHandler(event)"
            mouseUp="monkeypatchedgroup1_mouseUpHandler(event)">
            <s:BorderContainer id="redBox"
                width="50" height="50"
                backgroundColor="red"
                mouseDown="bordercontainer1_mouseDownHandler(event)"/>
        </local:MonkeyPatchedGroup>
    </s:Application>
    Here is the monkey patched group:
    //  ADOBE SYSTEMS INCORPORATED
    //  Copyright 2008 Adobe Systems Incorporated
    //  All Rights Reserved.
    //  NOTICE: Adobe permits you to use, modify, and distribute this file
    //  in accordance with the terms of the license agreement accompanying it.
    package
        import flash.display.BlendMode;
        import flash.display.DisplayObject;
        import flash.geom.Rectangle;
        import mx.core.FlexVersion;
        import mx.core.IFlexModule;
        import mx.core.IFontContextComponent;
        import mx.core.IUIComponent;
        import mx.core.IUITextField;
        import mx.core.IVisualElement;
        import mx.core.IVisualElementContainer;
        import mx.core.UIComponent;
        import mx.core.mx_internal;
        import mx.events.FlexEvent;
        import mx.graphics.shaderClasses.ColorBurnShader;
        import mx.graphics.shaderClasses.ColorDodgeShader;
        import mx.graphics.shaderClasses.ColorShader;
        import mx.graphics.shaderClasses.ExclusionShader;
        import mx.graphics.shaderClasses.HueShader;
        import mx.graphics.shaderClasses.LuminosityShader;
        import mx.graphics.shaderClasses.SaturationShader;
        import mx.graphics.shaderClasses.SoftLightShader;
        import mx.styles.IAdvancedStyleClient;
        import mx.styles.ISimpleStyleClient;
        import mx.styles.IStyleClient;
        import mx.styles.StyleProtoChain;
        import spark.components.ResizeMode;
        import spark.components.supportClasses.GroupBase;
        import spark.core.DisplayObjectSharingMode;
        import spark.core.IGraphicElement;
        import spark.core.IGraphicElementContainer;
        import spark.core.ISharedDisplayObject;
        import spark.events.ElementExistenceEvent;
        use namespace mx_internal;
        //  Events
         *  Dispatched when a visual element is added to the content holder.
         *  <code>event.element</code> is the visual element that was added.
         *  @eventType spark.events.ElementExistenceEvent.ELEMENT_ADD
         *  @langversion 3.0
         *  @playerversion Flash 10
         *  @playerversion AIR 1.5
         *  @productversion Flex 4
        [Event(name = "elementAdd", type = "spark.events.ElementExistenceEvent")]
         *  Dispatched when a visual element is removed from the content holder.
         *  <code>event.element</code> is the visual element that's being removed.
         *  @eventType spark.events.ElementExistenceEvent.ELEMENT_REMOVE
         *  @langversion 3.0
         *  @playerversion Flash 10
         *  @playerversion AIR 1.5
         *  @productversion Flex 4
        [Event(name = "elementRemove", type = "spark.events.ElementExistenceEvent")]
        //  Styles
         *  Color of text shadows.
         *  @default #FFFFFF
         *  @langversion 3.0
         *  @playerversion Flash 10
         *  @playerversion AIR 1.5
         *  @productversion Flex 4
        [Style(name = "textShadowColor", type = "uint", format = "Color", inherit = "yes", theme = "mobile")]
         *  Alpha of text shadows.
         *  @default 0.55
         *  @langversion 3.0
         *  @playerversion Flash 10
         *  @playerversion AIR 1.5
         *  @productversion Flex 4
        [Style(name = "textShadowAlpha", type = "Number", inherit = "yes", minValue = "0.0", maxValue = "1.0", theme = "mobile")]
        //  Excluded APIs
        [Exclude(name = "addChild", kind = "method")]
        [Exclude(name = "addChildAt", kind = "method")]
        [Exclude(name = "removeChild", kind = "method")]
        [Exclude(name = "removeChildAt", kind = "method")]
        [Exclude(name = "setChildIndex", kind = "method")]
        [Exclude(name = "swapChildren", kind = "method")]
        [Exclude(name = "swapChildrenAt", kind = "method")]
        [Exclude(name = "numChildren", kind = "property")]
        [Exclude(name = "getChildAt", kind = "method")]
        [Exclude(name = "getChildIndex", kind = "method")]
        //  Other metadata
        [ResourceBundle("components")]
        [DefaultProperty("mxmlContent")]
        [IconFile("Group.png")]
         *  The Group class is the base container class for visual elements.
         *  The Group container takes as children any components that implement
         *  the IUIComponent interface, and any components that implement
         *  the IGraphicElement interface.
         *  Use this container when you want to manage visual children,
         *  both visual components and graphical components.
         *  <p>To improve performance and minimize application size,
         *  the Group container cannot be skinned.
         *  If you want to apply a skin, use the SkinnableContainer instead.</p>
         *  <p><b>Note:</b> The scale grid might not function correctly when there
         *  are DisplayObject children inside of the Group, such as a component
         *  or another Group.  If the children are GraphicElement objects, and
         *  they all share the Group's DisplayObject, then the scale grid works
         *  properly.</p>
         *  <p>Setting any of the following properties on a GraphicElement child
         *  requires that GraphicElement to create its own DisplayObject,
         *  thus negating the scale grid properties on the Group.</p>
         *  <pre>
         *  alpha
         *  blendMode other than BlendMode.NORMAL or "auto"
         *  colorTransform
         *  filters
         *  mask
         *  matrix
         *  rotation
         *  scaling
         *  3D properties
         *  bounds outside the extent of the Group
         *  </pre>
         *  <p>The Group container has the following default characteristics:</p>
         *  <table class="innertable">
         *     <tr><th>Characteristic</th><th>Description</th></tr>
         *     <tr><td>Default size</td><td>Large enough to display its children</td></tr>
         *     <tr><td>Minimum size</td><td>0 pixels</td></tr>
         *     <tr><td>Maximum size</td><td>10000 pixels wide and 10000 pixels high</td></tr>
         *  </table>
         *  @mxml
         *  <p>The <code>&lt;s:Group&gt;</code> tag inherits all of the tag
         *  attributes of its superclass and adds the following tag attributes:</p>
         *  <pre>
         *  &lt;s:Group
         *    <strong>Properties</strong>
         *    blendMode="auto"
         *    mxmlContent="null"
         *    scaleGridBottom="null"
         *    scaleGridLeft="null"
         *    scaleGridRight="null"
         *    scaleGridTop="null"
         *    <strong>Events</strong>
         *    elementAdd="<i>No default</i>"
         *    elementRemove="<i>No default</i>"
         *  /&gt;
         *  </pre>
         *  @see spark.components.DataGroup
         *  @see spark.components.SkinnableContainer
         *  @includeExample examples/GroupExample.mxml
         *  @langversion 3.0
         *  @playerversion Flash 10
         *  @playerversion AIR 1.5
         *  @productversion Flex 4
        public class MonkeyPatchedGroup extends GroupBase implements IVisualElementContainer, IGraphicElementContainer, ISharedDisplayObject
             *  Constructor.
             *  @langversion 3.0
             *  @playerversion Flash 10
             *  @playerversion AIR 1.5
             *  @productversion Flex 4
            public function MonkeyPatchedGroup():void
                super();
            //  Variables
            private var needsDisplayObjectAssignment:Boolean = false;
            private var layeringMode:uint = ITEM_ORDERED_LAYERING;
            private var numGraphicElements:uint = 0;
            private static const ITEM_ORDERED_LAYERING:uint = 0;
            private static const SPARSE_LAYERING:uint = 1;
            //  Overridden properties
            //  baselinePosition
             *  @inheritDoc
             *  @langversion 3.0
             *  @playerversion Flash 10
             *  @playerversion AIR 1.5
             *  @productversion Flex 4
            override public function get baselinePosition():Number
                if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_4_5)
                    return super.baselinePosition;
                if (!validateBaselinePosition())
                    return NaN;
                var bElement:IVisualElement = baselinePositionElement;
                // If no baselinePositionElement is specified, use the first element
                if (bElement == null)
                    for (var i:int = 0; i < numElements; i++)
                        var elt:IVisualElement = getElementAt(i);
                        if (elt.includeInLayout)
                            bElement = elt;
                            break;
                if (bElement)
                    return bElement.baselinePosition + bElement.y;
                else
                    return super.baselinePosition;
            [Inspectable(category = "General", enumeration = "noScale,scale", defaultValue = "noScale")]
             *  @private
            override public function set resizeMode(value:String):void
                if (isValidScaleGrid())
                    // Force the resize mode to be scale if we
                    // have set scaleGrid properties
                    value = ResizeMode.SCALE;
                super.resizeMode = value;
             *  @private
            override public function set scrollRect(value:Rectangle):void
                // Work-around for Flash Player bug: if GraphicElements share
                // the Group's Display Object and cacheAsBitmap is true, the
                // scrollRect won't function correctly.
                var previous:Boolean = canShareDisplayObject;
                super.scrollRect = value;
                if (numGraphicElements > 0 && previous != canShareDisplayObject)
                    invalidateDisplayObjectOrdering();
                if (mouseEnabledWhereTransparent && hasMouseListeners)
                    // Re-render our mouse event fill if necessary.
                    redrawRequested = true;
                    trace("Calling invalidateDisplayList in GroupBase");
                    super.$invalidateDisplayList();
             * @private
            override mx_internal function set hasMouseListeners(value:Boolean):void
                if (mouseEnabledWhereTransparent)
                    redrawRequested = true;
                super.hasMouseListeners = value;
             *  @private
            override public function set width(value:Number):void
                if (_width != value)
                    if (mouseEnabledWhereTransparent && hasMouseListeners)
                        // Re-render our mouse event fill if necessary.
                        redrawRequested = true;
                        super.$invalidateDisplayList();
                super.width = value;
             *  @private
            override public function set height(value:Number):void
                if (_height != value)
                    if (mouseEnabledWhereTransparent && hasMouseListeners)
                        // Re-render our mouse event fill if necessary.
                        redrawRequested = true;
                        super.$invalidateDisplayList();
                super.height = value;
            //  Properties
            //  alpha
            [Inspectable(defaultValue = "1.0", category = "General", verbose = "1")]
             *  @private
            override public function set alpha(value:Number):void
                if (super.alpha == value)
                    return;
                if (_blendMode == "auto")
                    // If alpha changes from an opaque/transparent (1/0) and translucent
                    // (0 < value < 1), then trigger a blendMode change
                    if ((value > 0 && value < 1 && (super.alpha == 0 || super.alpha == 1)) || ((value == 0 || value == 1) && (super.alpha > 0 && super.alpha < 1)))
                        blendModeChanged = true;
                        invalidateDisplayObjectOrdering();
                        invalidateProperties();
                super.alpha = value;
            //  baselinePositionElement
            private var _baselinePositionElement:IVisualElement;
             *  The element used to calculate the GroupBase's baselinePosition
             *  @langversion 3.0
             *  @playerversion Flash 10
             *  @playerversion AIR 1.5
             *  @productversion Flex 4
            public function get baselinePositionElement():IVisualElement
                return _baselinePositionElement;
             *  @private
            public function set baselinePositionElement(value:IVisualElement):void
                if (value === _baselinePositionElement)
                    return;
                _baselinePositionElement = value;
                invalidateParentSizeAndDisplayList();
            //  blendMode
             *  @private
             *  Storage for the blendMode property.
            private var _blendMode:String = "auto";
            private var blendModeChanged:Boolean;
            private var blendShaderChanged:Boolean;
            [Inspectable(category = "General", enumeration = "auto,add,alpha,darken,difference,erase,hardlight,invert,layer,lighten,multiply,normal,subtract,screen,overlay,colordodge,colorburn,exclusion,softlight,hue,saturation,color,luminosity", defaultValue = "auto")]
             *  A value from the BlendMode class that specifies which blend mode to use.
             *  A bitmap can be drawn internally in two ways.
             *  If you have a blend mode enabled or an external clipping mask, the bitmap is drawn
             *  by adding a bitmap-filled square shape to the vector render.
             *  If you attempt to set this property to an invalid value,
             *  Flash Player or Adobe AIR sets the value to <code>BlendMode.NORMAL</code>.
             *  <p>A value of "auto" (the default) is specific to Group's use of
             *  blendMode and indicates that the underlying blendMode should be
             *  <code>BlendMode.NORMAL</code> except when <code>alpha</code> is not
             *  equal to either 0 or 1, when it is set to <code>BlendMode.LAYER</code>.
             *  This behavior ensures that groups have correct
             *  compositing of their graphic objects when the group is translucent.</p>
             *  @default "auto"
             *  @see flash.display.DisplayObject#blendMode
             *  @see flash.display.BlendMode
             *  @langversion 3.0
             *  @playerversion Flash 10
             *  @playerversion AIR 1.5
             *  @productversion Flex 4
            override public function get blendMode():String
                return _blendMode;
             *  @private
            override public function set blendMode(value:String):void
                if (value == _blendMode)
                    return;
                invalidateProperties();
                blendModeChanged = true;
                //The default blendMode in FXG is 'auto'. There are only
                //certain cases where this results in a rendering difference,
                //one being when the alpha of the Group is > 0 and < 1. In that
                //case we set the blendMode to layer to avoid the performance
                //overhead that comes with a non-normal blendMode.
                if (value == "auto")
                    _blendMode = value;
                    // SDK-29631: Use super.$blendMode instead of super.blendMode
                    // since Group completely overrides blendMode and we
                    // want to bypass the extra logic in UIComponent which
                    // has its own override.
                    // TODO (egeorgie): figure out whether we can share some
                    // of that logic in the future.
                    if (((alpha > 0 && alpha < 1) && super.$blendMode != BlendMode.LAYER) || ((alpha == 1 || alpha == 0) && super.$blendMode != BlendMode.NORMAL))
                        invalidateDisplayObjectOrdering();
                else
                    var oldValue:String = _blendMode;
                    _blendMode = value;
                    // If one of the non-native Flash blendModes is set,
                    // record the new value and set the appropriate
                    // blendShader on the display object.
                    if (isAIMBlendMode(value))
                        blendShaderChanged = true;
                    // Only need to re-do display object assignment if blendmode was normal
                    // and is changing to something else, or the blend mode was something else
                    // and is going back to normal.  This is because display object sharing
                    // only happens when blendMode is normal.
                    if ((oldValue == BlendMode.NORMAL || value == BlendMode.NORMAL) && !(oldValue == BlendMode.NORMAL && value == BlendMode.NORMAL))
                        invalidateDisplayObjectOrdering();
            //  mxmlContent
            private var mxmlContentChanged:Boolean = false;
            private var _mxmlContent:Array;
            [ArrayElementType("mx.core.IVisualElement")]
             *  The visual content children for this Group.
             *  This method is used internally by Flex and is not intended for direct
             *  use by developers.
             *  <p>The content items should only be IVisualElement objects.
             *  An <code>mxmlContent</code> Array should not be shared between multiple
             *  Group containers because visual elements can only live in one container
             *  at a time.</p>
             *  <p>If the content is an Array, do not modify the Array
             *  directly. Use the methods defined by the Group class instead.</p>
             *  @default null
             *  @langversion 3.0
             *  @playerversion Flash 10
             *  @playerversion AIR 1.5
             *  @productversion Flex 4
            public function set mxmlContent(value:Array):void
                if (createChildrenCalled)
                    setMXMLContent(value);
                else
                    mxmlContentChanged = true;
                    _mxmlContent = value;
                        // we will validate this in createChildren();
             *  @private
            mx_internal function getMXMLContent():Array
                if (_mxmlContent)
                    return _mxmlContent.concat();
                else
                    return null;
             *  @private
             *  Adds the elements in <code>mxmlContent</code> to the Group.
             *  Flex calls this method automatically; you do not call it directly.
             *  @langversion 3.0
             *  @playerversion Flash 10
             *  @playerversion AIR 1.5
             *  @productversion Flex 4
            private function setMXMLContent(value:Array):void
                var i:int;
                // if there's old content and it's different than what
                // we're trying to set it to, then let's remove all the old
                // elements first.
                if (_mxmlContent != null && _mxmlContent != value)
                    for (i = _mxmlContent.length - 1; i >= 0; i--)
                        elementRemoved(_mxmlContent[i], i);
                _mxmlContent = (value) ? value.concat() : null; // defensive copy
                if (_mxmlContent != null)
                    var n:int = _mxmlContent.length;
                    for (i = 0; i < n; i++)
                        var elt:IVisualElement = _mxmlContent[i];
                        // A common mistake is to bind the viewport property of a Scroller
                        // to a group that was defined in the MXML file with a different parent   
                        if (elt.parent && (elt.parent != this))
                            throw new Error(resourceManager.getString("components", "mxmlElementNoMultipleParents",
                                                                      [ elt ]));
                        elementAdded(elt, i);
            //  Properties: ScaleGrid
            private var scaleGridChanged:Boolean = false;
            // store the scaleGrid into a rectangle to save space (top, left, bottom, right);
            private var scaleGridStorageVariable:Rectangle;
            //  scale9Grid
             *  @private
            override public function set scale9Grid(value:Rectangle):void
                if (value != null)
                    scaleGridTop = value.top;
                    scaleGridBottom = value.bottom;
                    scaleGridLeft = value.left;
                    scaleGridRight = value.right;
                else
                    scaleGridTop = NaN;
                    scaleGridBottom = NaN;
                    scaleGridLeft = NaN;
                    scaleGridRight = NaN;
            //  scaleGridBottom
            [Inspectable(category = "General")]
             *  Specifies the bottom coordinate of the scale grid.
             *  @langversion 3.0
             *  @playerversion Flash 10
             *  @playerversion AIR 1.5
             *  @productversion Flex 4
            public function get scaleGridBottom():Number
                if (scaleGridStorageVariable)
                    return scaleGridStorageVariable.height;
                return NaN;
            public function set scaleGridBottom(value:Number):void
                if (!scaleGridStorageVariable)
                    scaleGridStorageVariable = new Rectangle(NaN, NaN, NaN, NaN);
                if (value != scaleGridStorageVariable.height)
                    scaleGridStorageVariable.height = value;
                    scaleGridChanged = true;
                    invalidateProperties();
                    invalidateDisplayList();
            //  scaleGridLeft
            [Inspectable(category = "General")]
             * Specifies the left coordinate of the scale grid.
             *  @langversion 3.0
             *  @playerversion Flash 10
             *  @playerversion AIR 1.5
             *  @productversion Flex 4
            public function get scaleGridLeft():Number
                if (scaleGridStorageVariable)
                    return scaleGridStorageVariable.x;
                return NaN;
            public function set scaleGridLeft(value:Number):void
                if (!scaleGridStorageVariable)
                    scaleGridStorageVariable = new Rectangle(NaN, NaN, NaN, NaN);
                if (value != scaleGridStorageVariable.x)
                    scaleGridStorageVariable.x = value;
                    scaleGridChanged = true;
                    invalidateProperties();
                    invalidateDisplayList();
            //  scaleGridRight
            [Inspectable(category = "General")]
             * Specifies the right coordinate of the scale grid.
             *  @langversion 3.0
             *  @playerversion Flash 10
             *  @playerversion AIR 1.5
             *  @productversion Flex 4
            public function get scaleGridRight():Number
                if (scaleGridStorageVariable)
                    return scaleGridStorageVariable.width;
                return NaN;
            public function set scaleGridRight(value:Number):void
                if (!scaleGridStorageVariable)
                    scaleGridStorageVariable = new Rectangle(NaN, NaN, NaN, NaN);
                if (value != scaleGridStorageVariable.width)
                    scaleGridStorageVariable.width = value;
                    scaleGridChanged = true;
                    invalidateProperties();
                    invalidateDisplayList();
            //  scaleGridTop
            [Inspectable(category = "General")]
             * Specifies the top coordinate of the scale grid.
             *  @langversion 3.0
             *  @playerversion Flash 10
             *  @playerversion AIR 1.5
             *  @productversion Flex 4
            public function get scaleGridTop():Number
                if (scaleGridStorageVariable)
                    return scaleGridStorageVariable.y;
                return NaN;
            public function set scaleGridTop(value:Number):void
                if (!scaleGridStorageVariable)
                    scaleGridStorageVariable = new Rectangle(NaN, NaN, NaN, NaN);
                if (value != scaleGridStorageVariable.y)
                    scaleGridStorageVariable.y = value;
                    scaleGridChanged = true;
                    invalidateProperties();
                    invalidateDisplayList();
            private function isValidScaleGrid():Boolean
                return !isNaN(scaleGridLeft) && !isNaN(scaleGridTop) && !isNaN(scaleGridRight) && !isNaN(scaleGridBottom);
            //  Overridden methods: UIComponent
             *  @private
             *  Whether createChildren() has been called or not.
             *  We use this in the setter for mxmlContent to know
             *  whether to validate the value immediately, or just
             *  wait to let createChildren() do it.
            private var createChildrenCalled:Boolean = false;
             *  @private
            override protected function createChildren():void
                super.createChildren();
                createChildrenCalled = true;
                if (mxmlContentChanged)
                    mxmlContentChanged = false;
                    setMXMLContent(_mxmlContent);
             *  @private
            override public function validateProperties():void
                super.validateProperties();
                // Property validation happens top-down, so now let's
                // validate graphic element properties after
                // calling super.validateProperties()
                if (numGraphicElements > 0)
                    var length:int = numElements;
                    for (var i:int = 0; i < length; i++)
                        var element:IGraphicElement = getElementAt(i) as IGraphicElement;
                        if (element)
                            element.validateProperties();
             *  @private
            override protected function commitProperties():void
                super.commitProperties();
                invalidatePropertiesFlag = false;
                if (blendModeChanged)
                    blendModeChanged = false;
                    // Figure out the correct blendMode value
                    // to set.
                    // SDK-29631: Use super.$blendMode instead of super.blendMode
                    // since Group completely overrides blendMode and we
                    // want to bypass the extra logic in UIComponent which
                    // has its own override.
                    // TODO (egeorgie): figure out whether we can share some
                    // of that logic in the future.
                    if (_blendMode == "auto")
                        if (alpha == 0 || alpha == 1)
                            super.$blendMode = BlendMode.NORMAL;
                        else
                            super.$blendMode = BlendMode.LAYER;
                    else if (!isAIMBlendMode(_blendMode))
                        super.$blendMode = _blendMode;
                    if (blendShaderChanged)
                        // The graphic element's blendMode was set to a non-Flash
                        // blendMode. We mimic the look by instantiating the
                        // appropriate shader class and setting the blendShader
                        // property on the displayObject.
                        blendShaderChanged = false;
                        switch (_blendMode)
                            case "color":
                                super.blendShader = new ColorShader();
                                break;
                            case "colordodge":
                                super.blendShader = new ColorDodgeShader();
                                break;
                            case "colorburn":
                                super.blendShader = new ColorBurnShader();
                                break;
                            case "exclusion":
                                super.blendShader = new ExclusionShader();
                                break;
                            case "hue":
                                super.blendShader = new HueShader();
                                break;
                            case "luminosity":
                                super.blendShader = new LuminosityShader();
                                break;
                            case "saturation":
                                super.blendShader = new SaturationShader();
                                break;
                            case "softlight":
                                super.blendShader = new SoftLightShader();
                                break;
                // Due to dependent properties alpha and blendMode there may be a need
                // for a second pass at committing properties (to ensure our new
                // blendMode or blendShader is assigned to our underlying display
                // object).
                if (invalidatePropertiesFlag)
                    super.commitProperties();
                    invalidatePropertiesFlag = false;
                if (needsDisplayObjectAssignment)
                    needsDisplayObjectAssignment = false;
                    assignDisplayObjects();
                if (scaleGridChanged)
                    // Don't reset scaleGridChanged since we also check it in updateDisplayList
                    if (isValidScaleGrid())
                        resizeMode = ResizeMode.SCALE; // Force the resizeMode to scale
             *  @private
            override public function validateSize(recursive:Boolean = false):void
                // Since IGraphicElement is not ILayoutManagerClient, we need to make sure we
                // validate sizes of the elements, even in cases where recursive==false.
                // Size validation happens bottom-up, so now let's
                // validate graphic element size before
                // calling super.validateSize()
                if (numGraphicElements > 0)
                    var length:int = numElements;
                    for (var i:int = 0; i < length; i++)
                        var element:IGraphicElement = getElementAt(i) as IGraphicElement;
                        if (element)
                            element.validateSize();
                super.validateSize(recursive);
             *  @private
            override public function setActualSize(w:Number, h:Number):void
                if (_width != w || _height != h)
                    if (mouseEnabledWhereTransparent && hasMouseListeners)
                        // Re-render our mouse event fill if necessary.
                        redrawRequested = true;
                        super.$invalidateDisplayList();
                super.setActualSize(w, h);
             *  @private
            override public function validateDisplayList():void
                // call super.validateDisplayList() and let updateDisplayList() run
                super.validateDisplayList();
                // If the DisplayObject assignment is still not completed, then postpone validation
                // of the GraphicElements. invalidateDisplayList() will be called during the next
                // commitProperties() call since needsDisplayObjectAssignment=true,
                // so we will be re-running validateDisplayList() anyways
                if (needsDisplayObjectAssignment && invalidatePropertiesFlag)
                    return;
                // DisplayList validation happens top-down, so we should
                // validate graphic element DisplayList after
                // calling super.validateDisplayList().  This is
                // gets tricky because of graphic-element sharing.  We clear
                // Group's graphic's object in updateDisplayList() and handle the
                // rest of the DisplayList validation in here.
                // Iterate through the graphic elements. If an element has a displayObject that has been
                // invalidated, then validate all graphic elements that draw to this displayObject.
                // The algorithm assumes that all of the elements that share a displayObject are in between
                // the element with the shared displayObject and the next element that has a displayObject.
                var sharedDisplayObject:ISharedDisplayObject = this;
                if (numGraphicElements > 0)
                    var length:int = numElements;
                    for (var i:int = 0; i < length; i++)
                        var element:IGraphicElement = getElementAt(i) as IGraphicElement;
                        if (!element)
                            continue;
                        // Do a special check for layer, we may stumble upon an element with layer != 0
                        // before we're done with the current shared sequence and we don't want to mark
                        // the sequence as valid, until we reach the next sequence.  
                        if (element.depth == 0)
                            // Is this the start of a new shared sequence?         
                            if (element.displayObjectSharingMode != DisplayObjectSharingMode.USES_SHARED_OBJECT)
                                // We have finished redrawing the previous sequence
                                if (sharedDisplayObject)
                                    sharedDisplayObject.redrawRequested = false;
                                // Start the new sequence
                                sharedDisplayObject = element.displayObject as ISharedDisplayObject;
                            if (!sharedDisplayObject || sharedDisplayObject.redrawRequested)
                                element.validateDisplayList();
                        else
                            // If we have layering, we don't share the display objects.
                            // Don't update the current sharedDisplayObject
                            var elementDisplayObject:ISharedDisplayObject = element.displayObject as ISharedDisplayObject;
                            if (!elementDisplayObject || elementDisplayObject.redrawRequested)
                                element.validateDisplayList();
                                if (elementDisplayObject)
                                    elementDisplayObject.redrawRequested = false;
                // Mark the last shared displayObject valid
                if (sharedDisplayObject)
                    sharedDisplayObject.redrawRequested = false;
             *  @private
            override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
                // let user's code (layout) run first before dealing with graphic element
                // sharing because that's when redraws can be requested
                super.updateDisplayList(unscaledWidth, unscaledHeight);
                // Clear the group's graphic because graphic elements might be drawing to it
                // This isn't needed for DataGroup because there's no DisplayObject sharing
                // This code exists in updateDisplayList() as opposed to validateDisplayList()
                // because of compatibility issues since most of this code was
                // refactored from updateDisplayList() and in to validateDisplayList().  User's code
                // already assumed that they could call super.updateDisplayList() and then be able to draw
                // into the Group's graphics object.  Because of that, the graphics.clear() call is left
                // in updateDisplayList() instead of in validateDisplayList() with the rest of the graphic
                // element sharing code.
                var sharedDisplayObject:ISharedDisplayObject = this;
                if (sharedDisplayObject.redrawRequested)
                    // clear the graphics here.  The pattern is usually to call graphics.clear()
                    // before calling super.updateDisplayList() so what happens in super.updateDisplayList()
                    // isn't erased.  However, in this case, what happens in super.updateDisplayList() isn't
                    // much, and we want to make sure super.updateDisplayList() runs first since the layout
                    // is what actually triggers the the shareDisplayObject to request to be redrawn.
                    graphics.clear();
                    drawBackground();
                    // If a scaleGrid is set, make sure the extent of the groups bounds are filled so
                    // the player will scale our contents as expected.
                    if (isValidScaleGrid() && resizeMode == ResizeMode.SCALE)
                        graphics.lineStyle();
                        graphics.beginFill(0, 0);
                        graphics.drawRect(0, 0, 1, 1);
                        graphics.drawRect(measuredWidth - 1, measuredHeight - 1, 1, 1);
                        graphics.endFill();
                if (scaleGridChanged)
                    scaleGridChanged = false;
                    if (isValidScaleGrid())
                        // Check for DisplayObjects other than overlays
                        var overlayCount:int = _overlay ? _overlay.numDisplayObjects : 0;
                        if (numChildren - overlayCount > 0)
                            throw new Error(resourceManager.getString("components", "scaleGridGroupError"));
                        super.scale9Grid = new Rectangle(scaleGridLeft,
                                                         scaleGridTop,
                                                         scaleGridRight - scaleGridLeft,
                                                         scaleGridBottom - scaleGridTop);
                    else
                        super.scale9Grid = null;
             *  @private
             *  TODO (rfrishbe): Most of this code is a duplicate of UIComponent::notifyStyleChangeInChildren,
             *  refactor as appropriate to avoid code duplication once we have a common
             *  child iterator between UIComponent and Group.
            override public function notifyStyleChangeInChildren(
                styleProp:String, recursive:Boolean):void
                if (mxmlContentChanged || !recursive)
                    return;
                var n:int = numElements;
                for (var i:int = 0; i < n; i++)
                    var child:ISimpleStyleClient = getElementAt(i) as ISimpleStyleClient;
                    if (child)
                        child.styleChanged(styleProp);
                        if (child is IStyleClient)
                            IStyleClient(child).notifyStyleChangeInChildren(styleProp,
                                                                            recursive);
                if (advanceStyleClientChildren != null)
                    for (var styleClient:Object in advanceStyleClientChildren)
                        var iAdvanceStyleClientChild:IAdvancedStyleClient = styleClient as IAdvancedStyleClient;
                        if (iAdvanceStyleClientChild)
                            iAdvanceStyleClientChild.styleChanged(styleProp);
             *  @private
             *  TODO (rfrishbe): Most of this code is a duplicate of UIComponent::regenerateStyleCache,
             *  refactor as appropriate to avoid code duplication once we have a common
             *  child iterator between UIComponent and Group.
            override public function regenerateStyleCache(recursive:Boolean):void
                // Regenerate the proto chain for this object
                initProtoChain();
                // Recursively call this method on each child.
                var n:int = numElements;
                for (var i:int = 0; i < n; i++)
                    var child:IVisualElement = getElementAt(i);
                    if (child is IStyleClient)
                        // Does this object already have a proto chain?
                        // If not, there's no need to regenerate a new one.
                        if (IStyleClient(child).inheritingStyles != StyleProtoChain.STYLE_UNINITIALIZED)
                            IStyleClient(child).regenerateStyleCache(recursive);
                    else if (child is IUITextField)
                        // Does this object already have a proto chain?
                        // If not, there's no need to regenerate a new one.
                        if (IUITextField(child).inheritingStyles)
                            StyleProtoChain.initTextField(IUITextField(child));
                // Call this method on each non-visual StyleClient
                if (advanceStyleClientChildren != null)
                    for (var styleClient:Object in advanceStyleClientChildren)
                        var iAdvanceStyleClientChild:IAdvancedStyleClient = styleClient as IAdvancedStyleClient;
                        if (iAdvanceStyleClientChild && iAdvanceStyleClientChild.inheritingStyles != StyleProtoChain.STYLE_UNINITIALIZED)
                            iAdvanceStyleClientChild.regenerateStyleCache(recursive);
            //  Content management
             *  @private
            override public function get numElements():int
                if (_mxmlContent == null)
                    return 0;
                return _mxmlContent.length;
             *  @private
            override public function getElementAt(index:int):IVisualElement
                // check for RangeError:
                checkForRangeError(index);
                return _mxmlContent[index];
             *  @private
             *  Checks the range of index to make sure it's valid
            private function checkForRangeError(index:int, addingElement:Boolean = false):void
                // figure out the maximum allowable index
                var maxIndex:int = (_mxmlContent == null ? -1 : _mxmlContent.length - 1);
                // if adding an element, we allow an extra index at the end
                if (addingElement)
                    maxIndex++;
                if (index < 0 || index > maxIndex)
                    throw new RangeError(resourceManager.getString("components", "indexOutOfRange",
                                                                   [ index ]));
             * @private
            private function isAIMBlendMode(value:String):Boolean
                if (value == "colordodge" || value == "colorburn" || value == "exclusion" || value == "softlight" || value == "hue" || value == "saturatio

    FYI - This regression has been filed here: http://bugs.adobe.com/jira/browse/SDK-31989

  • Header renderer click handler not working

    Hi All
    Below is code of my header renderer which copied code from default headerrenderer and created new one, I added textinput with down arrow and close button,
    But when i click on close button, I am making filter box invisible, If i put a break point inside griditemrenderer1_mouseOutHandler() function then filter box becomes invisible, but while running in debug mode without break point filter box shows visible only,
    Please let me know where i am doing wrong.
    <?xml version="1.0" encoding="utf-8"?>
    <s:GridItemRenderer minWidth="21" minHeight="21"
                        xmlns:fx="http://ns.adobe.com/mxml/2009"
                        xmlns:s="library://ns.adobe.com/flex/spark"
                        xmlns:mx="library://ns.adobe.com/flex/mx"
                        mouseOver="griditemrenderer1_mouseOverHandler(event)"
                        creationComplete="griditemrenderer1_creationCompleteHandler(event)">
        <fx:Declarations>
            <s:Label id="labelDisplay"
                     verticalCenter="1"
                     textAlign="start"
                     fontWeight="bold"
                     verticalAlign="middle"
                     maxDisplayedLines="1"
                     showTruncationTip="true" />
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import com.db.view.components.FilterPopup;
                import mx.managers.PopUpManager;
                import mx.controls.Menu;
                import mx.events.FlexEvent;
                import spark.components.gridClasses.IGridVisualElement;
                import mx.core.IVisualElement;
                import spark.components.DataGrid;
                import spark.components.GridColumnHeaderGroup;
                import spark.components.gridClasses.GridColumn;
                import spark.primitives.supportClasses.GraphicElement;
                // chrome color constants and variables
                private static const DEFAULT_COLOR_VALUE:uint = 0xCC;
                private static const DEFAULT_COLOR:uint = 0xCCCCCC;
                private static const DEFAULT_SYMBOL_COLOR:uint = 0x000000;
                private static var colorTransform:ColorTransform = new ColorTransform();
                 *  @private
                private function dispatchChangeEvent(type:String):void
                    if (hasEventListener(type))
                        dispatchEvent(new Event(type));
                //  maxDisplayedLines
                private var _maxDisplayedLines:int = 1;
                [Bindable("maxDisplayedLinesChanged")]
                [Inspectable(minValue="-1")]
                 *  The value of this property is used to initialize the
                 *  <code>maxDisplayedLines</code> property of this renderer's
                 *  <code>labelDisplay</code> element.
                 *  @copy spark.components.supportClasses.TextBase#maxDisplayedLines
                 *  @default 1
                 *  @langversion 3.0
                 *  @playerversion Flash 10
                 *  @playerversion AIR 1.5
                 *  @productversion Flex 4.5
                public function get maxDisplayedLines():int
                    return _maxDisplayedLines;
                 *  @private
                public function set maxDisplayedLines(value:int):void
                    if (value == _maxDisplayedLines)
                        return;
                    _maxDisplayedLines = value;
                    if (labelDisplay)
                        labelDisplay.maxDisplayedLines = value;
                    invalidateSize();
                    invalidateDisplayList();
                    dispatchChangeEvent("maxDisplayedLinesChanged");
                 *  @private
                 *  Create and add the sortIndicator to the sortIndicatorGroup and the
                 *  labelDisplay into the labelDisplayGroup.
                override public function prepare(hasBeenRecycled:Boolean):void
                    super.prepare(hasBeenRecycled);
                    if (labelDisplay && labelDisplayGroup && (labelDisplay.parent != labelDisplayGroup))
                        labelDisplayGroup.removeAllElements();
                        labelDisplayGroup.addElement(labelDisplay);
                private var chromeColorChanged:Boolean = false;
                private var colorized:Boolean = false;
                [Bindable]
                private var _filterVisibility:Boolean = false;
                 *  @private
                 *  Apply chromeColor style.
                override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
                    // Apply chrome color
                    if (chromeColorChanged)
                        var chromeColor:uint = getStyle("chromeColor");
                        if (chromeColor != DEFAULT_COLOR || colorized)
                            colorTransform.redOffset = ((chromeColor & (0xFF << 16)) >> 16) - DEFAULT_COLOR_VALUE;
                            colorTransform.greenOffset = ((chromeColor & (0xFF << 8)) >> 8) - DEFAULT_COLOR_VALUE;
                            colorTransform.blueOffset = (chromeColor & 0xFF) - DEFAULT_COLOR_VALUE;
                            colorTransform.alphaMultiplier = alpha;
                            transform.colorTransform = colorTransform;
                            var exclusions:Array = [labelDisplay];
                            // Apply inverse colorizing to exclusions
                            if (exclusions && exclusions.length > 0)
                                colorTransform.redOffset = -colorTransform.redOffset;
                                colorTransform.greenOffset = -colorTransform.greenOffset;
                                colorTransform.blueOffset = -colorTransform.blueOffset;
                                for (var i:int = 0; i < exclusions.length; i++)
                                    var exclusionObject:Object = exclusions[i];
                                    if (exclusionObject &&
                                        (exclusionObject is DisplayObject ||
                                            exclusionObject is GraphicElement))
                                        colorTransform.alphaMultiplier = exclusionObject.alpha;
                                        exclusionObject.transform.colorTransform = colorTransform;
                            colorized = true;
                        chromeColorChanged = false;
                    super.updateDisplayList(unscaledWidth, unscaledHeight);
                 *  @private
                override public function styleChanged(styleProp:String):void
                    var allStyles:Boolean = !styleProp || styleProp == "styleName";
                    super.styleChanged(styleProp);
                    if (allStyles || styleProp == "chromeColor")
                        chromeColorChanged = true;
                        invalidateDisplayList();
                protected function griditemrenderer1_mouseOverHandler(event:MouseEvent):void
                    _filterVisibility = true;
                protected function griditemrenderer1_mouseOutHandler():void
                    _filterVisibility = false;
                protected function griditemrenderer1_creationCompleteHandler(event:FlexEvent):void
                    trace(label);
                protected function textinput1_clickHandler(event:MouseEvent):void
                    var filterpopUp:FilterPopup = new FilterPopup();
                    filterpopUp.filterColumn = label;
                    PopUpManager.addPopUp(filterpopUp,this,false);
                    filterpopUp.addEventListener("test",testHandler);
                    filterpopUp.x = event.stageX - 50;
                    filterpopUp.y = event.stageY + 10;
                protected function testHandler(event:Event):void
                    owner.dispatchEvent(new Event("test"));
            ]]>
        </fx:Script>
        <s:VGroup left="7" right="7" top="5" bottom="5" gap="2" verticalAlign="bottom">
            <s:HGroup id="tiFilter" width="100%" gap="3" verticalAlign="middle" visible="{_filterVisibility}">
                <s:TextInput width="{labelDisplay.width + 20}" height="16" skinClass="com.db.view.skins.FilterTextInputSkin"
                              text="{label}" click="textinput1_clickHandler(event)"/>
                <s:HGroup id="closeBtn" width="15" height="15" click="griditemrenderer1_mouseOutHandler()"
                          buttonMode="true" useHandCursor="true" mouseChildren="false" keyDown="griditemrenderer1_mouseOutHandler()">
                    <s:Image source="@Embed('/assets/images/icon_close.gif')"/>
                </s:HGroup>
            </s:HGroup>
            <s:Group id="labelDisplayGroup" width="100%"/>
            <s:Group id="sortIndicatorGroup" includeInLayout="false" />
        </s:VGroup>
    </s:GridItemRenderer>

    Hi Sudhir,
    Thanks for posting your issue, Kindly find the code snnipet below to Add a new item in Custom list
    public override void ItemAdded(SPItemEventProperties properties)
        base.ItemAdded(properties);
        if (properties.List.Title
    == "Test")
    Get Properties
            string ABC=
    properties.ListItem["Column"].ToString();
            string DEF=
    properties.ListItem["Column"].ToString();
            DateTime XYZ=
    (DateTime)properties.ListItem["Start Column"];
            DateTime WSD=
    (DateTime)properties.ListItem["End Column"];
    Create sub site
            SPWeb web
    = properties.Site.AllWebs.Add(name.Replace(" ", string.Empty),
    name,
                description, 0, SPWebTemplate.WebTemplateSTS, false, false);
            web.Update();
    Also, browse the below mentioned URL to implementation your custom list step by step. and how you can debug your custom code.
    http://www.c-sharpcorner.com/UploadFile/40e97e/create-site-automatically-when-a-list-item-is-added/
    http://msdn.microsoft.com/en-us/library/ee231550.aspx
    I hope this is helpful to you, mark it as Helpful.
    If this works, Please mark it as Answered.
    Regards,
    Dharmendra Singh (MCPD-EA | MCTS)
    Blog : http://sharepoint-community.net/profile/DharmendraSingh

  • Flash Builder & StageVideo

    Hello everyone,
    A major concern arises for me, and after several days of testing I can not find a solution.
    I am currently developing a mobile application on Android to play a video locally.
    For this I use the Adobe SimpleStageVideo class available on the website : http://www.adobe.com/devnet/flashplayer/articles/stage_video.html
    At the launch all goes well , however when I switch to another application in full reading and then I go back to my video .
    That passes over other elements of my interface (ie the navigation menu ) and especially it grows.
    I tried to do a resize an event type activate ( to intercept the return on applicaiton )
    I also tried to remove the container, and then reinject the video in my interface ( although this is costly in resources ... ) .
    It did not work .
    I think during my event "activate " the UIComponent has not yet been fully rebuilt, and thereby resize does not work on a good screen size used (since it does not blow conscidère menus ) .
    To test my theory , I tested passing in debug mode. By running my code slower, the video goes back to the right size ...
    So I tried to put timers, but again it was a futile attempt .
    How is it possible when returning to my application that my video remains the right size , and not overlooking the rest of the menus?
    Here follows the code in question :
    // La Vue Permettant de Visionner la Vidéo
    <?xml version="1.0" encoding="utf-8"?>
    <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
                        xmlns:components="bouton.components.*"
                        xmlns:s="library://ns.adobe.com/flex/spark" title="viewVideo" activate="view1_activateHandler(event)" creationComplete="view1_creationCompleteHandler(event)" backgroundAlpha="0" actionBarVisible="false" tabBarVisible="false">
              <fx:Script>
                        <![CDATA[
                                  import flash.events.MouseEvent;
                                  import mx.core.UIComponent;
                                  import mx.events.FlexEvent;
                                  import valueObjects.SimpleStageVideo;
                                  private var conn:SQLConnection;
                                  private var createStmt:SQLStatement;
                                  public var dbFile:File;
                                  public var fichierCharge:File;
                                  public var numeroBouton:int = 0;
                                  private var test:SimpleStageVideo = new SimpleStageVideo();
                                  private var container:UIComponent = new UIComponent();
                                  protected function view1_creationCompleteHandler(event:FlexEvent):void
                                            var chemin:File = new File(data.url);
                                            test.setData(chemin);
                                            //container.stage = this.stage;
                                            container.height = stage.height;
                                            container.width = stage.width;
                                            container.addChildAt(test, 0);
                                            addElementAt(container, 0);
                                            trace(""+container.width+" : "+container.height+" : "+container.x+" : "+container.y);
                                  protected function view1_activateHandler(event:Event):void
                                            test.resize();
                                  private function resizeF(event:Event):void
                                            test.resize();
                        ]]>
              </fx:Script>
              <s:HGroup  id="barremenu" gap="0" horizontalAlign="left" styleName="header_style" verticalAlign="top" width="100%" contentBackgroundColor="#FFFFFF" contentBackgroundAlpha="1" paddingBottom="50" >
                        <s:Image scaleMode="letterbox" smooth="true" smoothingQuality="high"
                                             source="assets/header_droi.jpg" />
                        <components:Boutton_Retour click="boutton_retour1_clickHandler(event)" enabled="true" height="100%" contentBackgroundColor="#FFFFFF" contentBackgroundAlpha="1"/>
                        <components:Boutton_Accueil_Retour click="boutton_accueil1_clickHandler(event)" enabled="true" height="100%" contentBackgroundColor="#FFFFFF" contentBackgroundAlpha="1" />
                        <s:Image scaleMode="stretch" smooth="true" smoothingQuality="high"
                                             source="assets/header_milieu.jpg" fillMode="repeat" width="60%" height="99%" />
                        <s:Image  scaleMode="stretch" smooth="true" smoothingQuality="high"
                                              source="assets/ipad.jpg" />
              </s:HGroup>
    </s:View>
    // Ma Classe SimpleStageVideo
    package valueObjects
              import flash.display.Loader;
              import flash.display.Shape;
              import flash.display.Sprite;
              import flash.display.Stage;
              import flash.display.StageAlign;
              import flash.display.StageScaleMode;
              import flash.events.Event;
              import flash.events.MouseEvent;
              import flash.events.NetStatusEvent;
              import flash.events.StageVideoAvailabilityEvent;
              import flash.events.StageVideoEvent;
              import flash.events.VideoEvent;
              import flash.filesystem.File;
              import flash.geom.Rectangle;
              import flash.media.StageVideo;
              import flash.media.StageVideoAvailability;
              import flash.media.Video;
              import flash.net.NetConnection;
              import flash.net.NetStream;
              import flash.net.URLRequest;
              import flash.text.TextField;
              import flash.text.TextFieldAutoSize;
              import mx.core.UIComponent;
              import spark.components.Image;
              import spark.components.NavigatorContent;
              [SWF(frameRate="1", backgroundColor="#000000")]
              public class SimpleStageVideo extends Sprite
                        public var chemin:File;
                        private var FILE_NAME:String = "";
                        private static const INTERVAL:Number = 500;
                        private static const BORDER:Number = 20;
                        private var legend:TextField = new TextField();
                        private var sv:StageVideo;
                        private var nc:NetConnection;
                        private var ns:NetStream;
                        private var rc:Rectangle;
                        private var video:Video;
                        private var thumb:Shape;
                        private var interactiveThumb:Sprite;
                        private var totalTime:Number;
                        private var videoWidth:int;
                        private var videoHeight:int;
                        private var outputBuffer:String = new String();
                        private var rect:Rectangle = new Rectangle(0, 0, 0, BORDER);
                        private var videoRect:Rectangle = new Rectangle(0, 0, 0, 0);
                        private var gotStage:Boolean;
                        private var stageVideoInUse:Boolean;
                        private var classicVideoInUse:Boolean;
                        private var accelerationType:String;
                        private var infos:String = new String();
                        private var available:Boolean;
                        private var inited:Boolean;
                        private var played:Boolean;
                        private var container:Sprite;
                        private var displayButtonPause:Boolean;
                        public var imagePause:UIComponent;
                        public var pLoad:Loader;
                        private var testResize:Boolean = false;
                        private var widthStage:int = 0;
                        public function SimpleStageVideo()
                                  // Make sure the app is visible and stage available
                                  addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
                                  //addEventListener(Event.ACTIVATE, onActivate);
                        private function onActivate(event:Event):void
                                  video.addEventListener(Event.RENDER, functionResize);
                        private function functionResize(event:Event):void
                                  resize();
                         * @param event
                        private function onAddedToStage(event:Event):void
                                  // Scaling
                                  stage.scaleMode = StageScaleMode.NO_SCALE;
                                  stage.align = StageAlign.TOP_LEFT;
                                  widthStage = stage.width;
                                  // Thumb seek Bar
                                  thumb = new Shape();
                                  interactiveThumb = new Sprite();
                                  interactiveThumb.addChild(thumb);
                                  addChild(interactiveThumb);
                                  // Connections
                                  nc = new NetConnection();
                                  nc.connect(null);
                                  ns = new NetStream(nc);
                                  ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
                                  ns.client = this;
                                  // Screen
                                  video = new Video();
                                  video.smoothing = true;
                                  // Video Events
                                  // the StageVideoEvent.STAGE_VIDEO_STATE informs you if StageVideo is available or not
                                  stage.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, onStageVideoState);
                                  // in case of fallback to Video, we listen to the VideoEvent.RENDER_STATE event to handle resize properly and know about the acceleration mode running
                                  video.addEventListener(VideoEvent.RENDER_STATE, videoStateChange);
                                  // Input Events
                                  stage.addEventListener(MouseEvent.DOUBLE_CLICK, onKeyDown);
                                  stage.addEventListener(Event.RESIZE,  onResize);
                                  stage.addEventListener(MouseEvent.CLICK, onClick);
                         * @param event
                        private function onNetStatus(event:NetStatusEvent):void
                                  if ( event.info == "NetStream.Play.StreamNotFound" )
                                            legend.text = "Video file passed, not available!";
                        public function setData(chem:File):void
                                  chemin = chem;
                                  FILE_NAME = chemin.url;
                         * @param event
                        private function onFrame(event:Event):void
                                  var ratio:Number = (ns.time / totalTime) * (widthStage+470);
                                  rect.width = ratio;
                                  thumb.graphics.clear();
                                  thumb.graphics.beginFill(0xFF0000);
                                  thumb.graphics.drawRect(rect.x, rect.y+350, rect.width+120, rect.height);
                                  //thumb.graphics.drawRect(rect.x, rect.y, rect.width, rect.height);
                                  //testResize = true;
                         * @param event
                        private function onClick(event:MouseEvent):void
                                  //ns.pause();
                                  if ( event.stageY >= interactiveThumb.y - BORDER && event.stageX <= stage.stageWidth - BORDER )
                                            var seekTime:Number = (stage.mouseX - BORDER) * ( totalTime / (stage.stageWidth - (BORDER << 1) ) );
                                            ns.seek( seekTime );
                         * @param event
                        private function onKeyDown(event:MouseEvent):void
                                  ns.togglePause();
                                  // Affichage du bouton d'affichage de la mise en pause de la video
                                  if(displayButtonPause == false)
                                            pLoad = new Loader();
                                            pLoad.load(new URLRequest("assets/pause.png"));
                                            //imagePause = new UIComponent();
                                            //imagePause.addChild(pLoad);
                                            //imagePause.x = 200;
                                            //imagePause.y = 200;
                                            pLoad.x = (stage.width - (stage.width/3.5));
                                            pLoad.y = (stage.height - (stage.height/3.5));
                                            addChild(pLoad);
                                            displayButtonPause = true;
                                            pLoad.visible = true;
                                  } else
                                            displayButtonPause = false;
                                            pLoad.visible = false;
                                            removeChild(pLoad);
                         * Permet l'arret de la video avant la supression de la vue
                        public function arretVideo():void
                                  //video.clear();
                                  //sv.attachNetStream(null);
                                  ns.close();
                                  //video.attachNetStream(null);
                                  /*var nce:NetConnection = new NetConnection();
                                  nce.connect(null);
                                  sv.attachNetStream(new NetStream(nce));
                                  //sv.attachNetStream();*/
                         * @param width
                         * @param height
                         * @return
                        private function getVideoRect(width:uint, height:uint):Rectangle
                                  trace("Width" + width);
                                  trace("Stage Width" + stage.stageWidth);
                                  trace("Height" + height);
                                  trace("Stage height" + stage.stageHeight);
                                  var videoWidth:uint = width;
                                  var videoHeight:uint = height;
                                  var scaling:Number = Math.min ( stage.stageWidth / videoWidth, stage.stageHeight / videoHeight );
                                  videoWidth *= scaling, videoHeight *= scaling;
                                  var posX:uint = stage.stageWidth - videoWidth >> 1;
                                  var posY:uint = stage.stageHeight - videoHeight >> 1;
                                  videoRect.x = posX;
                                  videoRect.y = posY;
                                  videoRect.width = videoWidth;
                                  videoRect.height = videoHeight;
                                  trace("Objet video width" + video.width);
                                  trace("Objet video height" + video.height);
                                  trace("Objet video rect width" + videoRect.width);
                                  trace("Objet video rect height" + videoRect.height);
                                  return videoRect;
                        public function resize ():void
                                  if ( stageVideoInUse )
                                            // Get the Viewport viewable rectangle
                                            rc = getVideoRect(sv.videoWidth, sv.videoHeight);
                                            // set the StageVideo size using the viewPort property
                                            sv.viewPort = rc;
                                  } else
                                            // Get the Viewport viewable rectangle
                                            rc = getVideoRect(video.videoWidth, video.videoHeight);
                                            // Set the Video object size
                                            video.width = rc.width;
                                            video.height = rc.height;
                                            video.x = rc.x, video.y = rc.y;
                                            //trace(""+rc.width+" : "+rc.height+" : "+rc.x+" : "+rc.y);
                                            testResize = true;
                                  interactiveThumb.x = BORDER, interactiveThumb.y = stage.stageHeight - (BORDER << 1);
                                  legend.text = infos;
                         * @param evt
                        public function onMetaData ( evt:Object ):void
                                  totalTime = evt.duration;
                                  stage.addEventListener(Event.ENTER_FRAME, onFrame);
                         * @param event
                        private function onStageVideoState(event:StageVideoAvailabilityEvent):void
                                  // Detect if StageVideo is available and decide what to do in toggleStageVideo
                                  toggleStageVideo(available = inited = (event.availability == StageVideoAvailability.AVAILABLE));
                         * @param on
                        private function toggleStageVideo(on:Boolean):void
                                  infos = "StageVideo Running (Direct path) : " + on + "\n";
                                  // If we choose StageVideo we attach the NetStream to StageVideo
                                  if (on)
                                            stageVideoInUse = true;
                                            if ( sv == null )
                                                      sv = stage.stageVideos[0];
                                                      sv.addEventListener(StageVideoEvent.RENDER_STATE, stageVideoStateChange);
                                            sv.attachNetStream(ns);
                                            if (classicVideoInUse)
                                                      // If we use StageVideo, we just remove from the display list the Video object to avoid covering the StageVideo object (always in the background)
                                                      stage.removeChild ( video );
                                                      classicVideoInUse = false;
                                  } else
                                            // Otherwise we attach it to a Video object
                                            if (stageVideoInUse)
                                                      stageVideoInUse = false;
                                            classicVideoInUse = true;
                                            video.attachNetStream(ns);
                                            stage.addChildAt(video, 0);
                                  if ( !played )
                                            played = true;
                                            ns.play(FILE_NAME);
                         * @param event
                        private function onResize(event:Event):void
                                  resize();
                         * @param event
                        private function stageVideoStateChange(event:StageVideoEvent):void
                                  infos += "StageVideoEvent received\n";
                                  infos += "Render State : " + event.status + "\n";
                                  trace(infos);
                                  resize();
                         * @param event
                        private function videoStateChange(event:VideoEvent):void
                                  infos += "VideoEvent received\n";
                                  infos += "Render State : " + event.status + "\n";
                                  trace(infos);
                                  resize();

    Hi,
    Don't know if this is an entirely valid answer as I write pure AS3 (no Flex).
    I remember having problems about a year ago with the SimpleStageVideo when doing a video app that would work for both Apple and Android.
    I couldn't get it to work as I wanted so I skipped SimpleStageVideo alltogether.
    I ended up using this script to shift between StageVideo (iOS) and the usual videoPlayer (Android).
    The stageVideo checks if a menu is open (on the left side) and draws the rect according to that.
    The normal video gets it's size from the videoSprite which scales depending on the menu visibility.
    Later when StageVideo became available for Android it still worked.
    Hopefully it can help you get closer to a solution.
    private function load_video():void{   
        if ( stage.stageVideos.length >= 1 ) {   
            stageVideo = stage.stageVideos[0];
            try {
                if(S.application.menu.toggleOpen == true){
                    stageVideo.viewPort = new Rectangle(S.device.scaledVideo.x, S.device.scaledVideo.y, S.device.scaledVideo.width, S.device.scaledVideo.height);
                } else if(S.application.menu.toggleOpen == false){
                    stageVideo.viewPort = new Rectangle(S.device.video.x, S.device.video.y, S.device.video.width, S.device.video.height);
            } catch(e:Error) {}
            stageVideo.addEventListener(StageVideoEvent.RENDER_STATE, renderState);
            stageVideo.attachNetStream(netStream);
        } else {
            try {
                video = new Video(S.device.video.width, S.device.video.height);
                video.smoothing = true
                video.name = "video"
                video.x = S.device.video.x
                video.y = S.device.video.y
                videoSprite.addChild(video);
                video.attachNetStream(netStream);
            } catch(e:Error) {}
        netStream.play(S.path.video + S.application.xmlObjectArray[currentSlideIndex].video);
        videoStarted = true   

  • Tile List Selection indicator

    I have a tile list layout with some thumbnails.
    When one is selected it gets a default blueish background.
    Could someone explain how i would go about putting a nice green tick over a thumbnail once its selected?

    Thank you both for your replies.
    I'm already using a custom component that extends a spark List with layout property set to TileLayout. This is so i can mimick the user holding the CTRL key for multiple selection.
    I also already have a custom item renderer that displays the thumbnail and fires off an event when clicked.
    Really confused as where to put either of your code snippets.
    this is my custom component
    package
         import flash.events.MouseEvent;
         import mx.core.IVisualElement;
         import spark.components.List;
         public class CheckList extends List
              public function CheckList()
                   super();
                   allowMultipleSelection = true;
               * Override the mouseDown handler to act as though the Ctrl key is always down
              override protected function item_mouseDownHandler(event:MouseEvent):void
                   var newIndex:Number = dataGroup.getElementIndex(event.currentTarget as IVisualElement);
                   // always assume the Ctrl key is pressed by setting the third parameter of
                   // calculateSelectedIndices() to true
                   selectedIndices = calculateSelectedIndices(newIndex, event.shiftKey, true);
    and this is my item renderer
    <?xml version="1.0" encoding="utf-8"?>
    <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
                        xmlns:s="library://ns.adobe.com/flex/spark"
                        xmlns:mx="library://ns.adobe.com/flex/mx"
                        autoDrawBackground="true" width="300" height="315" click="thumb_clickHandler(event)">
         <mx:Image id="thumb" x="25" y="26" width="250" height="265" source="{data.thumburl}"/>
         <fx:Script>
              <![CDATA[
                   import flashx.textLayout.factory.TruncationOptions;
                   import mx.controls.Alert;
                   import mx.events.ItemClickEvent;
                   protected function thumb_clickHandler(event:MouseEvent):void
                        var ev:ItemClickEvent = new ItemClickEvent(ItemClickEvent.ITEM_CLICK, true);
                        ev.item = data;
                        ev.index = itemIndex;
                        //Alert.show(ev.item.imageurl);
                        dispatchEvent(ev);
              ]]>
         </fx:Script>
    </s:ItemRenderer>
    Any help you can give me would be great, the code is getting really messy, should i merge these into one class?

  • How not to sort datagrid column on double click

    Hello,
    I am currently building an application containing a datagrid for data representation. I've created a custom datagridheader in order to add a input text for filtering the columns (see code below).
    My goal is to hide the textinput, and then show it on a double click on the header. So i would like to know how to avoid the sort of this column each time i double click.?
    <?xml version="1.0" encoding="utf-8"?>
    <s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
                        xmlns:s="library://ns.adobe.com/flex/spark"
                        xmlns:mx="library://ns.adobe.com/flex/mx" resize="onColumnResize(event)" clipAndEnableScrolling="true" doubleClick="managefilterField(event)">
        <fx:Declarations>
            <!--- The default value of the <code>sortIndicator</code> property.
            It must be an IFactory for an IVisualElement.       
            <p>This value is specified in a <code>fx:Declaration</code> block and can be overridden
            by a declaration with <code>id="defaultSortIndicator"</code>
            in an MXML subclass.</p>
            @langversion 3.0
            @playerversion Flash 10
            @playerversion AIR 2.0
            @productversion Flex 4.5
            -->
            <fx:Component id="defaultSortIndicator">
                <s:Path data="M 3.5 7.0 L 0.0 0.0 L 7.0 0.0 L 3.5 7.0" implements="spark.components.gridClasses.IGridVisualElement">
                    <fx:Script>
                        <![CDATA[
                            import spark.components.DataGrid;
                            import spark.components.Grid;
                             *  @private
                            public function prepareGridVisualElement(grid:Grid, rowIndex:int, columnIndex:int):void
                                const dataGrid:DataGrid = grid.dataGrid;
                                if (!dataGrid)
                                    return;
                                const color:uint = dataGrid.getStyle("symbolColor");
                                arrowFill1.color = color;
                                arrowFill2.color = color;
                        ]]>
                    </fx:Script>
                    <s:fill>
                        <s:RadialGradient rotation="90" focalPointRatio="1">   
                            <!--- @private -->
                            <s:GradientEntry id="arrowFill1" color="0" alpha="0.6" />
                            <!--- @private -->
                            <s:GradientEntry id="arrowFill2" color="0" alpha="0.8" />
                        </s:RadialGradient>
                    </s:fill>
                </s:Path>
            </fx:Component>
            <!--- Displays the renderer's label property, which is set to the column's <code>headerText</code>.
            It must be an instance of a <code>TextBase</code>, like <code>s:Label</code>.
            <p>This visual element is added to the <code>labelDisplayGroup</code> by the renderer's
            <code>prepare()</code> method.   Any size/location constraints specified by the labelDisplay
            define its location relative to the labelDisplayGroup.</p>
            <p>This value is specified with a <code>fx:Declaration</code> and can be overridden
            by a declaration with <code>id="labelDisplay"</code>
            in an MXML subclass.</p>
            @langversion 3.0
            @playerversion Flash 10
            @playerversion AIR 2.0
            @productversion Flex 4.5
            -->
            <s:Label id="labelDisplay"
                     verticalCenter="1" left="0" right="0" top="0" bottom="0"
                     textAlign="start"
                     fontWeight="bold"
                     verticalAlign="middle"
                     maxDisplayedLines="1"
                     showTruncationTip="true" />
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import net.awl.ismp.console.components.misc.FilterCriteria;
                import net.awl.ismp.console.events.ColumnFilteredEvent;
                import net.awl.ismp.console.events.ColumnResizedEvent;
                import mx.events.ResizeEvent;
                import spark.components.gridClasses.IGridVisualElement;
                import mx.core.IVisualElement;
                import spark.components.DataGrid;
                import spark.components.GridColumnHeaderGroup;
                import spark.components.gridClasses.GridColumn;
                import spark.primitives.supportClasses.GraphicElement;
                // chrome color constants and variables
                private static const DEFAULT_COLOR_VALUE:uint = 0xCC;
                private static const DEFAULT_COLOR:uint = 0xCCCCCC;
                private static const DEFAULT_SYMBOL_COLOR:uint = 0x000000;
                private static var colorTransform:ColorTransform = new ColorTransform();
                 *  @private
                private function dispatchChangeEvent(type:String):void
                    if (hasEventListener(type))
                        dispatchEvent(new Event(type));                   
                protected function onColumnResize(event:ResizeEvent):void
                    dispatchEvent(new ColumnResizedEvent(ColumnResizedEvent.COLUMNRESIZED_EVT,this.width,this.column.columnInde x));
                //  maxDisplayedLines
                private var _maxDisplayedLines:int = 1;
                [Bindable("maxDisplayedLinesChanged")]
                [Inspectable(minValue="-1")]
                 *  The value of this property is used to initialize the
                 *  <code>maxDisplayedLines</code> property of this renderer's
                 *  <code>labelDisplay</code> element.
                 *  @copy spark.components.supportClasses.TextBase#maxDisplayedLines
                 *  @default 1
                 *  @langversion 3.0
                 *  @playerversion Flash 10
                 *  @playerversion AIR 1.5
                 *  @productversion Flex 4.5
                public function get maxDisplayedLines():int
                    return _maxDisplayedLines;
                override protected function stateChanged(oldState:String, newState:String, recursive:Boolean):void
                    trace("state changed from : "+oldState+" to "+newState);
                    super.stateChanged(oldState, newState, recursive);
                 *  @private
                public function set maxDisplayedLines(value:int):void
                    if (value == _maxDisplayedLines)
                        return;
                    _maxDisplayedLines = value;
                    if (labelDisplay)
                        labelDisplay.maxDisplayedLines = value;
                    invalidateSize();
                    invalidateDisplayList();
                    dispatchChangeEvent("maxDisplayedLinesChanged");
                //  sortIndicator
                private var _sortIndicator:IFactory;
                private var sortIndicatorInstance:IVisualElement;
                [Bindable("sortIndicatorChanged")]
                 *  A visual element that's displayed when the column is sorted.
                 *  <p>The sortIndicator visual element is added to the <code>sortIndicatorGroup</code>
                 *  by this renderer's <code>prepare()</code> method.  Any size/location constraints
                 *  specified by the sortIndicator define its location relative to the sortIndicatorGroup.</p>
                 *  @default null
                 *  @langversion 3.0
                 *  @playerversion Flash 10
                 *  @playerversion AIR 1.5
                 *  @productversion Flex 4.5
                public function get sortIndicator():IFactory
                    return (_sortIndicator) ? _sortIndicator : defaultSortIndicator;
                 *  @private
                public function set sortIndicator(value:IFactory):void
                    trace("setSortIndicator");
                    if (_sortIndicator == value)
                        return;
                    _sortIndicator = value;
                    if (sortIndicatorInstance)
                        sortIndicatorGroup.includeInLayout = false;
                        sortIndicatorGroup.removeElement(sortIndicatorInstance);
                        sortIndicatorInstance = null;
                    invalidateDisplayList();
                    dispatchChangeEvent("sortIndicatorChanged");
                 *  @private
                 *  Create and add the sortIndicator to the sortIndicatorGroup and the
                 *  labelDisplay into the labelDisplayGroup.
                override public function prepare(hasBeenRecycled:Boolean):void
                    trace("prepare !!");
                    super.prepare(hasBeenRecycled);
                    if (labelDisplay && labelDisplayGroup && (labelDisplay.parent != labelDisplayGroup))
                        labelDisplayGroup.removeAllElements();
                        labelDisplayGroup.addElement(labelDisplay);
                    trace(sortIndicator);
                    trace("sortIndicatorInstance : "+sortIndicatorInstance);
                    const column:GridColumn = this.column;
                    if (sortIndicator && column && column.grid && column.grid.dataGrid && column.grid.dataGrid.columnHeaderGroup)
                        const dataGrid:DataGrid = column.grid.dataGrid;
                        const columnHeaderGroup:GridColumnHeaderGroup = dataGrid.columnHeaderGroup;
                        if (columnHeaderGroup.isSortIndicatorVisible(column.columnIndex))
                            if (!sortIndicatorInstance)
                                sortIndicatorInstance = sortIndicator.newInstance();
                                sortIndicatorGroup.addElement(sortIndicatorInstance);
                                chromeColorChanged = true;
                                invalidateDisplayList();
                            // Initialize sortIndicator
                            sortIndicatorInstance.visible = true;
                            const gridVisualElement:IGridVisualElement = sortIndicatorInstance as IGridVisualElement;
                            if (gridVisualElement)
                                gridVisualElement.prepareGridVisualElement(column.grid, -1, column.columnIndex);
                            sortIndicatorGroup.includeInLayout = true;
                            sortIndicatorGroup.scaleY = (column.sortDescending) ? 1 : -1;
                        else
                            if (sortIndicatorInstance)
                                sortIndicatorGroup.removeElement(sortIndicatorInstance);
                                sortIndicatorGroup.includeInLayout = false;
                                sortIndicatorInstance = null;
                private var chromeColorChanged:Boolean = false;
                private var colorized:Boolean = false;
                 *  @private
                 *  Apply chromeColor style.
                override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
                    //trace("update display list");
                    // Apply chrome color
                    if (chromeColorChanged)
                        var chromeColor:uint = getStyle("chromeColor");
                        if (chromeColor != DEFAULT_COLOR || colorized)
                            colorTransform.redOffset = ((chromeColor & (0xFF << 16)) >> 16) - DEFAULT_COLOR_VALUE;
                            colorTransform.greenOffset = ((chromeColor & (0xFF << 8)) >> 8) - DEFAULT_COLOR_VALUE;
                            colorTransform.blueOffset = (chromeColor & 0xFF) - DEFAULT_COLOR_VALUE;
                            colorTransform.alphaMultiplier = alpha;
                            transform.colorTransform = colorTransform;
                            var exclusions:Array = [labelDisplay, sortIndicatorInstance];
                            // Apply inverse colorizing to exclusions
                            if (exclusions && exclusions.length > 0)
                                colorTransform.redOffset = -colorTransform.redOffset;
                                colorTransform.greenOffset = -colorTransform.greenOffset;
                                colorTransform.blueOffset = -colorTransform.blueOffset;
                                for (var i:int = 0; i < exclusions.length; i++)
                                    var exclusionObject:Object = exclusions[i];
                                    if (exclusionObject &&
                                        (exclusionObject is DisplayObject ||
                                            exclusionObject is GraphicElement))
                                        colorTransform.alphaMultiplier = exclusionObject.alpha;
                                        exclusionObject.transform.colorTransform = colorTransform;
                            colorized = true;
                        chromeColorChanged = false;
                    super.updateDisplayList(unscaledWidth, unscaledHeight);
                 *  @private
                override public function styleChanged(styleProp:String):void
                    var allStyles:Boolean = !styleProp || styleProp == "styleName";
                    super.styleChanged(styleProp);
                    if (allStyles || styleProp == "chromeColor")
                        chromeColorChanged = true;
                        invalidateDisplayList();
                protected function managefilterField(event:MouseEvent):void
                    trace("double click sortIndicator : "+this.sortIndicatorInstance);
                    this.filterInput.visible=!this.filterInput.visible;
                    this.filterInput.includeInLayout=this.filterInput.visible;
                    this.filterSpacer.visible=this.filterInput.visible;
                    this.filterSpacer.includeInLayout=this.filterInput.visible;
                    if(!this.filterInput.visible)
                        this.filterInput.text="";
                        dispatchEvent(new ColumnFilteredEvent(ColumnFilteredEvent.COLUMNFILTERED_EVT,new FilterCriteria(this.column.dataField,this.filterInput.text)));
                    this.filterInput.setStyle("borderColor",0xFF6319);
                    this.filterInput.setStyle("focusColor",0xFF6319);
                    //this.filterInput.setStyle(
                protected function onTextInputSelection(event:MouseEvent):void
                    event.stopImmediatePropagation();
                    this.filterInput.setStyle("borderColor",0xFF6319);
                    this.filterInput.setStyle("focusColor",0xFF6319);
                protected function onKeyUp(event:KeyboardEvent):void
                    if(event.charCode==Keyboard.ENTER)
                        stage.focus=null;
                protected function onFocusOut(event:FocusEvent):void
                    this.filterInput.setStyle("borderColor",0x00ff00);
                    this.filterInput.setStyle("focusColor",0x70B2EE);
                    dispatchEvent(new ColumnFilteredEvent(ColumnFilteredEvent.COLUMNFILTERED_EVT,new FilterCriteria(this.column.dataField,this.filterInput.text)));
            ]]>
        </fx:Script>
        <s:states>
            <s:State name="normal" />
            <s:State name="hovered" />
            <s:State name="down" />
        </s:states>     
        <!-- layer 1: shadow -->
        <!--- @private -->
        <s:Rect id="shadow" left="-1" right="-1" top="-1" bottom="-1" radiusX="2">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color="0x000000"
                                     color.down="0xFFFFFF"
                                     alpha="0.01"
                                     alpha.down="0" />
                    <s:GradientEntry color="0x000000"
                                     color.down="0xFFFFFF"
                                     alpha="0.07"
                                     alpha.down="0.5" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect>
        <!-- layer 2: fill -->
        <!--- @private -->
        <s:Rect id="fill" left="0" right="0" top="0" bottom="0">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color="0xFFFFFF"
                                     color.hovered="0xBBBDBD"
                                     color.down="0xAAAAAA"
                                     alpha="0.85" />
                    <s:GradientEntry color="0xD8D8D8"
                                     color.hovered="0x9FA0A1"
                                     color.down="0x929496"
                                     alpha="0.85" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect>
        <!-- layer 3: fill lowlight -->
        <!--- @private -->
        <s:Rect id="lowlight" left="0" right="0" top="0" bottom="0">
            <s:fill>
                <s:LinearGradient rotation="270">
                    <s:GradientEntry color="0x000000" ratio="0.0" alpha="0.0627" />
                    <s:GradientEntry color="0x000000" ratio="0.48" alpha="0.0099" />
                    <s:GradientEntry color="0x000000" ratio="0.48001" alpha="0" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect>
        <!-- layer 4: fill highlight -->
        <!--- @private -->
        <s:Rect id="highlight" left="0" right="0" top="0" bottom="0">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color="0xFFFFFF"
                                     ratio="0.0"
                                     alpha="0.33"
                                     alpha.hovered="0.22"
                                     alpha.down="0.12"/>
                    <s:GradientEntry color="0xFFFFFF"
                                     ratio="0.48"
                                     alpha="0.33"
                                     alpha.hovered="0.22"
                                     alpha.down="0.12" />
                    <s:GradientEntry color="0xFFFFFF"
                                     ratio="0.48001"
                                     alpha="0" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect> 
        <!-- layer 5: highlight stroke (all states except down) -->
        <!--- @private -->
        <s:Rect id="highlightStroke" left="0" right="0" top="0" bottom="0" excludeFrom="down">
            <s:stroke>
                <s:LinearGradientStroke rotation="90" weight="1">
                    <s:GradientEntry color="0xFFFFFF" alpha.hovered="0.22" />
                    <s:GradientEntry color="0xD8D8D8" alpha.hovered="0.22" />
                </s:LinearGradientStroke>
            </s:stroke>
        </s:Rect>
        <!-- layer 6: highlight stroke (down state only) -->
        <!--- @private -->
        <s:Rect id="hldownstroke1" left="0" right="0" top="0" bottom="0" includeIn="down">
            <s:stroke>
                <s:LinearGradientStroke rotation="90" weight="1">
                    <s:GradientEntry color="0x000000" alpha="0.25" ratio="0.0" />
                    <s:GradientEntry color="0x000000" alpha="0.25" ratio="0.001" />
                    <s:GradientEntry color="0x000000" alpha="0.07" ratio="0.0011" />
                    <s:GradientEntry color="0x000000" alpha="0.07" ratio="0.965" />
                    <s:GradientEntry color="0x000000" alpha="0.00" ratio="0.9651" />
                </s:LinearGradientStroke>
            </s:stroke>
        </s:Rect>
        <!--- @private -->
        <s:Rect id="hldownstroke2" left="1" right="1" top="1" bottom="1" includeIn="down">
            <s:stroke>
                <s:LinearGradientStroke rotation="90" weight="1">
                    <s:GradientEntry color="0x000000" alpha="0.09" ratio="0.0" />
                    <s:GradientEntry color="0x000000" alpha="0.00" ratio="0.0001" />
                </s:LinearGradientStroke>
            </s:stroke>
        </s:Rect>
        <!--<s:Rect id="fill" left="0" right="0" top="0" bottom="0">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color.normal="0xf9f9f9" color.hovered="0xfcfdfa"
                                     color.down="0xdceac2" alpha="0.85" />
                    <s:GradientEntry color.normal="0xeaeaea" color.hovered="0xdceac2"
                                     color.down="0xd2e1b5" alpha="0.85" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect>-->
        <!--<s:VGroup left="7" right="7" top="5" bottom="5" gap="6" verticalAlign="middle">
            <s:TextInput width="100%" />
            <s:HGroup width="100%">
                <s:Group id="labelDisplayGroup" width="100%" />
                <s:Group id="sortIndicatorGroup" includeInLayout="false" />
            </s:HGroup>
        </s:VGroup>-->
        <s:VGroup verticalAlign="middle" left="7" top="5" right="7" bottom="5" gap="2" >
            <s:TextInput id="filterInput" width="100%" visible="false" includeInLayout="false" keyUp="onKeyUp(event)" focusOut="onFocusOut(event)" click="onTextInputSelection(event)"/>
            <s:Spacer id="filterSpacer" visible="false" includeInLayout="false" height="5" />
        <s:HGroup width="100%" height="100%" verticalAlign="middle">
            <s:Group id="labelDisplayGroup" width="100%" />
            <s:Group id="sortIndicatorGroup" includeInLayout="false" />
        </s:HGroup>
        </s:VGroup>
    </s:GridItemRenderer>

    Based on your idea, i've intercepted the click event and I use stopImmediatePropagation.
    THen i added an image to sort the column. So if the image is clicked the sort is ok.

  • How to set fontFamily with an embedded font of a textFlow ?

    Hy,
    When I create a TextFlow without use any component of the flex SDK (4.0.13827) and then I try to change or apply a FontFamily of an embedded font, it doesn't work. Whereas when I use a component like RichEditableText or Label, it works.
    Bellow the code I wrote for my test :
    <?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                                xmlns:s="library://ns.adobe.com/flex/spark"
                                xmlns:mx="library://ns.adobe.com/flex/mx"
                                creationComplete="creationCompleteHandler(event)"
                                width="800" height="600"
                                >
         <fx:Style>
              @namespace s "library://ns.adobe.com/flex/spark";
              @namespace mx "library://ns.adobe.com/flex/mx";
              @namespace local "*";
              @font-face {
                   src:                         url("assets/Fonts/arial.ttf");
                   fontFamily:                  ArialEmbedded;
                   advandedAntiAliasing:      true;
                   cff:                              true;
                   unicodeRange:                U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E,U+00A1-U+00FF,U+2000-U+206F,U+20A0-U+20CF,U+2100-U+2183;
              @font-face {
                   src:                         url("assets/Fonts/cour.ttf");
                   fontFamily:                  CourierEmbedded;
                   advandedAntiAliasing:      true;
                   cff:                              true;
                   unicodeRange:                U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E,U+00A1-U+00FF,U+2000-U+206F,U+20A0-U+20CF,U+2100-U+2183;
              s|WindowedApplication
         </fx:Style>
         <fx:Script>
              <![CDATA[
                   import flash.text.Font;
                   import flash.text.engine.FontLookup;
                   import flashx.textLayout.container.ContainerController;
                   import flashx.textLayout.conversion.TextConverter;
                   import flashx.textLayout.edit.EditManager;
                   import flashx.textLayout.edit.IEditManager;
                   import flashx.textLayout.elements.TextFlow;
                   import flashx.textLayout.events.SelectionEvent;
                   import flashx.textLayout.formats.TextLayoutFormat;
                   import flashx.undo.UndoManager;
                   import mx.collections.ArrayCollection;
                   import mx.events.FlexEvent;
                   import spark.core.SpriteVisualElement;
                   import spark.events.IndexChangeEvent;
                   private var dynTextFlow : TextFlow;
                   private var ctTextFlow : TextFlow;
                   protected function creationCompleteHandler(event:FlexEvent):void
                        controlBarVisible=false;
                        dynTextFlow = TextConverter.importToFlow("Hello World", TextConverter.PLAIN_TEXT_FORMAT);
                        drawTextBloc(dynTextFlow);
                        dynTextFlow.addEventListener(SelectionEvent.SELECTION_CHANGE, selectionChangeListener);
                        dynTextFlow.fontFamily = "ArialEmbedded";
                        dynTextFlow.fontLookup = FontLookup.EMBEDDED_CFF;
                        dynTextFlow.fontSize = 24;
                        dynTextFlow.interactionManager = new EditManager(new UndoManager());
                        dynTextFlow.flowComposer.updateAllControllers();
                        dynTextFlow.invalidateAllFormats();
                        dynTextFlow.flowComposer.updateAllControllers();
                   protected function cbFont_creationCompleteHandler(event:FlexEvent):void
                        var fonts:ArrayCollection=new ArrayCollection(Font.enumerateFonts());
                        cbFont.dataProvider=fonts;
                   protected function cbFont_changeHandler(event:IndexChangeEvent):void
                        var cf : TextLayoutFormat = new TextLayoutFormat();
                        cf.fontLookup = FontLookup.EMBEDDED_CFF;
                        cf.fontFamily = ComboBox(event.currentTarget).selectedItem.fontName;
                        IEditManager(ctTextFlow.interactionManager).applyLeafFormat(cf);
                        ctTextFlow.interactionManager.setFocus();
                   private function drawTextBloc(txt : TextFlow) : void
                        var container : SpriteVisualElement = new SpriteVisualElement();
                        var controller : ContainerController = new ContainerController(container, 300, 200);
                        addElement(container);
                        txt.fontLookup = FontLookup.EMBEDDED_CFF;
                        txt.fontFamily = "ArialEmbedded";
                        txt.flowComposer.addController(controller);
                   private function selectionChangeListener(event : SelectionEvent) : void
                        ctTextFlow = event.currentTarget as TextFlow;
                   protected function txt_selectionChangeHandler(event:FlexEvent):void
                        ctTextFlow = (event.currentTarget as RichEditableText).textFlow;
              ]]>
         </fx:Script>
         <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
         </fx:Declarations>
         <s:layout>
              <s:VerticalLayout paddingLeft="10" paddingTop="10"/>
         </s:layout>
         <s:RichEditableText x="10"
                                  y="10"
                                  selectionChange="txt_selectionChangeHandler(event)"
                                  paddingTop="5" paddingLeft="5" paddingRight="5" paddingBottom="5"
                                  id="txt"
                                  fontFamily="CourierEmbedded"
                                  text="RichEditableText"
                                  height="200"
                                  width="350"/>
         <s:ComboBox id="cbFont"
                        labelField="fontName"
                        creationComplete="cbFont_creationCompleteHandler(event)"
                        change="cbFont_changeHandler(event)"
                        />
         <s:Label text="TEST" fontFamily="CourierEmbedded" fontSize="22" rotation="45"/>
    </s:WindowedApplication>
    Please, help me...
    Thank you very much...

    Thank you very much,
    I finally found the solution using the swfContext :
    use namespace mx_internal;
    myTextFlow.swfContext = ISWFContext(getFontContext("myFontName", false, false, FontLookup.EMBEDDED_CFF));
    It works fine both with a dynamic component like RichEditableText or a dynamic textflow with a ContainerController.
    Thanks

  • Default css file problems

    I'm trying to use a default css file in a library project...  I'm using this in my library's compile arguments:
    "-include-stylesheet defaults.css /assets/styles/defaults.css"
    In defaults.css, I'm trying to assign a defautl skin like this:
    comp|Badge {
        skin-class: ClassReference('com.woo.skins.BadgeSkin');
    The problem is when the component is being newed:
    Main Thread (Suspended: TypeError: Error #1009: Cannot access a property or method of a null object reference.)   
        mx.core::UIComponent/getStyle   
        spark.components.supportClasses::SkinnableComponent/attachSkin   
        spark.components.supportClasses::SkinnableComponent/validateSkinChange   
        spark.components.supportClasses::SkinnableComponent/createChildren  
    What part am I doing wrong?  I'm hoping it's the -include-stylesheet part, I couldn't find a single example for using that.

    I assume you are using FlexBuilder to build and compile and not ant or the comand line correct? If so there are two things you need to check.
    1) Where is your defaults.css located? As long as it is in the root of your library's src directory (ie. src/defaults.css) you shouldn't even need to add that compiler option. When it builds a project, FlexBuilder looks for a file named defaults.css in this location and will use it to override the framework version.
    2) Go into your project properties -> build path -> assets tab. Make sure your defaults.css file is selected for inclusion.

  • Static class definition in flex

    Hi friends,
    can any one,please provide me with some example of defining static class in flex and acessing it in mxml page.
    one more thing i want to make clear,static class is nothing but .as class. Am i Right?
    thanks in Advace!!!!

    > may u know what is the difference between mx: and s:
    Flex actually has two sets of components, the original "MX" components from Flex 1.0 and the newer "Spark" components introduced in Flex 4.0. The Spark components support a much better skinning model.
    In terms of ActionScript classes, the two versions of Application are mx.core.Application and spark.components.Application. The MXML tags that map to these classes are normally written as <mx:Application> and <s:Application>, although the mx: and s: prefixes are completely arbitrary. What is important is the URIs declared for xmlns:mx="..." and xmlns:s="...". These URIs represent the SWCs containing these components, and the SWCs have "manifest" information about the mapping of tags to classes.
    Gordon Smith
    Adobe Flex SDK Team

  • How could i put image in button bar

    import events.ToolbarEvent;
    import mx.events.FlexEvent;
    import mx.events.ItemClickEvent;
    import mx.events.SliderEvent;
    import mx.core.*;
    import spark.skins.spark.ImageSkin;
    import ui.presenters.MainPresentationModel;
                [Bindable]
                public var fileButtons:Array = [{label:"Open"},{label:"Save"}];
                [Bindable]
                public var navButtons:Array =
                    {label:"Adjust",state:MainPresentationModel.ADJUST_STATE},
                    {label:"Touchup",state:MainPresentationModel.TOUCHUP_STATE},
                    {label:"Effects",state:MainPresentationModel.EFFECT_STATE}
                [Bindable]
                public var historyButtons:Array = [{label:"Undo"},{label:"Redo"}];
                private function handleFileClick(e:ItemClickEvent):void
                    if (e.label == "Open")
                        dispatchEvent(new ToolbarEvent(ToolbarEvent.OPEN));
                    else if (e.label == "Save")
                        dispatchEvent(new ToolbarEvent(ToolbarEvent.SAVE));
                private function handleNavClick(e:ItemClickEvent):void
                    callLater(handleNavigation,[e.item.state]);
                private function handleNavigation(state:String):void
                    if (navBar.selectedIndex == -1)
                        dispatchEvent(new ToolbarEvent(ToolbarEvent.SHOW));
                    else
                        dispatchEvent(new ToolbarEvent(ToolbarEvent.SHOW,true,false,state));
                private function handleHistoryClick(e:ItemClickEvent):void
                    if (e.label == "Undo")
                        dispatchEvent(new ToolbarEvent(ToolbarEvent.UNDO));
                    else if (e.label == "Redo")
                        dispatchEvent(new ToolbarEvent(ToolbarEvent.REDO));
                private function handleZoomChange(e:SliderEvent):void
                    dispatchEvent(new ToolbarEvent(ToolbarEvent.ZOOM, true, false, null, e.value));
            ]]>
        </mx:Script>
        <mx:ButtonBar dataProvider="{fileButtons}" itemClick="handleFileClick(event)"   />
        <mx:ToggleButtonBar id="navBar" dataProvider="{navButtons}" toggleOnClick="true"
            creationComplete="event.target.selectedIndex=-1" itemClick="handleNavClick(event)"/>
        <mx:Button label="Show Source" click="dispatchEvent(new ToolbarEvent(ToolbarEvent.SRC))"  />
        <mx:Spacer width="100%" />
        <mx:ButtonBar dataProvider="{historyButtons}" itemClick="handleHistoryClick(event)"  />
        <mx:HSlider value="1.0" minimum="0.1" maximum="3.0" snapInterval="0.1" liveDragging="true" change="handleZoomChange(event)" />
    </mx:HBox>
    using this code what shoud i do to add image on button bar

    I would extend the button bar and in create children I will add the image.

  • Adding native menus to an AIR application using ActionScript

    Hi,
    I'm working on Mac and PC with Air application.
    I'd creates a class extends Menu witch goal is to create a nativeMenu.
    My class is
    package
        import flash.desktop.DockIcon;
        import flash.desktop.NativeApplication;
        import flash.desktop.SystemTrayIcon;
        import flash.display.BitmapData;
        import flash.display.Loader;
        import flash.display.NativeMenu;
        import flash.display.NativeMenuItem;
        import flash.display.NativeWindow;
        import flash.display.NativeWindowDisplayState;
        import flash.display.NativeWindowSystemChrome;
        import flash.display.Screen;
        import flash.display.Sprite;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import flash.events.NativeWindowDisplayStateEvent;
        import flash.geom.Rectangle;
        import flash.net.URLRequest;
        import flash.sampler.NewObjectSample;
        import mx.controls.Alert;
        import mx.controls.Menu;
        import mx.core.Application;
        import mx.core.FlexGlobals;
        import mx.core.WindowedApplication;
        import spark.components.Application;
        import spark.components.WindowedApplication;
        public class createMenuBar extends Menu
            public function createMenuBar()
             * Initializes the app after loading
            public function initWindow():void{
                // Create root menu
                var rootMenu:NativeMenu = new NativeMenu();
                // Create root submenus
                rootMenu.addSubmenu(creerMenuFichier(),"Fichier");
                rootMenu.addSubmenu(creerMenuEdition(),"Edition");
                // Attach event listener routine to root menu
                rootMenu.addEventListener(Event.SELECT, dispatchMenuCommand);
                // Assign application menu (Mac OS X)
                if(NativeApplication.supportsMenu){
                    NativeApplication.nativeApplication.menu = rootMenu;
                // Assign window menu (MS Windows)
                if(NativeWindow.supportsMenu ){
                    stage.nativeWindow.menu = rootMenu;
             * createMenuCommand()
             * Creates a menu command based on parameters
            public function createMenuCommand(menuContainer:NativeMenu,
                itemLabel: String, itemKey:String,itemModifiers:Array,
                itemMnemonic:int, selectHandler:Function):NativeMenuItem{
                var cmd:NativeMenuItem = NativeMenu(menuContainer).addItem(new NativeMenuItem(itemLabel));
                cmd.mnemonicIndex = itemMnemonic; // index de la lettre de rappel du raccourci par dŽfaut 0
                cmd.keyEquivalent = itemKey;
                if(itemModifiers !=null){
                    cmd.keyEquivalentModifiers = itemModifiers;
                if (selectHandler !=null){
                    cmd.addEventListener(Event.SELECT, selectHandler);
                return cmd;
             * createMenuSeparator()
             * Creates a menu separator
            private function createMenuSeparator(menuContainer:NativeMenu):NativeMenuItem{
                var sep : NativeMenuItem = NativeMenu(menuContainer).addItem(new NativeMenuItem("sep", true));
                return sep;
             * Creates the File menu for app
            private function creerMenuFichier(): NativeMenu{
                var mnu:NativeMenu = new NativeMenu();
                createMenuCommand(mnu, 'Changer Utilisateur','k',null, 0, hChangeUser);
                createMenuCommand(mnu, 'Verrouiller/DŽverrouiller','', null, 0, hLock);
                createMenuCommand(mnu, 'Maintenance','', null, 0, hMaintenance);
                createMenuSeparator(mnu);
                // If Mac OS X, then use Quit label
                if (NativeApplication.supportsMenu) {
                    createMenuCommand( mnu, 'Quitter', 'q', null, 0, hExit); 
                // If Windows, then use Exit
                else {
                    createMenuCommand( mnu, 'Fermer', 'x', null, 0, hExit);
                return mnu; 
            public function creerMenuEdition() : NativeMenu{
                var mnu:NativeMenu = new NativeMenu();
                createMenuCommand( mnu, 'Annuler', 'z', null, 0, null); 
                createMenuCommand( mnu, 'RŽpŽter', 'y', null, 0, null);
                createMenuSeparator(mnu);   
                createMenuCommand( mnu, 'Couper', 'x', null, 2, null); 
                createMenuCommand( mnu, 'Copier', 'c', null, 0, null); 
                createMenuCommand( mnu, 'Coller', 'v', null, 0, null); 
                return mnu;
             * Catch-all menu dispatcher for all menus
            public function dispatchMenuCommand(evt: Event):void {
                var menuItem:NativeMenuItem = evt.target as NativeMenuItem;
                if (!menuItem.hasEventListener('select')) { 
                    Alert.show(menuItem.label + " a ŽtŽ selectionnŽ!");
             * Simple handlers for certain menu commands
            public function hChangeUser(evt: Event):void {
                Alert.show( "Vous allez changer d'utilisateur");
    On main air app.mxml file I create menu with
    var menu : createMenuBar = new createMenuBar();
      menu.initWindow();
    application menu appear but when I work on Windows system, windows menu is not visible.
    Can you help me to solve that?
    Thanks

    I believe you ran into an AIR limitation.  In the class header for NativeMenu it mentions:
    A native menu is a menu that is controlled and drawn by the operating system rather than by your application.       AIR supports the following types of native menus:
    Application menus are supported on OS X. Use the NativeApplication.supportsMenu property to test whether        application menus are supported on the host operating system. An  application menu is displayed on the Menu bar at the top of the        Mac desktop. OS X provides a default menu for every application, but  many of the menu commands are not functional. You can add       event listeners to the default items, replace individual menus and  items, or even replace the default menu entirely.       Access the application menu object using the NativeApplication menu property.
    Window menus are supported on Windows and Linux. Use the NativeWindow.supportsMenu property to       test whether window menus are supported on the host operating system. A  window menu is displayed below the window title bar. The area       occupied by the menu is not part of the window stage. Applications  cannot draw into this area. Assign a menu to a window using the        NativeWindow menu property.
    -ref: http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/display/Nati veMenu.html
    Use the NativeMenu.isSupported property to check if OS supports it.  There is also NativeWindow.supportsMenu property that may help you.  I hope that helps.

  • Error when overriding mx_internal function in mxml file

    Hi,
    I'm having difficulty overriding an mx_internal function inside an mxml file. I get an error:
    1004: Namespace was not found or is not a compile-time constant. StackRenderer.mxml /Layouts/src/example line 12 Flex Problem
    <?xml version="1.0" encoding="utf-8"?>
         <s:ItemRenderer
                xmlns:fx="http://ns.adobe.com/mxml/2009"
                xmlns:s="library://ns.adobe.com/flex/spark"
                xmlns:mx="library://ns.adobe.com/flex/mx">
                <fx:Script>
                      <![CDATA[
                            import mx.core.mx_internal;
                            use namespace mx_internal;
                            override mx_internal function drawBackground():void{
                       ]]>
                </fx:Script>
    </s:ItemRenderer>
    What am I doing wrong?

    Sorry for missleading information: I missed the error after I removed "use namespace mx_internal;". However I think I have found a problem. For some reason you get the error in MXML file (probably there are some restrictions for using namespaces in MXML files but I'm not sure). I have created an ActionScript component and it now compiles (for sure):
    package
       import mx.core.mx_internal;
       import spark.components.supportClasses.ItemRenderer;
       use namespace mx_internal
       public class CustomIRAS extends ItemRenderer
          override mx_internal function drawBackground():void {
    So I suggest creating ActionScript component instead of MXML.
    Michael

  • Multicast video player with FMS 4.0

    I am trying to create a video player in Flash Builder using the new Flash Media Server 4.0 capabilities but I am not able to. The only thread I've seen out there is regarding the P2P player which is not what I want as seen here:
    http://www.swfgeek.net/2010/08/10/multicast-streaming-in-flash-player-10-1-revisited/
    I want to create a custom player that can retrieve a multicast broadcast.
    Here is my code:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Group 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="650" height="250">
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <fx:Script>
        <![CDATA[
        import mx.core.UIComponent;
        import spark.components.Group;
        private const SERVER:String = "rtmfp://172.22.2.150/multicast";
        private const DEVKEY:String = ""; //removed for now
        [Bindable]
        private var connected:Boolean = false;
        private var video:Video;
        private var netConnection:NetConnection;
        private var stream:NetStream;
        public function init():void{
        writeText("Broadcaster:");
        video = new Video(320,240);
        video.x = 10;
        video.y = 10;
        var uic:UIComponent = new UIComponent();
        uic.addChild(video);
        addElement(uic);
        connect();
        private function connect():void{
        netConnection = new NetConnection();
        netConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
        netConnection.connect(SERVER+DEVKEY);
        private function onNetConnectionNetStatus(event:NetStatusEvent):void
        switch(event.info.code){
        case "NetStream.Connect.Success":
        event.info.stream.dispatchEvent(event);
        break;
        private function netStatus(event:NetStatusEvent):void{
        writeText(event.info.code);
        switch(event.info.code){
        case "NetConnection.Connect.Success":
        setupStream();
        break;
        case "NetStream.Connect.Success":
        // not using a camera, using another live video source
        //var cam:Camera = Camera.getCamera();   
        //stream.attachCamera(cam);
        //stream.publish("multicast");
        //video.attachCamera(cam);
        stream.attach(netConnection);
        stream.publish("myStream");
        video.attachNetStream(stream);
        break;
        private function setupStream():void{
        //var groupspec:GroupSpecifier = new GroupSpecifier("myGroup/multicastOne");
            var groupspec:GroupSpecifier = new GroupSpecifier("fms.multicast.example");
        groupspec.serverChannelEnabled = true;
        groupspec.multicastEnabled = true;
        groupspec.groupspecWithoutAuthorizations()
        stream = new NetStream(netConnection,groupspec.groupspecWithAuthorizations());
        stream.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
        private function writeText(txt:String):void{
        txtHistory.text += txt+"\n";
        ]]>
        </fx:Script>
        <s:TextArea top="10" bottom="10" id="txtHistory" width="250" right="10"/>
    </s:Group>

    The QT movie opened promptly for me in Firefox 4.0. The fact that it's intermittent for you with FF indicates that it's a connection issue and not an iWeb issue. For some reason not all of the files are being loaded by FF at those times. (The server is probably being run by an Ohio State graduate )
    OT
    Go Blue!
    Note: using Quicktime for you slide presentation will exclude all those users from the dark side who don't have Quicktime installed on their PCs. You might look into a java based method for the presentation. There are lots of them out there. With the free Jalbum you have over 100 themes/skins to choose from.
    Message was edited by: Old Toad

  • Flex mobile: actionbar chrome always has a gradient look

    Hi,
    I have a mobile app based on ViewNavigatorApplication. I want the action bar to have a single flattened color.
    I have following declaration in the app main mxml file
    s|ActionBar
         chromeColor: #000000;
    In spite of this, the app’s action bar always has a gradient look. Am I missing anything here ?
    also, i tried setting the following values too
    backgroundAlpha: 0;
    contentBackgroundAlpha: 0;
    accentColor: #000000;
    but didnt get the required results.
    Thanks,

    The gradient is created by the skin based on the chrome color.  You will need to create a custom skin to not draw a gradient.
    Here is an example custom skin that extends ActionBarSkin to accomplish this.
    SolidActionBarSkin.as:
    package
        import mx.core.DPIClassification;
        import spark.skins.mobile.ActionBarSkin;
        public class SolidActionBarSkin extends ActionBarSkin
            override protected function drawBackground(unscaledWidth:Number, unscaledHeight:Number):void
                var chromeColor:uint = getStyle("chromeColor");
                var backgroundAlphaValue:Number = getStyle("backgroundAlpha");
                // border size is twice as big on 320
                var borderSize:int = 1;
                if (applicationDPI == DPIClassification.DPI_320)
                    borderSize = 2;
                graphics.beginFill(chromeColor, backgroundAlphaValue);
                graphics.drawRect(0, borderSize, unscaledWidth, unscaledHeight - (borderSize * 2));
                graphics.endFill();
    And the CSS to use it in your application:
    <?xml version="1.0" encoding="utf-8"?>
    <s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                                xmlns:s="library://ns.adobe.com/flex/spark"
                                firstView="views.ReproMHomeView">
        <fx:Style>
            @namespace s "library://ns.adobe.com/flex/spark";
            s|ActionBar {
                skinClass: ClassReference("SolidActionBarSkin");
        </fx:Style>
    </s:ViewNavigatorApplication>

Maybe you are looking for

  • Deskjet 3050 wireless problem

    Hi, Hope someone can help ASAP please!!!!!! Have a Deskjet 3050 wireless printer, which i have tried all ways of installing, but cant get it to print wireless. I have a Compaq laptop with wireless, Belgin Wireless router, I can see the network on the

  • PSElements 12, purchased with Dell computer, quit working.  How do I get the software to function again?

    I purchased a Windows 7 system from Dell in April 2014, including PSElements 12 and Premiere 12.  Elements 12 worked fine until a few days ago, then reverted to the 30-day trial version.  A Dell Support Agent worked on it for two days, left Elements

  • Check+Printing+Sequence

    I am looking for some guidance on Check Printing Sequence.  Our specific problem is that we want checks over $50K to print first in our check run because these checks require signatures, but we are unsure of how to get this to work other than having

  • A* algorithm

    Hi, I need to implement the a* search algorithm in java. This algorithm measures the optimal route to take between two nodes in a tree using the formula f(n) = g(n) + h(n) (where g(n) is the cost to reach that node n and h(n) is the cost to the goal

  • Todd - Thanks for PrE 9 Trial Stickie

    Todd, Thank you for adding the sticky at the top of the PrE forum. With previous versions of the PrE trial, the only limitation has been the watermark. With the various, necessary modules, that must be activated, many trial users were encountering is