Giter Club home page Giter Club logo

Comments (4)

raresn avatar raresn commented on July 18, 2024

We are using this code to generate a list of labels containg the hours of the day, that we then convert to a texture and use when needed.

from feathersui-starling.

joshtynjala avatar joshtynjala commented on July 18, 2024

You don't need to call all of those other methods after setting the text property. You can, in fact, be sure that the rendered text will change when the text setter is called. The text setter calls invalidate(), which will cause the Label to update itself before the next time that Starling renders.

public function set minutes(value:Number):void
{
	_minutes = value;
	if(_minutesInt != (value | 0)) {
		// trace("[TimeTextLabel] - update text", value);
		_minutesInt = value | 0;
		this.text = Info.minutesToText(_minutesInt);
	}
}

from feathersui-starling.

Adrian-S avatar Adrian-S commented on July 18, 2024

The problem is a bit more complex.

We are trying to draw on a RenderTexture the same Object, that extends a Sprite, containing this extended Label, multiple times. This is done only once on first run and texture is saved to png.

So rather than creating multiple objects, we try to create one, and draw it in different positions and with different text, and we do this in a for loop. We were not able to validate it and force it to show. If we don’t add that extra code it will render a texture with 00:00 only. We need to force it to paint on each update.

Maybe there is a better way to fill the texture with numbers. Any sugestion is appriciated.

The other issue here is this error:

Uncaught Error // Error // Error: Error #3768 // Error: Error #3768
	at starling.textures::ConcreteTexture/dispose()
	at feathers.controls.text::TextBlockTextRenderer/dispose()
	at starling.display::DisplayObjectContainer/removeChildAt()
	at starling.display::DisplayObjectContainer/removeChild()
	at feathers.controls::Label/createTextRenderer()
	at ro.app.items::TimeTextLabel/set minutes()

One sollution would be to add a condition and stop calling createTextRenderer(), since it's only required for texture generation. Out of the errors I've read, they were not in the texture generation part. I think error is given when probably app is in background. This might not be the most elegant fix.

Since February we had about 1000 errors related to this. Same object class is used multiple times, during the normal usage of the app, but I don't have a statistic for that. So 1000 errors could be low, or coult be high, but it's certanly enough to demand a patch.

Maybe in the future we will skip this dynamic generation and have all textures stored on a server based on DPI and download after install. Right now it's like a procedural texture, and saves the app 1-2Mb. For 3x resolution, this code generates 4 textures of 2048x2048px. But this is also a perfect copy of what air will render for text, and this was the main goal when we created this monster.

from feathersui-starling.

joshtynjala avatar joshtynjala commented on July 18, 2024

After the text gets set, the Label will be invalid, and it will need to update. Normally, this would happen before Starling renders the next frame. However, you can force it to happen immediately, like this:

label.minutes = newMinutes;
label.validate();

from feathersui-starling.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.