Skip to main content
Inspiring
May 12, 2011
Question

Getting a runtime error in ContainerController

  • May 12, 2011
  • 6 replies
  • 24316 views

Using SDK 4.5.0.20967

The error is thrown on line 3182:

while (containerListIndex == -1 && floatIndex > 0)

{

     floatIndex--;

     floatInfo = _composedFloats[floatIndex - 1];

     containerListIndex = _floatsInContainer.indexOf(floatInfo.graphic);

}

floatIndex is 1 when it enters the loop,

then it is decresed to 0,

then null gets assigned to floatInfo - when it is looking for:  _composedFloats[-1]

Then it throws an error when it tries to access a property on floatInfo - which is set to null

Here is the error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

     at flashx.textLayout.container::ContainerController/http://ns.adobe.com/textLayout/internal/2008::updateGraphics()

    

I am not sure exactly how I am triggering this - I am trying to discern that - but if you have any thoughts - please let me know.

This topic has been closed for replies.

6 replies

Participant
April 12, 2012

Jin-Huang thank you too much for your help. Could you please help me. I have made chat where i used component textLayout. I had issue with freezing scrollBar. Then i downloaded textLayout 3.0 and issue was fixed. But then i had

new issue at some point chat is blank, wipe and doesn't write any message. Before this happens i catch error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

                at flashx.textLayout.container::ContainerController/http://ns.adobe.com/textLayout/internal/2008::updateGraphics()

                at flashx.textLayout.container::ContainerController/http://ns.adobe.com/textLayout/internal/2008::updateCompositionShapes()

                at flashx.textLayout.compose::StandardFlowComposer/updateCompositionShapes()

                at flashx.textLayout.compose::StandardFlowComposer/updateToController()

                at flashx.textLayout.container::ContainerController/updateForScroll()

                at flashx.textLayout.container::ContainerController/set verticalScrollPosition()

                at flashx.textLayout.container::ContainerController/autoScrollIfNecessaryInternal()

                at flashx.textLayout.container::ContainerController/autoScrollIfNecessary()

                at flashx.textLayout.container::ContainerController/mouseMoveHandler()

                at flashx.textLayout.container::ContainerController/http://ns.adobe.com/textLayout/internal/2008::rootMouseMoveHandler()

               

                I used flex builder 4.5.0. I am sure that i set all properties correct (Merge-Into-Code etc). So can i take source code this library? Maybe should i update flex builder etc. Please help us. Thank you.

Adobe Employee
April 12, 2012

http://sourceforge.net/projects/tlf.adobe/files/3.0/

You can download the source code from the link above. Copy the .as file into your project and remove the swc (I mean you compile your application with TLF code, not swc), you will know exactly which line failed.

Participating Frequently
June 6, 2012

In many of your post you keep saying that you can just host the libaray on your own server. Ive been trying to do that and i keep getting the following error...

Flex Error #1001: Digest mismatch with RSL http://www.domain.com/test/textLayout.swf. Redeploy the matching RSL or relink your application with the matching library.

Participant
September 21, 2011

Sorry for that.

My project is set to Runtime-Shared-Library.

What URL in particular do I have to modify?

<!-- TextLayout SWC -->

      <runtime-shared-library-path>

        <path-element>libs/textLayout.swc</path-element>

        <rsl-url>http://fpdownload.adobe.com/pub/swz/tlf/2.0.0.232/textLayout_2.0.0.232.swz</rsl-url>

        <policy-file-url>http://fpdownload.adobe.com/pub/swz/crossdomain.xml</policy-file-url>

        <rsl-url>textLayout_2.0.0.232.swz</rsl-url>

        <policy-file-url></policy-file-url>

    </runtime-shared-library-path>

Is it here somewhere?

I'm new to flex so please bare with my silly questions. I really appreaciate your help Jin.

Adobe Employee
September 22, 2011

For now, there is no available rsl-url for 3.0 rsl library. We are applying for the access of http://fpdownload.adobe.com to upload 3.0 rsl library.

If you have your own server, you can put 3.0 swz on it and use your own url. The url must be direct.

Participant
September 21, 2011

I've copied the textLayout.swc file into the \frameworks\libs folder but i keep getting the same error.

Only now I can't see the content of the ContainerController class.

The stack trace only indicates that the error comes from the updateGraphics method.

Are you certain that there isn't anything else to do in order to make the TLF 3.0 work in the flex SDK?

Is there an Ant build neccesary?

Adobe Employee
September 21, 2011

I'm sure.

Pls pay attention to my last reply and your configuration.  Did you set framework linkage of project as Merge-Into-Code? Have you cleaned your project and re-compile?

Participant
September 19, 2011

Hi.

I've noticed that TLF 3.0 was launched on sourceforge.

My question is: how can i update my flex sdk to use the new TLF?

I've copied the new folders of TLF 3.0 over the old ones but that does not help.

Any help is apreciated.

Thanks

September 19, 2011

I'd like to +1 the questions about integrating the tlf 2.1 (waiting for the 3.0swz) to my project.

In flashBuilder i have 3 projects:

2 library projects representing my appFramework (core and utils)

1 appProject

In my libraries projects the framework linkage is external.

In parallele in my app Project

So far no luck

I also tried in a release build i did to savagely paste textLayout_2.1.0.6.swz and rename it like the 2.0... one i had (I thought it worked for a second but unfortunatly didn't)

Any hints on a way to use the fixed lib instead of the 2.0 ?

Thanks in advance

Adobe Employee
September 20, 2011

In my libraries projects the framework linkage is external.

In parallele in my app Project

1. rsl libraries in frameworks\libs are just copies of the libraries on the server. They are not linked in your runtime.

2. it should work that you change link configuration of sdk. But http://sourceforge.net/projects/tlf.adobe/files/2.1/6/textLayout2.0.0.6.swz will be redirect to another place when you try to download the that swz...So the link showed on sourceforge cannot work. URL for SWZ should always be a direct link. Please wait for the RSL library on Adobe hosted server or you put RSL libraries on your own server.

josh_onAuthor
Inspiring
September 13, 2011

Do you know when the earliest date that the 3.0 swz will be uploaded? Could that happen before next year?

Thanks.

Adobe Employee
September 14, 2011

We are trying to get the access to upload rsl on that server. If we got the access, rsl will be there soon. But I cannot promise you the time. I will tell you here if state changes.

josh_onAuthor
Inspiring
May 13, 2011

Here is an example of the bug, the yellow box in the TextFlow is an InlineGraphicElement.

Click the red box at the bottom of the flow to start adding text.

It crashes once the InlineGraphicElement is pushed out of the visible area of the container.

http://www.theyrule.net/test/tlf_images/SingleContainerTest.swf

This was published using the SDK 4.5.0.20967

Here is the same file published with HERO - which still has the other inlineGraphic alignment problem - but does not have the runtime error:

http://www.theyrule.net/test/tlf_images/SingleContainerTestHero.swf

Here is the source:

package

{

import flash.display.Sprite;

import flash.display.StageAlign;

import flash.display.StageScaleMode;

import flash.events.Event;

import flash.events.MouseEvent;

import flash.system.System;

import flash.text.TextField;

import flash.text.TextFormat;

import flashx.textLayout.container.ContainerController;

import flashx.textLayout.container.ScrollPolicy;

import flashx.textLayout.edit.EditManager;

import flashx.textLayout.elements.DivElement;

import flashx.textLayout.elements.InlineGraphicElement;

import flashx.textLayout.elements.ParagraphElement;

import flashx.textLayout.elements.SpanElement;

import flashx.textLayout.elements.TextFlow;

import flashx.textLayout.formats.TextLayoutFormat;

import flashx.textLayout.formats.VerticalAlign;

import flashx.textLayout.tlf_internal;

import flashx.undo.UndoManager;

use namespace tlf_internal;

[SWF (width="500", height="700", backgroundColor="#FFFFFF")]

public class SingleContainerTest extends Sprite

{

protected var tf:TextFlow;

protected var em:EditManager;

protected var um:flashx.undo.UndoManager

protected var _bg:Sprite;

protected var _spr:Sprite;

protected var _cc:ContainerController

protected var _init_fmt:TextLayoutFormat;

protected var _btn:Sprite;

protected var _playing:Boolean = false;

protected var _count:int = 0;

protected var _graph:Sprite;

protected var _print_out:TextField;

protected var _last_time:Date = new Date();

protected var _last_five:Array = [];

public function SingleContainerTest()

{

stage.scaleMode = StageScaleMode.NO_SCALE;

stage.align = StageAlign.TOP_LEFT;

var cw:Number = 200; // the container width

var ch:Number = 600;  // the container height

_bg = new Sprite();

_bg.graphics.lineStyle(.25, 0);

_bg.graphics.drawRect(0,0,cw,ch);

addChild(_bg);

_spr = new Sprite();

addChild(_spr);

_graph = new Sprite();

_graph.x = cw + 10;

_graph.y = 250;

addChild(_graph);

_print_out = new TextField();

var fmt:TextFormat = _print_out.defaultTextFormat;

fmt.font = "_sans";

_print_out.wordWrap = true;

_print_out.multiline = true;

_print_out.width = stage.stageWidth - (10 + _graph.x);

_print_out.x = _graph.x;

_print_out.y = _graph.y + 10;

addChild(_print_out);

//define TextFlow and manager objects

tf = new TextFlow();

um = new UndoManager();

em = new EditManager(um);

tf.interactionManager = em;  

//compose TextFlow to display

_cc = new ContainerController(_spr,cw,ch);

//_cc.verticalAlign = VerticalAlign.BOTTOM;

//_cc.verticalScrollPolicy = ScrollPolicy.ON;

tf.flowComposer.addController(_cc);

tf.flowComposer.updateAllControllers();

//make a button to add Inline Graphic elements

_btn = new Sprite();

_btn.graphics.beginFill(0xFF0000,1);

_btn.graphics.drawRect(0,0,120,30);

addChild(_btn);

_btn.addEventListener(MouseEvent.CLICK, btnClicked);

_btn.y = 600;

addMessage("1");

addMessage("2");

addMessage("3", true);

}

public function addMessage(msg:String, add_image:Boolean = false):void {

//define elements to contain text

var d:DivElement = new DivElement();

var p:ParagraphElement = new ParagraphElement();

var s:SpanElement = new SpanElement();

s.text = msg;

//add these elements to the TextFlow

p.addChild(s);

d.addChild(p);

if(add_image){

var sp:Sprite = new Sprite();

sp.graphics.beginFill(0xFFCC00);

sp.graphics.drawRect(0,0,100,20);

var i:InlineGraphicElement = new InlineGraphicElement();

i.source = sp;

i.width = 100;

i.height = 20;

p.addChild(i);

}

tf.addChild(d);

tf.flowComposer.updateAllControllers();

_cc.verticalScrollPosition = _cc.getContentBounds().height;

tf.flowComposer.updateAllControllers();

}

protected function btnClicked(e:MouseEvent):void {

_playing = !_playing;

removeEventListener(Event.ENTER_FRAME, onEnterFrame);

if(_playing){

addEventListener(Event.ENTER_FRAME, onEnterFrame);

}

}

protected function onEnterFrame(e:Event):void {

_count++;

if(_count > 100){

tf.removeChildAt(0);

}

addMessage("Message Number: " + _count + " " + randomString());

printOut()

}

protected function printOut():void {

var now:Date = new Date();

var tm:Number = (now.getTime() - _last_time.getTime());

_last_five.push(tm);

if(_last_five.length > 10) _last_five.shift();

var avg_tm:Number = 0;

for(var i:int = 0; i < _last_five.length; i++) avg_tm += _last_five;

avg_tm = Math.round(avg_tm/_last_five.length);

var elapsed_str:String = "message: \t\t\t"+_count

+ "\ntime: \t\t\t\t" + tm + "ms"

+ "\navg of last 10:\t\t" + avg_tm +"ms";

//trace(elapsed_str );

_print_out.text = elapsed_str;

_last_time = now;

drawGraph(tm);

}

protected function drawGraph(tm:Number):void {

if(_count % 5 == 0){

_graph.graphics.beginFill(0x0);

_graph.graphics.drawRect(_count/10,-Math.round(tm/10),1,1);

_graph.graphics.beginFill(0xFF0000);

_graph.graphics.drawRect(_count/10,-Math.round(System.totalMemory/1000000),1,1);

}

}

protected function randomString():String {

var chars:String = "abcdefghijklmnopqrstuvwzyz                    ";

var chars_len:Number = chars.length;

var random_str:String = "";

var num_chars:Number = Math.round(Math.random() * 100);

for (var i:int =0; i < num_chars; i++){

random_str = random_str + chars.charAt(Math.round(Math.random() * chars_len));

}

return random_str;

}

}

}

Adobe Employee
May 13, 2011

It can be reproduced with SDK 4.5 (tlf 2.0.232 in it). But your code works well without any runtime error when compiled with tlf 3.0.5 on my machine, which is not released officially to the outside of Adobe.


I'm not sure when flex team will add tlf 3.0 into their SDK.