dcsimg
A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: R E V E L A T I O N

  1. #1
    madskool.wordpress.com brutfood's Avatar
    Join Date
    Apr 2002
    Posts
    469
    I recently had a revelation about the way flash works - I posted this finding on a more general forum - but no-one answered. So I thought I'd try the more enlightened mac users. Ok, maybe you all know this, and you're gonna say "We knew THAT! - what planet have you been on!".

    Let me explain first the way I had assumed (until now) that flash works:-

    Assumption: Flash need only encode the keyframes. This is more efficient in terms of file size and download time. Tweening is performed by the player at run time. Suppose for example you wish to move an object very slowly - this would require many tweened frames - but that doesn't matter, only the keyframes need be encoded to describe this movement. This is the beauty of SVG. To encode the tweened frames would be inefficient, therefore Macromedia wouldn't do it this way.

    This assumption is wrong!!!

    Flash renders the movie into frames when it creates the .swf. Try a long tween and look at the size report. This is why .swf file sizes have often baffled me. The only possible advantage of the way Macromedia have done things is runtime (browser) computational complexity considerations? Hardly an issue on todays computers?

    Forget about the compress option in Flash MX! Scalable Vector Graphics make it possible to produce miniscule file sizes for animations - using the scheme that I described. Why don't they do this?

    Fortunately, I usually use Actionscript, which I've found can create much smaller files than by timeline techniques - but it shouldn't be this way!

  2. #2
    Senior Member SJT's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    2,563
    How did you find this out?
    Is there a Specification from Macromedia somewhere?

  3. #3
    madskool.wordpress.com brutfood's Avatar
    Join Date
    Apr 2002
    Posts
    469
    I had to create a very simle movie with an object that just rotated slowly. So I just did that using the timeline, two keyframes and lots of tweened frames. I was appauled when this created a file that was about 12K. I changed it to perform the rotation in actionscript, it's size dropped to about 1K. Then I investigated with stuff and looked at the size reports that flash generates.

  4. #4
    Senior Member SJT's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    2,563
    What about making the same animation in SVG format?
    How big is the file size then?
    I can't do this, as i don't have an svg animation editor, unless you can recommend one (not Livemotion, i don't have a few hundred quid spare for this test...).

    The only problem i have with this idea is that it would be insane for Macromedia to prerender swf files, especially on a frame by frame basis.

    ok, just tried two tweens:
    Exactly the same shape (duplicated file) one is 5 frames long, the other 250.

    No change in file size, and the reports for both files indicate that the shape bytes (73 B) and tweened shape bytes (153 B) are the same.

    ???

  5. #5
    madskool.wordpress.com brutfood's Avatar
    Join Date
    Apr 2002
    Posts
    469
    OK, I've just done that test with a ball moving across that screen. The 5 frame tween is 156 bytes. The 250 frame tween is 1190 bytes. (Flash 6 format with compression).

    The size report for the bigger file looks like this:-

    Movie Report
    -------------
    FrameFrame # Frame Bytes Total Bytes Page
    ------------ ----------- ----------- ---------------
    1 119 119 Scene 1
    2 12 131 2
    3 12 143 3
    4 12 155 4
    5 12 167 5
    6 12 179 6

    etc. etc. etc.

    247 12 3071 247
    248 12 3083 248
    249 12 3095 249
    250 12 3107 250

    Page Shape Bytes Text Bytes
    ----------------------- ----------- ----------
    Scene 1 0 0

    Page Symbol Bytes Text Bytes
    ----------------------- ------------ ----------
    Tween 2 0 0
    Tween 1 79 0

    Are we getting different results? - Our flash applications can't be behaving differently?!

    Daniel

  6. #6
    Senior Member SJT's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    2,563
    Test1.swf 4Kb file FlashMX w/Compression:
    20 87 438 20

    Page Shape Bytes Text Bytes
    ----------------------- ----------- ----------
    Scene 1 73 0

    Tweened Shapes: 153 bytes


    Test2.swf 4Kb file FlashMX w/Compression:
    251 87 2517 251

    Page Shape Bytes Text Bytes
    ----------------------- ----------- ----------
    Scene 1 73 0

    Tweened Shapes: 153 bytes

  7. #7
    madskool.wordpress.com brutfood's Avatar
    Join Date
    Apr 2002
    Posts
    469
    Our results look similar - thank goodness for that!

    The third number in the set of four is the number of bytes taken to encode the frames. And it is bigger for the longer tween.

    4K is the size of the file on the macintosh HFS+ filing system, which works with 4K blocks. If you do a get info, the number in parenthesis is the real size of the file, that you will experience when you publish stuff online. (actually, on my mac, sometimes this number doesn't show up - but that's another problem)

  8. #8
    SWiSHer extraordinaire
    Join Date
    Dec 2000
    Location
    Australia
    Posts
    3,900
    Flash Player renders the shapes for each frame .. they are not stored as such in the SWF.

    The shapes are defined once (as vectors). Embedded fonts are also defined as vectors (one vector shape for each glyph used). Device fonts are not defined at all (Flash asks the o/s to draw them). Bitmaps files are defined once (as bitmap fills). Smae for sounds, movie-clips, buttons etc. All are defined once (before use) and then referred to by id number when they are placed in a frame.

    The frames themselves only contain transform (placement) information and any frame actions (as action byte code)

    SWF files do not have motion tweening .. each frame has the required transform for that frame. But it does not containt the shape for that frame.

    For shape tweens, each frame has a value that indicates the ratio between start and end shapes of the tween .. it doesn't keep the individual inbetween shapes in the SWF file .. Flash Player calculates it when rendering each frame.

    You can do 'tweened' movement etc using scripting .. where you can write your own code for calculating positions of objects on each frame. This is even more flexible (but not as simple as) normal motion tweening in Flash.

  9. #9
    madskool.wordpress.com brutfood's Avatar
    Join Date
    Apr 2002
    Posts
    469
    That all makes sense Roger,

    It seems to tally with experiments that I've done to investigate this. I could tell that the contents of symbols weren't being duplicated for each frame - which is just as well!

    But WHY have they made it that each frame contains the transforms for the shapes in that frame? - This is quite an overhead for long tweens. Why doesn't the player work these out on the fly? (by tweening).

    Do you know what the engineering trade-off issue was that compelled Macromedia to do it this way, and sacrifice the smaller file sizes that they could have acheived?

  10. #10
    SWiSHer extraordinaire
    Join Date
    Dec 2000
    Location
    Australia
    Posts
    3,900
    I don't know the reasons.

    I would imagine the decision was make to do motion with separate transforms per frame was to keep SWF as a streaming format .. also because frame do not necessarily execute in sequaence.

    It is posible, one supposed, that MM could have decided to implement a motion tween in a similar way to the way they implement shape tweens .. that is haveing a start and end trnaform and a value on each framethe says how far between start and end one is.

    I imagine the thought behind this is that animation is rarely linear, so they went for the simpler and more general solution or a transform (or partial transform) for each frame of animation.

    And, as said before, a more compact solution is offered via scripting (although this requires much more effort on the authors part then motion tweens, and has at least the limitation that you can only specify overall rotation rather than separate x and y angle transforms for skewing).

  11. #11
    madskool.wordpress.com brutfood's Avatar
    Join Date
    Apr 2002
    Posts
    469

    Sorry, been busy...

    I don't think those are good reasons.

    Interpolation doesn't have to be linear. It is deterministic, hence you can imagine a function where you plug-in parameters such as start position, end position, frame number, ease-in, ease-out etc - and out pops an interpolated position. Even movement along a path can be interpolated, because the path vector is known to the flash player.

    This won't affect streaming (except for speeding-up download). A frame is either real, or interpolated.

    I suspect that the developers of flash just went for a simpler solution. (compromising a bit of efficiency).

    In another lifetime - I used to develop and program DSP (Digital Signal Processing) algorithms. We hand-crafted efficient assember code, and used our enginuity to squeeze the best functionality out of a DSP device. I don't think this approach would be out of place when developing (limited-bandwidth) Internet technologies - but hey, flash is one of the most popular multimedia plug-ins! So technological superiority doesn't really count as much as clever marketing etc. I suppose.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center