History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: LPP-2587
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: -- --
Assignee: Mamye Kratt
Reporter: sanjaya lai
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OpenLaszlo

refreshing fontstyle attribute for lazy replicated text is not working for lzr=swf8

Created: 30/Aug/06 07:12 PM   Updated: 14/Sep/06 04:19 AM
Component/s: LFC - Text
Affects Version/s: None
Fix Version/s: 3.4

Time Tracking:
Not Specified

Severity: Minor
Fixed in Change#: 1,838
Runtime: N/A
Flags: Support
Fix in hand: False


 Description  « Hide
Hi,

I am having a problem updating the "fontsyle" attribute for a lazy replicated text object when compiling into swf8.
in the same swf8 compilation, this problem is not happening.

For swf7, I can update the "fontstyle" attribute properly for both regular replicated text object and lazy replicated text object.
To better exhibit the issue, I included a testcase.

Thanks.

Sanjaya

<canvas debug="true">
   <dataset name="ds">
       <root>
           <text name="my-yellow-10-plain" fgcolor="0xFFFF00" fontsize="10" fontstyle="plain"/>
           <text name="my-blue-11-bold" fgcolor="0x0000FF" fontsize="11" fontstyle="bold" />
           <text name="my-red-12-italic" fgcolor="0xFF0000" fontsize="12" fontstyle="italic" />
           <text name="my-green-13-bolditalic" fgcolor="0x339900" fontsize="13" fontstyle="bolditalic" />
       </root>
   </dataset>
   <datapointer name="dp" xpath="ds:/root"/>

   <method name="refresh" args="c, startIndex">
   <![CDATA[
       var arr = [];
       var currIndex = startIndex;
       var max = 4;

       for (var i = 0; i < max; i++){
           Debug.write(i, " arr["+i+"] = dp.subnodes["+currIndex+"]");
           
           arr[i] = dp.p.childNodes[currIndex];

           //currIndex = Math.abs(max - (currIndex + count));
           currIndex = (currIndex + 1);
           if (currIndex == max)
              currIndex = 0;
       }
       c.testtext.datapath.setNodes(arr);
       Debug.write("refresh() ",arr);
   ]]>
   </method>

   <view>
       <simplelayout axis="x" spacing="10"/>
       <view>
           <simplelayout />
           <text fontstyle="bold" fontsize="15">Regular replication</text>
           <button text="start 0" onclick="canvas.refresh(container,0)" />
           <button text="start 1" onclick="canvas.refresh(container,1)" />
           <button text="start 2" onclick="canvas.refresh(container,2)" />
           <button text="start 3" onclick="canvas.refresh(container,3)" />
        
           <button text="rapidclick">
               <handler name="onclick">
               <![CDATA[
                   var max = 20;
        
                   for (var i = 0; i < max; i++){
                       var j = i % 4;
                       canvas.refresh(container,j);
                   }
               ]]>
               </handler>
           </button>
        
           <view id="container" height="200" width="300" bgcolor="gray">
              <simplelayout />
              <text name="testtext" resize="true">
                  <datapath xpath="ds:/root/text"/>
                  <handler name="ondata">
                      var dat = this.data;
                      this.setAttribute("text",dat.getAttr('name'));
                      this.setAttribute("fgcolor",dat.getAttr('fgcolor')*1);
                      this.setAttribute("fontsize",dat.getAttr('fontsize'));
                      this.setAttribute("fontstyle",dat.getAttr('fontstyle'));
                  </handler>
              </text>
           </view>
       </view>
    
    
       <view>
           <simplelayout />
           <text fontstyle="bold" fontsize="15">Lazy replication</text>
           <button text="start 0" onclick="canvas.refresh(container2,0)" />
           <button text="start 1" onclick="canvas.refresh(container2,1)" />
           <button text="start 2" onclick="canvas.refresh(container2,2)" />
           <button text="start 3" onclick="canvas.refresh(container2,3)" />
        
           <button text="rapidclick lazy rep">
               <handler name="onclick">
               <![CDATA[
                   var max = 20;
        
                   for (var i = 0; i < max; i++){
                       var j = i % 4;
                       canvas.refresh(container2,j);
                   }
               ]]>
               </handler>
           </button>
        
           <view id="container2" datapath="ds:/root" height="200" width="300" bgcolor="gray">
              <simplelayout />
              <text name="testtext" resize="true">
                  <datapath xpath="text" replication="lazy" />
                  <handler name="ondata">
                      var dat = this.data;
                      this.setAttribute("text",dat.getAttr('name'));
                      this.setAttribute("fgcolor",dat.getAttr('fgcolor')*1);
                      this.setAttribute("fontsize",dat.getAttr('fontsize'));
                      this.setAttribute("fontstyle",dat.getAttr('fontstyle'));
                  </handler>
              </text>
           </view>
       </view>
    </view>
</canvas>

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Benjamin Shine - 31/Aug/06 04:39 PM
Looking into the code for this, I notice that we never close the B, I, or U tags which are set in LzText.setFormat, in LzText6.as line 790-799:
    if (this.fontstyle == "bold" || this.fontstyle =="bolditalic"){
        this.format += "<B>";
    }

    if (this.fontstyle == "italic" || this.fontstyle =="bolditalic"){
        this.format += "<I>";
    }
    if (this.underline){
        this.format += "<U>";
    }
}

P T Withington - 07/Sep/06 09:34 PM
Based on Ben's observation, I tried closing the tags (i.e., putting properly-formatted HTML in the htmlText of a TextField) and that appears to solve the problem. My hunch is that the swf8 TextField is ignoring (some) html that is not properly formatted, hence not updating as we expect.

P T Withington - 14/Sep/06 04:18 AM
r1838 | ptw | 2006-09-14 07:17:17 -0400 (Thu, 14 Sep 2006) | 18 lines
Changed paths:
   M /openlaszlo/trunk/WEB-INF/lps/lfc/views/LzText6.as
   M /openlaszlo/trunk/test/bugs/lpp-2587.lzx

Change change.bRStyRUqK.txt by ptw@tin-woodsman.local /Users/ptw/pending-changes/ on 2006-09-07 21:08:34 EDT

Summary: Use properly formatted HTML to style text

Bugs Fixed:
LPP-2587 refreshing fontstyle attribute for lazy replicated text is not working for lzr=swf8

Technical Reviewer: hminsky (pending)
QA Reviewer: ben (Message-Id: <6B969305-FFFE-4FB1-BEC4-1A66A74A841B@laszlosystems.com>)
Doc Reviewer: n/a

Details:
    By trial and error I discovered that Flash 8 TextFields seem to
    arbitrarily reject malformed HTML. I changed LzText to use
    properly formed HTML for styling.

Tests:
    test/bugs/lpp-2587.lzx

P T Withington - 14/Sep/06 04:19 AM
Assigning to Mamye for verification. Sanjaya's test file is checked in with this bug number.