void RenderPages() { RenderCovers(); if (_softShadow != null) { _softShadow.RemoveFromParent(); } int curPage = _currentPage; if (curPage % 2 == 0) { curPage--; } int leftPage, rightPage, turningPageBack, turningPageFront; leftPage = curPage; rightPage = leftPage < _pageCount - 1 ? (leftPage + 1) : -1; if (_turningTarget != -1) { int tt = _turningTarget; if (tt % 2 == 0) { tt = tt - 1; } if (tt == curPage) { _currentPage = _turningTarget; turningPageBack = turningPageFront = -1; } else if (tt > leftPage) { turningPageFront = tt; turningPageBack = rightPage; rightPage = tt < _pageCount - 1 ? (tt + 1) : -1; } else { turningPageFront = tt > 0 ? (tt + 1) : 0; turningPageBack = leftPage; leftPage = tt > 0 ? tt : -1; } } else { turningPageBack = turningPageFront = -1; } _objectNewIndice[0] = leftPage; _objectNewIndice[1] = rightPage; _objectNewIndice[2] = turningPageBack; _objectNewIndice[3] = turningPageFront; for (int i = 0; i < 4; i++) { int pageIndex = _objectNewIndice[i]; if (pageIndex != -1) { for (int j = 0; j < 4; j++) { int pageIndex2 = _objectIndice[j]; if (pageIndex2 == pageIndex) { if (j != i) { _objectIndice[j] = _objectIndice[i]; _objectIndice[i] = pageIndex; GComponent tmp = _objects[j]; _objects[j] = _objects[i]; _objects[i] = tmp; } break; } } } } for (int i = 0; i < 4; i++) { GComponent obj = _objects[i]; int oldIndex = _objectIndice[i]; int index = _objectNewIndice[i]; _objectIndice[i] = index; if (index == -1) { if (obj != null) { obj.RemoveFromParent(); } } else if (oldIndex != index) { if (obj == null) { obj = UIPackage.CreateObjectFromURL(_pageResource).asCom; obj.displayObject.home = this.displayObject.cachedTransform; _objects[i] = obj; } _pagesContainer.AddChild(obj); pageRenderer(index, obj); } else { if (obj.parent == null) { _pagesContainer.AddChild(obj); pageRenderer(index, obj); } else { _pagesContainer.AddChild(obj); } } if (obj != null && obj.parent != null) { Controller c1 = obj.GetController("side"); if (c1 != null) { if (index == 0) { c1.selectedPage = "first"; } else if (index == _pageCount - 1) { c1.selectedPage = "last"; } else { c1.selectedPage = (index % 2 == 0) ? "right" : "left"; } } if (i == 0 || i == 1) { SetPageNormal(obj, i == 0); } else if (_paper == Paper.Soft) { SetPageSoft(obj, i == 2); } else { SetPageHard(obj, i == 2); } } } }