Skip to main content
Participant
October 19, 2011
Question

LinkElement become NOT clickable when it scroll out of TextArea view

  • October 19, 2011
  • 1 reply
  • 1102 views

Hi:

I am writing a online call center product with flash builder 4.5.

I found a tricky problem with LinkElement.

I use the TextArea as the display stage for each incoming and outgoing message. Obviously, the messages includes image and href.

I use LinkElement to display them.

As conversation continues, the TextArea's view scrolls to display more and more content.

When LinkElement scrolls out of the viewable area of TextArea, it becomes NOT clickable!!!

If I change the size or height of TextArea, make the LinkElement shows in view of TextArea, it becomes Clickable.

But changing the size of TextArea is not a workable way to fix this problem, espetially for a long conversation.

The source code is too long, I have to show some snapshot.

=============================================================================

Following is function to generate Paragraph to be inserted into TextArea.



private function imageToLocalParagraph(



role:int, customerId:int, stationId:int, imageTitle:String, imageUrl:String):ArrayList{








var selfName:String = getRoleName(role, customerId, stationId);



var color:uint = getColor(role);



var timeStr:String = getTimeString();



var list:ArrayList = new ArrayList();








var p:ParagraphElement = new ParagraphElement();





var span:SpanElement = new SpanElement();



span.text =




timeStr + " " + selfName;



span.fontSize = _fontSize;



span.color = color;



p.addChild(span);



list.addItem(p);








var p2:ParagraphElement = new ParagraphElement();



var inf:Object = {color:0xFF0000};  



p2.linkHoverFormat = inf;





var link:LinkElement = new LinkElement();



link.href = imageUrl;



link.target = "_blank";



link.addEventListener(FlowElementMouseEvent.CLICK, onImageClick);



var linkSpan:SpanElement = new SpanElement();



linkSpan.text = "点击打开" + imageTitle;



linkSpan.fontSize = _fontSize;



linkSpan.color = color;



link.addChild(linkSpan);



p2.addChild(link);



list.addItem(p2);








return list;




}

Following is the TextArea that contains each paragraph.

=================================================================


<s:TextArea id="textArea"




editable="false"




focusEnabled="true"




horizontalCenter="0"




width="100%"




height="70%">


<s:textFlow>



<s:TextFlow>




<s:p><s:a href="http://adobe.com/" target="_blank"></s:a></s:p>



</s:TextFlow>


</s:textFlow>

</s:TextArea>

When sprite is created complete, event listener is set for TextArea and this. ParagraphElementEvent is new defined event to receive paragraph list.





this.textArea.textFlow.addEventListener(





CompositionCompleteEvent.COMPOSITION_COMPLETE, compositionCompleteHandler);









this.addEventListener(ParagraphElementEvent.TYPE, onParagraphElementEvent);

When receiving paragraph list event, TextArea will add it and auto scroll view to bottom.

======================================================================================================




private function onParagraphElementEvent(event:ParagraphElementEvent):void {





if (event.eventId == this._customer.customerId) {





var list:ArrayList = event.paragraphElementList;











for (var i:int = 0; i < list.length; i++) {






var p:ParagraphElement = (ParagraphElement)(list.getItemAt(i));






this.textArea.textFlow.addChild(p);





}











// auto scrolling to bottom with 3 ways, the last one is perfect





// (1) this.textArea.appendText("");





// (2) this.textArea.scrollToRange(int.MAX_VALUE, int.MAX_VALUE);





// (3) call scrollToBottom twice when textFlow.addChild and textFlow.CompositionCompleteEvent





scrollToBottom();




}



}







private function compositionCompleteHandler(event:CompositionCompleteEvent):void {




scrollToBottom();



}







private function scrollToBottom():void {




this.textArea.validateNow();




var maximum:Number = this.textArea.scroller.verticalScrollBar.maximum;




this.textArea.scroller.verticalScrollBar.value = maximum;



}




I don't think it is a problem of Flash builder 4.5.

LinkElement is a commen component.

Thanks

Steven

This topic has been closed for replies.

1 reply

Participant
October 19, 2011

Some additional information:

The scenario of "NOT clickable" means that:

(1) LinkElement become out of current view of text area due to scrolling;

(2) Scrolls the scroller to re-display the LinkElement out of the current view,

(3) click the link element.

(4) Text Area auto scrolls to bottom and nothing happens. If it works, a new browser window should be opened and the content is the href of LinkElement.

Participating Frequently
October 20, 2011

I tried to implement a test for your case. But i am wondering, if you already scrolls the link out of your textArea's view, that means the link is invisable, how to click the link ?

What i tested is:

1. Create a long text, apply a link in the middle of the text.

2. Scroll down to make the text invisable.

3. Scroll back, and click the link. it works.

Can you please make more clear of your case ?

Participant
October 21, 2011

hi:

the reason has been figured out:

It results from CompositionCompleteEvent.COMPOSITION_COMPLETE.

this.textArea.textFlow.addEventListener(CompositionCompleteEvent.COMPOSITION_COMPLETE, compositionCompleteHandler);

If we scrolls the text area to show the LinkElement invisible,

Click the the Link element, will trigger CompositionCompleteEvent again.

In my implementation, CompositionCompleteEvent  will scrolls the text area to bottom immediately.

It looks that the link not works.

The reason is found, but another question is created:

What is the solution for the text area, which satisfys two aspects:

(1) auto scroll to bottom;

(2) make the link element workable when scrolls.

This is important for IM applications.