Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411588 Posts in 69386 Topics- by 58443 Members - Latest Member: Mansreign

May 06, 2024, 12:21:39 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)A Few Questions About Flash
Pages: 1 [2] 3
Print
Author Topic: A Few Questions About Flash  (Read 9362 times)
ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #20 on: November 11, 2008, 12:37:56 PM »

It'd still be good to be able to draw things at varying degrees of transparency. For instance, let's say you wanted a sprite to fade out, changing its transparency from 1 to 0 over time; could that be done without creating an animation strip of png files?

I've heard that about Flash 10 too, but I'll wait and see. It's the main reason stopping me from learning Flash, everything just goes so slow in it. 20 fps games are typical, even on very fast computers, and it's hard for me to play an action game that runs in like 20 fps, because the animation is so jagged that it hurts the eyes and because the response time is so slow.
Logged

Gnarf
Guest
« Reply #21 on: November 11, 2008, 12:41:28 PM »

For instance, let's say you wanted a sprite to fade out, changing its transparency from 1 to 0 over time; could that be done without creating an animation strip of png files?

Yes.
Logged
Problem Machine
Level 8
***

It's Not a Disaster


View Profile WWW
« Reply #22 on: November 11, 2008, 12:42:43 PM »

Quote
could that be done without creating an animation strip of png files?
Yeah each display object has an alpha value; the only problem is that animating alphas with no hardware acceleration can be REALLY slow, so I guess it depends on how good the hardware support in Flash 10 actually is.

Logged

ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #23 on: November 11, 2008, 12:43:03 PM »

Hmm, good to know. I wonder why more Flash games don't use transparency, then? Is it that most of them are made in older versions of Flash?

EDIT: I guess the above post answers that (about how slow it'd be).
Logged

John Nesky
Level 10
*****


aka shaktool


View Profile WWW
« Reply #24 on: November 11, 2008, 02:12:43 PM »

There is nothing special about animating alpha that makes it slow. Animating alpha just means that you're constantly redrawing the sprite on the screen, which you'd be likely be doing anyway. (unless you force it to render the sprite offscreen before applying alpha, which is useful for certain effects but is a little slower and is usually unnecessary)

Vector graphics tend to render slowly, but depending on the situation you can render vector graphics once and cache that to a bitmap, and then just animate the position, orientation, size, and alpha of that bitmap and it should be fine.

I'm annoyed at the misconceptions about Flash displayed in this thread. Sad
« Last Edit: November 11, 2008, 02:16:25 PM by shaktool » Logged
Gnarf
Guest
« Reply #25 on: November 11, 2008, 02:28:00 PM »

There is nothing special about animating alpha that makes it slow. Animating alpha just means that you're constantly redrawing the sprite, which you'd be likely be doing anyway.

It's using alpha that is slow compared to like, not. Animating something in Flash generally means that you're redrawing it more often (rather than just reusing that already drawn part of the previous frame). Last time I checked it wasn't awfully clever about figuring out what parts of the screen needs to be redrawn though. Taking a union of all dirty rectangles (meaning that the entire screen is redrawn if there's one moving object in the upper left corner and one in the lower right). So that might be a bit hit and miss.

That might all have changed since I last looked into those kinds of things though. It's been a while.
Logged
Cagey
Level 1
*



View Profile WWW
« Reply #26 on: November 11, 2008, 02:36:16 PM »

I'm annoyed at the misconceptions about Flash displayed everywhere. Sad

Sad

For an interpretted language, AS3 is reasonably fast. While it would never be anywhere near as fast as raw C + SDL/OpenGL, the development time is generally massively lower.

Just to clear some things up:
- Every display object has an alpha property. You can set it to any value in between 0 and 1. The CPU usage of this would be the equivalent of moving it 1 pixel (roughly) so it definitely isn't particularly slow. (...Or what Gnarf said)
- Flash has a variety of blending modes. See here.
- Flash player 10 does support hardware acceleration. I'm not certain how much faster this mode would be, but from the sound of it, it isn't amazing.

While Flash/AS3 isn't perfect my opinion is that it's a very nice platform for quickly and easily producing nice looking games that take minimal time to get running on a player's computer.
« Last Edit: November 11, 2008, 02:45:53 PM by Cagey » Logged

Problem Machine
Level 8
***

It's Not a Disaster


View Profile WWW
« Reply #27 on: November 11, 2008, 02:41:16 PM »

Quote
- Every display object has an alpha property. You can set it to any value in between 0 and 1. The CPU usuage of this would be the equivalent of moving it 1 pixel (roughly) so it definitely isn't particularly slow. (...Or what Gnarf said)
Changing alpha isn't slow, but using alpha values between 0 and 1 is DRASTICALLY slower than using either of them. At one point, I had a semi-transparent mini-map in a game, and it completely wrecked the frame-rate. Now, admittedly, there were some other very unoptimized bits that were probably bogging crap down as well, but I've read in several books(and IRC an SDL tutorial talking about software rendering of alpha values) that alpha values are slow. I tend to believe it.
Logged

John Nesky
Level 10
*****


aka shaktool


View Profile WWW
« Reply #28 on: November 11, 2008, 03:18:31 PM »

I'd like to see a demonstration of this frame-rate wrecking mini-map. It is important to me that my Flash graphics pipeline is optimized, so if there's something I'm misunderstanding about how Flash renders with alpha, I'd like to know about it.

It occurs to me that there is one situation I know of in which Flash might render something faster with alpha disabled: Copying from one pixel buffer to another with pixel snapping activated, meaning it's just directly copying pixels.

EDIT: Never mind, you're right, using alpha on solid or gradient filled vector graphics is slower. But that's only a problem if you're animating complex vector graphics without caching stuff to bitmaps, and if you're doing that you're already flirting with frame rate problems.

Basically, Flash gives you the ability to do stuff that is computationally expensive. If you want. And it's really useful, but too many people abuse it by doing it constantly without realizing it.  Huh?
« Last Edit: November 11, 2008, 03:41:02 PM by shaktool » Logged
Problem Machine
Level 8
***

It's Not a Disaster


View Profile WWW
« Reply #29 on: November 11, 2008, 03:40:53 PM »

I'll put one together later, though I think that what you're saying is pretty close; I do know that rotating sprites tends to have much the same effect, but I don't think Flash's standard sub-pixel movement stuff does. I don't know, I freely admit not being an expert in the nuts and bolts of it, but I do seem to notice substantial slowdown whenever I see a sprite with in-between alpha values.
Logged

John Nesky
Level 10
*****


aka shaktool


View Profile WWW
« Reply #30 on: November 11, 2008, 03:41:56 PM »

No, it's cool, I just tried it now, see my edit.
Logged
Problem Machine
Level 8
***

It's Not a Disaster


View Profile WWW
« Reply #31 on: November 11, 2008, 03:53:49 PM »

Quote
And it's really useful, but too many people abuse it by doing it constantly without realizing it.
You seem to know your stuff, what would you say the most common such mistakes are?  Grin
Logged

BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #32 on: November 11, 2008, 03:54:28 PM »

Flash's renderer is pretty slow. (but it is a lot better now, e.g. dirty rects are smarter)

It's slow because it's a vector renderer. It's designed for smooth anti-aliased things, that are rotated to arbitrary angles and scales. There's a lot less you can pipeline for that. When people put it to use for aligned, pixel locked bitmaps, it's slower than other software renders because it is not making those assumptions. As soon as you mark up your bitmap sprites as such, or use the blitting command (Draw, iirc), it becomes way better. There is a certain amount of control the user gets, to compromise between fast bitmaps and slow vectors (e.g. cacheAsBitmap), but this control does mean it is possible to get it wrong, and have the worst of both worlds.

No, it doesn't do much (any?) hardware acceleration. But it is constantly evolving as a platform, so please stop with the "last I heard" jazz. Even this post is out of date, as I know little about version 10. But at least in the recent years it has started resembling more and more a "serious" tool, from changing the language to something more regular, to providing raster operations. I imagine as the raster aspect comes through more and more, the amount of hardware acceleration will improve too. cf Pixel Bender (which is multi-core rather than GPU, but hey)
« Last Edit: November 11, 2008, 04:04:37 PM by BorisTheBrave » Logged
John Nesky
Level 10
*****


aka shaktool


View Profile WWW
« Reply #33 on: November 11, 2008, 04:14:02 PM »

what would you say the most common such mistakes are?  Grin

Not understanding the difference between rendering vector graphics and rendering bitmaps. Check this out:
http://blog.touchmypixel.com/archives/5

EDIT: Also, not understanding how redraw regions work, and that EVERYTHING inside a redraw region has to be re-rendered, even if it's not actually the part that's animated. So make sure that the stuff inside your redraw regions can be rendered quickly. If you have the debug Flash player installed in your browser you can usually see the redraw regions in a game from the right click menu.
« Last Edit: November 11, 2008, 04:30:28 PM by shaktool » Logged
Gnarf
Guest
« Reply #34 on: November 11, 2008, 04:40:49 PM »

EVERYTHING inside a redraw region has to be re-rendered, even if it's not actually the part that's animated.

(but it is a lot better now, e.g. dirty rects are smarter)

So people who have been using Flash like all recently and stuff, what is the status on that? I tried googling (a little bit) for it before my last post, but didn't come across anything that sounded way different from what it was like years ago...
Logged
John Nesky
Level 10
*****


aka shaktool


View Profile WWW
« Reply #35 on: November 11, 2008, 05:02:12 PM »

Whenever something about a display object -- one that is added to the stage -- changes, its bounding rectangle becomes dirty, and that display object and everything overlapping it inside the dirty rect has to be re-rendered. (For some reason, this includes display objects that are marked with "invisible = false", so if you want something to be invisible, remove it from the stage.) This happens with changes to properties like position, orientation, scale, etc. Sometimes you can avoid unnecessary dirty rectangles with a conditional like:
Code:
if (Math.abs(sprite.x - destinationX) > 0.1 ) sprite.x = destinationX;
This will not change the position of a sprite if changing the position would barely have any effect, and thus save the effort of rendering it and everything overlapping it.

Sometimes nearby dirty rects get combined, resulting in larger redraw regions but fewer redundant preparational calculations. I'm assuming BorisTheBrave was referring to improvements here.
Logged
Gnarf
Guest
« Reply #36 on: November 11, 2008, 05:19:47 PM »

Ah, okay. The way it used to be, all dirty rectangles would be combined, nearby or not. Not (necessarily) doing that any longer would be better muchly.
Logged
Aik
Level 6
*


View Profile
« Reply #37 on: November 11, 2008, 06:34:50 PM »

Quote
Hahaha, no. Go and see how many tutorials there are for AS2 and then check how relatively little there are for AS3. But Box2D and APE (physics engines) are for AS3, plus AS3 is more efficient and organized, so I think that AS3 is better if you're planning on using efficient rigid body physics, graphical effects or big projects in general.

If you're googling for help on some problem/weird quirk with AS2, you're far more likely to pull up people getting answers for the same problem with AS3. Well, that's what I found with my latest foray into AS2, anyway. Most people and communities seem to have moved on from AS2 to AS3, and given the scarcity of results for a lot of the things I was looking for, I imagine a lot of the information has disappeared from the internet altogether.
Logged
isaac
Level 2
**



View Profile WWW
« Reply #38 on: November 11, 2008, 08:16:29 PM »

Yeh, I think that as Actionscript has matured as a language, there are a lot more classes that you can use, and places you can go for help with AS3 than AS2.

There's still more tutorials for AS2, but they're mostly terrible with bad practices and slow code. We're a few years out on AS3 now, and there's plenty of decent resources for it.
Logged

agj
Level 10
*****



View Profile WWW
« Reply #39 on: November 11, 2008, 10:17:44 PM »

If you have the debug Flash player installed in your browser you can usually see the redraw regions in a game from the right click menu.

Useful! Thanks.
Logged

Pages: 1 [2] 3
Print
Jump to:  

Theme orange-lt created by panic