1
votes

I am having an issue adding multiple form inputs to a scrollable list in a mobile app.

I can add up to 110 entries and this will work but adding more than that produces the error "ArgumentError: Error #2006: The supplied index is out of bounds.". Stepping through the code I can see the error is produced by the ScrollableStageText class when it tries to run updateViewPort() which draws a rectangle and calculates the y value to more than 8192.

I have created this Flash builder code which will reproduce the error.

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView"
        initialize="init()">


    <fx:Script>
        <![CDATA[
            import spark.components.FormItem;
            public function init():void
            {
                var fi:FormItem;
                var ti:TextInput;

                for (var i:int = 0; i < 150; i++)
                {
                    fi = new FormItem; 
                    fi.label = i.toString(); 
                    fi.percentWidth=100;
                    ti = new TextInput; 
                    ti.id="item_"+i; 
                    ti.percentWidth=100;
                    ti.text = "";
                    ti.styleName = "ti";
                    fi.addElement(ti);
                    listtest.addElement(fi);
                }
            }

        ]]>
    </fx:Script>

    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->     
    </fx:Declarations>
    <s:Scroller width="100%" height="100%" >
        <s:VGroup id="listtest" width="100%" horizontalAlign="center">
            <s:TextInput />
        </s:VGroup> 
    </s:Scroller>

</s:View>

I can see the issue has been raised on the apache forums but I cannot see how to set the y value as suggested here within flash builder.

Any help on this issue would be apprecated.

1

1 Answers

0
votes

This is an interesting error.

Until the Apache team provide a fix the only solution I can think of would be to override TextInput class and provide a fix right down to the methods that are wrongly trying to set the StageText instance y property beyond the accepted value.

Unfortunately StageText is a final class so it cannot be overrided which would have been easier but composition is possible and could be the right way to go.