سؤال

everyone.

Can I get a number of items from a ScrollPane component in Flash? If yes, then how?

Thanks in advance.

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

المحلول

ScrollPane has one item which is the source parameter. If you want to know all the children within that source (and it's a DisplayObjectContainer), you can use the .numChildren property of the SOURCE.

If you want all the sub-children, you could iterate through all the children until you have you're final number:

var d:DisplayObjectContainer = scrollPane.source;

function countChildren(container:DisplayObjectContainer):int {
    var count:int = container.numChildren;
    var tmp:DisplayObject;
    var i:int = count;
    while(i--){
        tmp = container.getChildAt(i);
        if(tmp is DisplayObjectContainer){
            count += countChildren(tmp);
        }
    }
    return count;
}

so call countChildren() with the source of the scrollPane.

if(scrollPane.source is DisplayObjectContainer){
    countChildren(DisplayObjectContainer(scrollPane.source));
}

نصائح أخرى

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObjectContainer.html#numChildren

Should have a numChildren if the objects you're talking about are actual direct descendants of the ScrollPane in question.

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