انتقل إلى العنصر المحدد في فليكس عنصر قائمة 4 سبارك

StackOverflow https://stackoverflow.com/questions/1602103

سؤال

وأنا وضع العنصر المحدد في الصورة: عنصر قائمة مع أكشن، وأنها تعمل، ولكن قائمة لا انتقل إلى العنصر المحدد - الحاجة إلى التمرير مع التمرير أو الماوس. هل من الممكن لصناعة السيارات في التمرير إلى العنصر المحدد؟ شكرا!

هل كانت مفيدة؟

المحلول

وجرب طريقة s:List <لأ href = "http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/components/List.html#ensureIndexIsVisible٪28٪29" يختلط = "noreferrer "> ensureIndexIsVisible (مؤشر: دولي): الفراغ

نصائح أخرى

لشرارة:

وlist.ensureIndexIsVisible(index);

وهذه الوظيفة سوف انتقل إلى الجزء العلوي من القائمة في فليكس 4+. فإنه يأخذ في الاعتبار ارتفاع هذا البند، حتى أنها ستعمل لقوائم مع عناصر مختلفة مع ارتفاع مختلفة.

private function scrollToIndex(list:List,index:int):void
{
    if (!list.layout)
        return;

    var dataGroup:DataGroup = list.dataGroup;

    var spDelta:Point = dataGroup.layout.getScrollPositionDeltaToElement(index);

    if (spDelta)
    {
        dataGroup.horizontalScrollPosition += spDelta.x;
        //move it to the top if the list has enough items
        if(spDelta.y > 0)
        {
            var maxVSP:Number = dataGroup.contentHeight - dataGroup.height;
            var itemBounds:Rectangle = list.layout.getElementBounds(index);
            var newHeight:Number = dataGroup.verticalScrollPosition + spDelta.y 
            + dataGroup.height - itemBounds.height;
            dataGroup.verticalScrollPosition = Math.min(maxVSP, newHeight);
        }
        else
        {
            dataGroup.verticalScrollPosition += spDelta.y;

        }
    }
}
//try this
this.callLater(updateIndex);//where you want to set the selectedIndex

private function updateIndex():void
{
    list.selectedIndex = newIndex;
    list.ensureIndexIsVisible(newIndex);
}

في المرن 3 هناك طريقة scrollToIndex وبالتالي يمكنك الاتصال

list.scrollToIndex(list.selectedIndex);

وأعتقد أن هذا يجب أن تعمل في المرن 4 للغاية.

وهذا عمل بالنسبة لي. وكان لاستخدام callLater.

list.selectedItem = "MyTestItem"; //or list.selectedIndex = 10;
this.callLater(updateIndex); //dispatch an update to list

private function updateIndex():void {
    list.ensureIndexIsVisible(list.selectedIndex);
}

ورأيت هذه الفكرة الأساسية هنا ... http://arthurnn.com/blog/2011/ 12/1 / coverflow تخطيط مقابل المرن 4 /

public function scrollGroup( n : int ) : void
{
    var scrollPoint : Point = theList.layout.getScrollPositionDeltaToElement( n );
    var duration : Number = ( Math.max( scrollPoint.x, theList.layout.target.horizontalScrollPosition ) - Math.min( scrollPoint.x, theList.layout.target.horizontalScrollPosition )) * .01;
    Tweener.addTween(theList.layout,{ horizontalScrollPosition: scrollPoint.x , time:duration});
}
protected function theList_caretChangeHandler(event:IndexChangeEvent):void
{
    scrollGroup( event.newIndex );
    event.target.invalidateDisplayList();
}

وربما عليك تريد الوصول إلى قائمة الأعضاء سكرولر مباشرة وتفعل شيئا مثل:

وlist.scroller.scrollRect.y = list.itemRenderer.height * index;

ويمكنك مضاعفة ارتفاع عنصر من مؤشره وتمرير هذه القيمة إلى:

yourListID.scroller.viewport.verticalScrollPosition

وذلك هو الشوائب - يمكنك أن ترى المظاهرة والحل في الشبكي: / /issues.apache.org/jira/browse/FLEX-33660

وعملت هذا التمديد عنصر قائمة مخصصة للي:

<s:List
    xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    valueCommit="callLater(ensureIndexIsVisible, [selectedIndex])">
</s:List>

وأنا في الآونة الأخيرة تحقيق ذلك في واحدة من مشاريعي من خلال وجود حجم المعرفة لمادتي في المجموعة ..

<s:Scroller x="940" y="0" maxHeight="465" maxWidth="940" horizontalScrollPolicy="off" verticalScrollPolicy="off">
  <s:HGroup  id="tutPane" columnWidth="940" variableColumnWidth="false" gap="0" x="0" y="0">
  </s:HGroup>
</s:Scroller>

وبعد هذا بلدي تحكم زر للتلاعب يعمل عن طريق زيادة والخاص "targetindex" متغير، ثم دعوت وظيفة checkAnimation، والتي تستخدم الطبقة تحريك، في التحرير والسرد مع SimpleMotionPath والمقارنة بين tutpane.firstIndexInView ومؤشر الهدف. هذا تعديل "horizontalScrollPosition" للمجموعة.

وهذا ما سمح ضوابط منفصلة للعمل أساسا بمثابة شريط التمرير، ولكن كان شرط من انزلاق التحكم لعرض العنصر المحدد .. وأعتقد أن هذا الأسلوب يمكن أن تعمل لاختيار الآلية من العناصر فضلا

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top