dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [RESOLVED] RangeError: Error #2006: The supplied index is out of bounds. HELP!!!

  1. #1
    Junior Member
    Join Date
    Oct 2008
    Posts
    20

    resolved [RESOLVED] RangeError: Error #2006: The supplied index is out of bounds. HELP!!!

    Hi,
    I made shared object application with drawing lines, arrow and circles. Almost everything works fine until I restart application.
    Not every time but very often I get this error:
    RangeError: Error #2006: The supplied index is out of bounds.
    This is code which loading share objects:

    function addNewChild(data, name) {
    var child = null;
    switch(data.toolType) {
    case "brush":
    child = new ScrappyBrush();
    break;
    case "arrow":
    child = new ScrappyLine();
    break;
    case "text":
    child = new ScrappyTxt();
    break;
    case "textBox":
    child = new ScrappyTxtBox();
    break;
    case "circle":
    child = new ScrappyCircle();
    break;
    case "bitmap":
    child = new ScrappyBMP();
    break;
    }
    if (child) {
    child.name = name;
    dragTarget.addChild(child);
    child.updateSharedObject(this.so);
    }
    }

    I was trying to replace dragTarget.addChild(child); to dragTarget.addChildAt(child,0); but that did not solved my problem.

    Can anyone explain me what is wrong?

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    I don't see anything in that code that would throw an index error - can you post the full trace when the swf fails? That should show you exactly what function is breaking. (I suspect it's in one of those constructors)

  3. #3
    Junior Member
    Join Date
    Oct 2008
    Posts
    20
    First thx for replay
    The problem is that error is only thing what I get. But I was wrong with one thing - replaceing
    dragTarget.addChild(child); to
    dragTarget.addChildAt(child,0);
    solved problem with loading shared objects. Unfortunately the same error message I get during connection with media server (but not every time) . Usually when I draw more objects.
    Code to connect and sync with media server:

    function mainInit() {
    // create a connection to the media server
    nc.addEventListener(NetStatusEvent.NET_STATUS,netS tatusHandler);
    nc.connect("rtmp://localhost/whiteboard");
    this.so = SharedObject.getRemote(args.gidReq+"-"+args.cidReq, nc.uri, true);
    this.so.addEventListener(SyncEvent.SYNC,syncEventH andler);
    this.so.fps = 0;
    this.so.connect(nc);
    }

    public function netStatusHandler(event:NetStatusEvent):void {
    trace(event.info.code);
    }

    public function syncEventHandler (event:SyncEvent) {
    var list = event.changeList;
    for (var i = 0; i<list.length; i++) {
    if (list[i].name == null) continue;
    trace(list[i].name);
    if (list[i].code == "delete") {
    // Shape has been deleted, remove it.
    this.dragTarget.removeChild(this.dragTarget.getChi ldByName(list[i].name));
    } else {
    var child = this.dragTarget.getChildByName(list[i].name);
    if (child)
    child.updateSharedObject(this.so);
    else
    this.addNewChild(this.so.data[list[i].name], list[i].name);
    }
    }
    }

    I thought this error concern only addChild function, but I was wrong
    I'm sure that constructors are ok.
    Please give me some idea what can be wrong

  4. #4
    Junior Member
    Join Date
    Oct 2008
    Posts
    20
    Finally I solved that
    The problem was in function mainInit(), I replace part of the code from this function to the function netStatusHandler
    Code:

    function mainInit() {
    // create a connection to the media server
    if(nc == null){
    nc = new NetConnection();
    nc.addEventListener(NetStatusEvent.NET_STATUS,netS tatusHandler);
    nc.connect("rtmp://localhost/whiteboard");
    }
    }

    public function netStatusHandler(event:NetStatusEvent):void {
    if(event.info.code == "NetConnection.Connect.Success") {
    this.so = SharedObject.getRemote(args.gidReq+"-"+args.cidReq, nc.uri, true);
    this.so.addEventListener(SyncEvent.SYNC,syncEventH andler);
    this.so.connect(nc);
    trace(event.info.code);
    }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center