Error #2006 The Supplied Index Is Out Of Bounds
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more rangeerror error #2006 the supplied index is out of bounds about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges
Argumenterror Error #2025 The Supplied Displayobject Must Be A Child Of The Caller
Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each
As3 Error 1010
other. Join them; it only takes a minute: Sign up Error 2006 The Supplied Index is Out of Bounds up vote 1 down vote favorite Another day another problem unfortunately- the last line of this piece of code is
Error 2006 The Supplied Index Is Out Of Bounds Setchildindex
the culprit: uiBar = new mcUiBar(); uiBar.x=-15; uiBar.y=-5; addChildAt(uiBar, numChildren-1); Now I researched and so I know it has something to with the array being larger than whatever, but I'm not figuring it out. I'm stumped. I would appreciate your help. Cheers actionscript-3 error-handling flash-cs5 share|improve this question asked Apr 8 '11 at 10:46 londonbird 20126 add a comment| 2 Answers 2 active oldest votes up vote 3 down vote accepted The out of range error basically index out of bounds error python is saying that the value you're providing for the index is "out of range" of the array of indexes in the display object container. The acceptable range is from 0 to n+1 where n is the topmost child's index. Another way to say this is 0 to numChildren. So George is right, you're going to have problems when numChildren - 1 = -1. If you're trying to add the child to the next-to-top layer, use the if statement above. However, if you're just trying to add it to the top layer, you should either use addChildAt(child, numChildren) or addChild(child) which are synonymous. share|improve this answer answered Apr 8 '11 at 21:00 Mims H. Wright 2,37411728 Yes Mims...thanks for the clarification. I'm new at all this btw...and thanks for sharing your knowledge!! I'm also learning Java but I prefer actionscript 3.0 lol. –londonbird Apr 12 '11 at 2:39 add a comment| up vote 1 down vote Too little code, but that last line: addChildAt(uiBar, numChildren-1); seems to be the problem. What happens if there are no children added yet (numChildren is 0) ? That should throw an error because you're trying to add uiBar at depth/index -1 try addChildAt(uiBar, numChildren > 0 ? numChildren-1 : 0); share|improve this answer answered Apr 8 '11 at 10:52 George Profenza 31.6k984150 Flash CS5 likes your code! After I fixed the problem
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and index out of bounds matlab error policies of this site About Us Learn more about Stack Overflow the error index out of bounds r company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags array index out of bounds error Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only http://stackoverflow.com/questions/5593975/error-2006-the-supplied-index-is-out-of-bounds takes a minute: Sign up Why is this AS3 code generating an “Error #2006: The supplied index is out of bounds”? up vote 0 down vote favorite So what I'm trying to do is go through each element of the array "maps" which contains 4 movieclips and look and the children within each of those movieclips to see which are of http://stackoverflow.com/questions/15723993/why-is-this-as3-code-generating-an-error-2006-the-supplied-index-is-out-of-bo type "Block". However I'm getting a #2006 error and I'm not sure why, can anyone help please? function findBlocks() { trace("findBlocks()"); for (i=0; maps.length; i++) { for (var j=0; maps[i].numChildren; j++) { var mc = maps[i].getChildAt(j); if (mc is Block) { blocks.push(mc); } } } trace("blocks array: " + blocks); } actionscript-3 share|improve this question edited Mar 30 '13 at 22:25 Lee Taylor 4,54072138 asked Mar 30 '13 at 22:04 Craig Harkness 31 add a comment| 1 Answer 1 active oldest votes up vote 3 down vote accepted Your for loop conditions are incorrect, try this : for (var i=0; i < maps.length; i++){ for (var j=0; j < maps[i].numChildren; j++){ var mc = maps[i].getChildAt(j); if (mc is Block){ blocks.push(mc); } } } You have to remember that arrays and the display list start at 0, so the index of the last element in your lists is length-1, and in the case of a display list numChildren-1 i < maps.length and j < maps[i].numChildren are what solve the problem share|improve this answer answered Mar 30 '13 at 22:11 prototypical 5,82
using your existing account on the new forums, check out this thread. Register https://www.kirupa.com/forum/showthread.php?290027-RangeError-Error-2006-The-supplied-index-is-out-of-bounds Help Remember Me? Forum Today's Posts FAQ Calendar Forum Actions Mark Forums Read Quick Links View Forum Leaders What's New? Advanced Search Forum Flash ActionScript http://life.neophi.com/danielr/2007/06/rangeerror_error_2006_the_supp.html 3 RangeError: Error #2006: The supplied index is out of bounds. Results 1 to 5 of 5 Thread: RangeError: Error #2006: The supplied index is out of out of bounds. Thread Tools Show Printable Version Subscribe to this Thread… Search Thread Advanced Search Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode February 25th, 2008,05:21 PM #1 anujsharma181 View Profile View Forum Posts 19 posts Registered User RangeError: Error #2006: The supplied index is out out of bounds of bounds. Hi Guys I am making an Auto-Arrange button and clicking on which arranges all the children of the container( which are on the main stage) in the tile format. Basically on clicking, I manually move those child on the stage to particular coordinates as shown in my code. I have pasted my code below. My problem is that as soon as i click on the auto arrange button I am getting error "RangeError: Error #2006: The supplied index is out of bounds.". Please let me know what i am doing wrong and i will appreciate if you let me know how would i fix this Thanks a lot guys Anuj ******************CODE********************** var aa:Number=0; var xcoord:Number=-300; var ycoord:Number=-200; var xcoord1:Number=450; var xcoord2:Number=850; var xcoord3:Number=1250; var ycoord1:Number=350; var ycoord2:Number=650; //Button Listener btn_AA.addEventListener(MouseEvent.CLICK,autoArran ge); function autoArrange(event:MouseEvent):void { if(container.getChildAt(aa)!=null) { container.getChildAt(aa).x=xcoord; container.getChildAt(aa).y=ycoord; //Arrange Second container.getChildAt(aa+1).x=xcoord+xcoord1; container.getChildAt(aa+1).y=ycoord; //Arrange Third container.getChildAt(aa+2).x=xcoord+ xcoord2; container.getChildAt(aa+2).y=ycoord; //Arrange Forth container.getChildAt(aa+3).x=xcoor
moving a component from one parent to another is the following error: RangeError: Error #2006: The supplied index is out of bounds. at flash.display::DisplayObjectContainer/getChildAt() at mx.core::Container/getChildAt() at mx.containers.utilityClasses::CanvasLayout/measure() at mx.containers::Canvas/mx.containers:Canvas::measure() (... some of stack trace deleted ...) at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher2() at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher() at [renderEvent] at [mouseEvent] You'll notice that the stack trace is nothing but framework code. An error in a callLater that I didn't make? The problem is simple. When moving a component from one parent to another you have to call removeChild() on the current parent before calling addChild() to attach it to the new parent. The following code demonstrates the issue: