From e4d07e7e961be6865bf06dc9d54b288523baab48 Mon Sep 17 00:00:00 2001 From: Rafael Belvederese Date: Wed, 11 Aug 2010 03:34:52 -0300 Subject: [PATCH] fixed the "RangeError #2006" bug, when a Book was instantiated without children. --- README.markdown | 14 +++++++------- src/com/rubenswieringa/book/Book.as | 2 +- .../rubenswieringa/containers/SuperViewStack.as | 7 +++++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/README.markdown b/README.markdown index 8a4bb6b..659b63a 100644 --- a/README.markdown +++ b/README.markdown @@ -1,6 +1,6 @@ # FlexBook # -- Current Version: 1.0.3 +- Current Version: 1.0.4 - Flex 3.5 / AS3 / Flash Player 9+ - Date: 4th July 2007 - Original Author: Ruben Swieringa @@ -11,15 +11,15 @@ For demos / implementations, look at this repo: ## Release Notes -- Fixed the 'sticky-page' bug -- Added the jumptoPage method. It's similar to the gotoPage method, but it won't do a lot of flips to reach some page. -- Fixed the bug that, when adding a Page dynamically, the Page didn't show fold gradients. +- Fixed the 'sticky-page' bug; +- Added the jumptoPage method. It's similar to the gotoPage method, but it won't do a lot of flips to reach some page; +- Fixed the bug that, when adding a Page dynamically, the Page didn't show fold gradients; +- Fixed the "RangeError #2006" bug, when a Book was instantiated without any children. ## Known Issues / Bugs -- For Book instances, height values greater than the height of the content may slow down the application. -- ScrollPolicies for Page instances are disabled (the properties have been overridden and are idle in the Page class). When a Page instance is not being flipped, its fold-gradient is drawn upon a Shape instance stored within that Page its rawChildren. When scrollbars are displayed, the Shape instance will no longer be in place. -- When a Book instance without any children is initialized a RangeError is thrown. I will look into this issue, in the meanwhile you may want to use the following workaround; Put two child Page instances in the Book instance, then (from withinin the creationComplete property of the Book instance) remove the two dummy-children by using the removeChild() method. +- For Book instances, height values greater than the height of the content may slow down the application; +- ScrollPolicies for Page instances are disabled (the properties have been overridden and are idle in the Page class). When a Page instance is not being flipped, its fold-gradient is drawn upon a Shape instance stored within that Page its rawChildren. When scrollbars are displayed, the Shape instance will no longer be in place; - When using the jumptoPage method, the previous pages are instantly rendered before the flip. Example: You are on pages 2-3 and want to go to pages 8-9. When jumptoPage is called, the pages 6-7 will override pages 2-3, before flipping to pages 8-9. ## Credits diff --git a/src/com/rubenswieringa/book/Book.as b/src/com/rubenswieringa/book/Book.as index 9cd316b..4e26853 100755 --- a/src/com/rubenswieringa/book/Book.as +++ b/src/com/rubenswieringa/book/Book.as @@ -106,7 +106,7 @@ package com.rubenswieringa.book { * @author Ruben Swieringa * and others. * http://github.com/rthesaint/FlexBook - * @version 1.0.3 + * @version 1.0.4 * @see PageManager PageManager * @see Page Page * @see BookEvent BookEvent diff --git a/src/com/rubenswieringa/containers/SuperViewStack.as b/src/com/rubenswieringa/containers/SuperViewStack.as index 8c8c016..b66d621 100755 --- a/src/com/rubenswieringa/containers/SuperViewStack.as +++ b/src/com/rubenswieringa/containers/SuperViewStack.as @@ -24,7 +24,7 @@ package com.rubenswieringa.containers { * @author Ruben Swieringa * ruben.swieringa@gmail.com * www.rubenswieringa.com - * @version 1.0.3 + * @version 1.0.4 * @see mx.containers.ViewStack * * @@ -480,9 +480,12 @@ package com.rubenswieringa.containers { * @see mx.containers.ViewStack#selectedChild */ public function get selectedChild ():Container { + if (this.numChildren == 0) + return null; + return super.getChildAt(this._selectedIndex) as Container; } - public function set selectedChild (child:Container):void { + public function set selectedChild (child:Container):void { this.selectedIndex = this.getChildIndex(child); }