Problem with links when paginating
Hello, I've been struggling with this for two weeks now without being able to find a solution, so any help would be hugely appreciated.
I wrote a subclass (relevant code below) of Sprite which contains a TextFlow and a variable number of child sprites (each one of them is linked to a ContainerController in the TextFlow's flowComposer). When there's just one page everything works fine: the cursor changes when you hover over a link and it opens the browser when you click on it. The problem comes when there's more than one page: neither cursor change nor click behavior in any page.
I observed something similar happening in the Pagination example contained in the latest build anounced on the blog, except for the fact that links in the first page worked.
After reading this discussion I downloaded the latest build, copied textLayout.swc into the frameworks/libs directory of my local copy of Flex SDK 4.1 (replacing the old one) and updated the project's build path reference to that file (I'm still talking about the Pagination example) and things started to work there.
So I repeated this last step for my project, but no luck. I even rebuilt the SDK using ant after copying the new file. By the way, how can I know which version of textLayout.swc my project is using? When I expand the swc in my build path it says "textLayout_1.1.0.604.swz", but the 2.0 readme says the current build is 200... so I'm a bit confused about that.
So, here's the code for the problematic method, I would like to know if this is a bug or it's just my code is messed up. Please tell me if you need to know something else. (The comments are in Spanish, but I leave the just in case
)
private function refreshPages() : void
{
//Si se estaba viendo alguna página, guardar la posición absoluta de su primer caracter
//para después poder seguir desde ahí.
this.savePosition();
//Limpiar la lista de páginas.
this._textFlow.flowComposer.removeAllControllers();
var i : int
for (i = 0; i < this.numChildren; i++)
{
//this.getChildAt(i) = null;
this.removeChildAt(i);
}
//Se lleva la cuenta de la posición sobre x de la página actual.
var currentX : Number = 0;
var container : Sprite; //Sprite donde se va a mostrar el texto de una página.
var controller : ContainerController; //Controlador que maneja el sprite de una página.
while (true)
{
//Se crea y posiciona una nueva página.
container = new Sprite();
controller = new ContainerController(container, this._width, this._height);
controller.horizontalScrollPolicy = ScrollPolicy.OFF;
controller.verticalScrollPolicy = ScrollPolicy.OFF;
this._textFlow.flowComposer.addController(controller);
this._textFlow.flowComposer.compose();
container.x = currentX;
currentX += this._width;
//Se corta cuando ya todo el texto está cubierto por los ContainerControllers creados.
if (controller.textLength == 0 ||
controller.textLength + controller.absoluteStart > this._textFlow.textLength)
break;
}
//Se sacan los controladores vacíos, y se agregan los containers válidos al componente.
for (i = 0; i < this._textFlow.flowComposer.numControllers; i++)
{
var currentController : ContainerController = this._textFlow.flowComposer.getControllerAt(i);
if (currentController.textLength == 0)
this._textFlow.flowComposer.removeControllerAt(i);
else
this.addChild(currentController.container);
}
//Se redibujan los controladores.
this._textFlow.flowComposer.updateAllControllers();
//Se trata de ir a la página en la que está el contenido que el
//usuario estaba probablemente leyendo.
this.restorePage();
}
Thanks.
