Text Object Reference Point Not Sticking

When I create a text object and then set the reference point to CenterLeftReferencePoint, when I later change the text of the text object the text object’s reference reverts to CenterReference Point. Resetting the reference point and location work, but shouldn’t be necessary.

txt = display.newText("test",0,0,nil,48);  
txt:setReferencePoint(display.CenterLeftReferencePoint);  
txt.x = display.contentWidth \* 0.5; txt.y = 100;  
  
 function txt:touch(e)  
 if e.phase == "ended" then  
 txt.text = "longer phrase"  
 end  
 end  
  
 txt:addEventListener("touch",txt)  

The above code produces the error. Adding two lines (seen below) “fixes” the problem.

txt = display.newText("test",0,0,nil,48);  
txt:setReferencePoint(display.CenterLeftReferencePoint);  
txt.x = display.contentWidth \* 0.5; txt.y = 100;  
  
 function txt:touch(e)  
 if e.phase == "ended" then  
 txt.text = "longer phrase"  
 txt:setReferencePoint(display.CenterLeftReferencePoint); --reset reference point  
 txt.x = display.contentWidth \* 0.5; txt.y = 100; -- reset location  
 end  
 end  
  
 txt:addEventListener("touch",txt)  

I submitted a bug report (8309). Am I missing something? [import]uid: 64596 topic_id: 15573 reply_id: 315573[/import]

Here’s an explanation regarding this. This isn’t most intuitive, but once you understand the mechanics of it, it isn’t so bad…

In our current design, reference points are statically positioned relative to the object’s local origin. When the text changes, the width and height of the text object change, so the reference point is no longer along the left boundary of the object like it was before.

http://developer.anscamobile.com/forum/2010/02/04/text-assignment-clears-reference-point#comment-5687 [import]uid: 67217 topic_id: 15573 reply_id: 57514[/import]