right. its for lazy loading. when the scroll thumb goes into the "hot area"
then it sends requests to the server for new content. when new content is
received i create a new container and add it to the accordion with
addChildAt(newContainer, 0); to make sure it is before existing content. to
keep a natural feel the view should stay where it is, where the user has the
mouse down on the scroll thumb.

code example. this isn't showing lazy loading. it is only showing that when
adding a container before exiting content that new container is selected

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:code="http://code.google.com/p/flexlib/2010/";
               xmlns:fx="http://ns.adobe.com/mxml/2009";
               xmlns:mx="library://ns.adobe.com/flex/mx"
               xmlns:s="library://ns.adobe.com/flex/spark">

    <fx:Script>
        <![CDATA[
            private var item:int;
            private var itemAfter:int;

            protected function addBefore_clickHandler(event:MouseEvent):void
{
                var prevIndex:int = accordion.selectedIndex;
                var canvas:Canvas = new Canvas();
                var label:Label = new Label();
                label.text = "item " + --item;
                canvas.addChild(label);

                // when we add to the beginning of the current content it
becomes selected
                accordion.addChildAt(canvas, 0);

                // to keep the selected item the same you must set the index
                // or the new item will be selected
                //accordion.selectedIndex = ++prevIndex;
            }

            protected function addAfter_clickHandler(event:MouseEvent):void
{
                var prevIndex:int = accordion.selectedIndex;
                var canvas:Canvas = new Canvas();
                var label:Label = new Label();
                label.text = "item " + accordion.numChildren;
                canvas.addChild(label);

                // add to the end of the current content
                accordion.addChild(canvas);
            }
        ]]>
    </fx:Script>

    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here
-->
    </fx:Declarations>

    <s:Scroller height="100%" width="100%">
        <s:Group>
            <code:HAccordion id="accordion"
                             height="200" width="100%">
                <mx:Canvas>
                    <s:Label text="item 0"/>
                </mx:Canvas>
                <mx:Canvas>
                    <s:Label text="item 1"/>
                </mx:Canvas>
                <mx:Canvas>
                    <s:Label text="item 2"/>
                </mx:Canvas>
                <mx:Canvas>
                    <s:Label text="item 3"/>
                </mx:Canvas>
            </code:HAccordion>
        </s:Group>
    </s:Scroller>

    <s:Button label="add before" y="200"
              click="addBefore_clickHandler(event)"/>
    <s:Button label="add after" y="230"
              click="addAfter_clickHandler(event)"/>
</s:Application>





On Tue, Jul 13, 2010 at 12:49 AM, Alex Harui <aha...@adobe.com> wrote:

>
>
> I’m having trouble picturing an accordion with scrollbars.  But if it did,
> why wouldn’t the scrollbar be tuned for the total number of children?  Why
> are children being added as you scroll?
>
>
>
> On 7/12/10 6:59 PM, "dorkiedorkfromdorkt...@gmail.com" <
> dorkiedorkfromdorkt...@gmail.com> wrote:
>
>
>
>
>
>
> In that case, I'll elaborate on the situation...
>
> I am using a horizontal Accordion component with newest items to the right.
> When you scroll left you get to a location where more items are added. As
> you add each item the scrollbar thumb track jumps to the right and then
> jumps back to where the mouse is. This happens every time a new item is
> added to the accordion.
>
>
> On Mon, Jul 12, 2010 at 6:35 PM, Alex Harui <aha...@adobe.com> wrote:
>
>
>
>
>
>
> Flash renders what is visible and on the display list.  UIComponent is
> invisible until creationComplete and theoretically, it and all of its
> children shouldn’t be changing after then.  Or make it visible=false until
> you know it is ready.
>
>
>
> On 7/12/10 2:37 PM, "dorkiedorkfromdorkt...@gmail.com <
> http://dorkiedorkfromdorkt...@gmail.com> " <
> dorkiedorkfromdorkt...@gmail.com <http://dorkiedorkfromdorkt...@gmail.com>
> > wrote:
>
>
>
>
>
>
> There's a component that I'm adding child components too it. When I do this
> there's a flash as the component is added and resized and then put into the
> right position. Is there a way to prevent a square area from being rendered
> for a second or two? I can fix the issue but I'd have to go into UIComponent
> and mess with the base classes. Since I've run into this before (elastic
> race track) and will in the future its seems a reasonable request.
>
>
>
>
>
> --
> Alex Harui
> Flex SDK Team
> Adobe System, Inc.
> http://blogs.adobe.com/aharui
>   
>

Reply via email to