From issues-return-9839-apmail-flex-issues-archive=flex.apache.org@flex.apache.org Sun Dec 13 08:44:47 2015 Return-Path: X-Original-To: apmail-flex-issues-archive@minotaur.apache.org Delivered-To: apmail-flex-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3EF9E18532 for ; Sun, 13 Dec 2015 08:44:47 +0000 (UTC) Received: (qmail 73685 invoked by uid 500); 13 Dec 2015 08:44:47 -0000 Delivered-To: apmail-flex-issues-archive@flex.apache.org Received: (qmail 73658 invoked by uid 500); 13 Dec 2015 08:44:47 -0000 Mailing-List: contact issues-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list issues@flex.apache.org Received: (qmail 73649 invoked by uid 99); 13 Dec 2015 08:44:46 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 Dec 2015 08:44:46 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id C807A2C1F6B for ; Sun, 13 Dec 2015 08:44:46 +0000 (UTC) Date: Sun, 13 Dec 2015 08:44:46 +0000 (UTC) From: "Harbs (JIRA)" To: issues@flex.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (FLEX-34988) Number of characters with images is wrong MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FLEX-34988?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15054862#comment-15054862 ] Harbs commented on FLEX-34988: ------------------------------ Right. Here is the code I was using which works in AFB: package { import flash.display.Sprite; import flash.events.Event; import flash.events.TimerEvent; import flash.utils.Timer; import flashx.textLayout.compose.StandardFlowComposer; import flashx.textLayout.container.ContainerController; import flashx.textLayout.container.ScrollPolicy; import flashx.textLayout.conversion.TextConverter; import flashx.textLayout.edit.EditManager; import flashx.textLayout.elements.InlineGraphicElement; import flashx.textLayout.elements.TextFlow; import flashx.textLayout.formats.TextLayoutFormat; public class TLF_Bench_Images extends Sprite { private var oTextFlow:TextFlow; private var oSprite:Sprite; private var oController:ContainerController; private var oEditManager:EditManager; private var oFormat:TextLayoutFormat; private var nWidth:Number = 750; private var nHeigth:Number = 500; private var sParagraphText:String; private var sPageText:String; private var sText:String = ""; private var nXPos:Number = 50; private var nYPos:Number = 50; private var iPages:int = 4; // Number of pages "DIN A4". private var iColour:int = 0xFFFF66; private var iPos_Start; private var iPos_End; private var iTextLength; private var nTime_Start; private var nTime_End; private var timer:Timer; public function TLF_Bench_Images() { loaderInfo.addEventListener(Event.INIT, initHandler); } public function initHandler(event:Event):void { loaderInfo.removeEventListener(Event.INIT, initHandler); addEventListener(Event.ENTER_FRAME, enterFrameHandler); } public function enterFrameHandler(event:Event):void { removeEventListener(Event.ENTER_FRAME, enterFrameHandler); doTest(); } public function doTest():void { //------------------ Create a long Text. sText has a 100 "DIN A4" pages length more or less. sParagraphText = "aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa . \n \n"; sPageText = sParagraphText; // + sParagraphText + sParagraphText + sParagraphText + sParagraphText + sParagraphText + sParagraphText + sParagraphText + sParagraphText; for ( var i:int = 0; i < iPages; i++) { sText += sPageText; } // for j //------------------ Create de TextFlow and the elements we need to display it. oTextFlow = new TextFlow(); oSprite = new Sprite(); oSprite.x = nXPos; oSprite.y = nYPos; this.addChild( oSprite ); oTextFlow = TextConverter.importToFlow( sText, TextConverter.PLAIN_TEXT_FORMAT ); oTextFlow.fontSize = 30; oController = new ContainerController( oSprite, nWidth, nHeigth ); oController.verticalScrollPolicy = ScrollPolicy.ON; //-- oTextFlow.flowComposer = new StandardFlowComposer(); oTextFlow.flowComposer.addController(oController); oTextFlow.flowComposer.updateAllControllers(); //-- oEditManager = new EditManager(); oTextFlow.interactionManager = oEditManager; //------------------ Scroll to the end of the Textflow. iTextLength = oTextFlow.getText().length; iPos_Start = iTextLength - 200; iPos_End = iTextLength - 20; oController.scrollToRange( iPos_Start, iPos_End ); //------------------ Get text BEFORE. sText = oTextFlow.getText(); trace("BEFORE - sText.length:", sText.length, " oTextFlow.textLength:", oTextFlow.textLength); //------------------ Add 3 images. var oInlineGraphic:InlineGraphicElement; oEditManager.selectRange( 10, 10 ); oInlineGraphic = oEditManager.insertInlineGraphic( "image/Image.png", 50, 30 ); oEditManager.selectRange( 20, 20 ); oInlineGraphic = oEditManager.insertInlineGraphic( "image/Image.png", 50, 30 ); oEditManager.selectRange( iTextLength - 10, iTextLength - 10 ); oInlineGraphic = oEditManager.insertInlineGraphic( "image/Image.png", 50, 30 ); //---------- Prove to uncomment this line. //oController.verticalScrollPosition = 0; sText = oTextFlow.getText(); trace("AFTER - sText.length:", sText.length, " oTextFlow.textLength:", oTextFlow.textLength ); oEditManager.setFocus(); //------------------ Get text AFTER. //------------------ RESULTS: // We have added 3 images, but getText() function only returns the last one. // // NOTE_1: If you uncomment [oController.verticalScrollPosition = 0;] line after adding the 3rd image, it returns the first two images. // So, it seems getText() function only returns the images that have appeared on screen. // // NOTE_2: On the other hand, as you can see in the example, the [textLength] attribute returns one more character than [getText().length]. //------------------ END } } } > Number of characters with images is wrong > ----------------------------------------- > > Key: FLEX-34988 > URL: https://issues.apache.org/jira/browse/FLEX-34988 > Project: Apache Flex > Issue Type: Bug > Components: TLF > Affects Versions: Apache Flex 4.14.0 > Reporter: goratz > Attachments: Image.png, TLF_Bench_Images.as, TLF_Bench_Images.fla > > > Hi, I have a problem when I insert images in the text. When I get the text of the TLF the number of characters is wrong. It only counts the images that are displayed. > I build a test code to see the problem. > ----------------------------------------------------------------------------------------------- > I added 3 images, but getText() function only returns the last one. > NOTE_1: If you uncomment [oController.verticalScrollPosition = 0;] line after adding the 3rd image, it returns the first two images. > So, it seems getText() function only returns the images that have appeared on screen. > NOTE_2: On the other hand, as you can see in the example, the [textLength] attribute returns one more character than [getText().length]. -- This message was sent by Atlassian JIRA (v6.3.4#6332)