Dealing with single line long strings in TextObjects

Hey guys, I am creating a story telling app. I have lots of text to display, but I want it displayed all on a single line that will go off the screen, and the user can drag the object horizontally as they read the text to bring more text on screen. The issue I am having is that once my text object gets such a long string of text, it shows up as a black box in the app. Is there any way to get around this limit on how wide the text object can be? Only solution i can think is to make several text objects and create them next to each other, but to make that work well i would need a way to have my code know how wide each text object is… Any ideas or thoughts would be great. Thanks!

Ps- im trying to avoid wrapping text because i dont want huge blocks of text covering my screen, just trying to keep it down to this single thin line that can be scrolled by the user. [import]uid: 19620 topic_id: 24088 reply_id: 324088[/import]

That’s a neat idea. Interested to see how it turns out.

Couldn’t you use this to determine width?

(object.contentBounds.xMax - object.contentBounds.xMin)

If that doesn’t work maybe just add it to a display group and see if you can measure the display group width…

[import]uid: 41884 topic_id: 24088 reply_id: 97161[/import]

Thanks for the tips, ill try those when i get off work and let you know how it turns out. [import]uid: 19620 topic_id: 24088 reply_id: 97200[/import]

Hmm im sure i could find a way to make the above idea work, but its going to be quite a pain to hard code the width for what the text object should be for each page. Ill have to delete and recreate it depending on the page n such. Is there really no way to get around a text string being as long as we want? [import]uid: 19620 topic_id: 24088 reply_id: 97217[/import]

So I was able to determine widths using “object.contentWidth” for my different text objects. It worked out well, but in the end, the idea of scrolling the text on a single line seems too much like a news feed. So im going to abandon the idea, but its workable. Hopefully helpful to some other person. [import]uid: 19620 topic_id: 24088 reply_id: 97232[/import]

Hi rxmarccall,

Sounds like you are moving away from this in your app, but here is a bit of code I posted to the Code Exchange that breaks long strings into separate display objects automatically for a “news ticker” look. It breaks them up into a pre-defined number of characters per display object that you can adjust (for example if you used an extra large font, you’d want to decrease the character count per display object).

There’s also code in here to stream a Twitter feed as a ticker, but you can disregard that part. In my example, I pull the text from a hosted .txt file, but you could just plug in your text as a variable and it would work just fine. Hope you find it useful.

Here’s the link: http://developer.anscamobile.com/code/streaming-news-ticker-twitter-feed-or-online-text-file [import]uid: 27636 topic_id: 24088 reply_id: 97238[/import]

Oh awesome, that is very helpful and a better approach to what i was trying to do. Thanks for posting that, while i will probly not use it on the main interactions of my app, im thinking of using it on the apps home screen as a news update. Thanks again! [import]uid: 19620 topic_id: 24088 reply_id: 97346[/import]