Deprecated: Assigning the return value of new by reference is deprecated in /var/www/omflash.dk/public_html/wp-includes/cache.php on line 33

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/omflash.dk/public_html/wp-content/plugins/sem-subscribe-me2/sem-subscribe-me.php on line 511

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method UltimateTagWarriorActions::ultimate_query_vars() should not be called statically in /var/www/omflash.dk/public_html/wp-includes/functions.php on line 1252

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method UltimateTagWarriorActions::ultimate_posts_where() should not be called statically in /var/www/omflash.dk/public_html/wp-includes/functions.php on line 1252

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method UltimateTagWarriorActions::ultimate_posts_join() should not be called statically in /var/www/omflash.dk/public_html/wp-includes/functions.php on line 1252

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method UltimateTagWarriorActions::ultimate_tag_templates() should not be called statically in /var/www/omflash.dk/public_html/wp-includes/functions.php on line 1329
Actionscript 3 performance optimering - omFlash();
Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method UltimateTagWarriorActions::ultimate_add_ajax_javascript() should not be called statically in /var/www/omflash.dk/public_html/wp-includes/functions.php on line 1329

Actionscript 3 performance optimering


Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /var/www/omflash.dk/public_html/wp-includes/functions-formatting.php on line 83

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method UltimateTagWarriorActions::ultimate_the_content_filter() should not be called statically in /var/www/omflash.dk/public_html/wp-includes/functions.php on line 1252

Strict Standards: Non-static method UltimateTagWarriorActions::regExEscape() should not be called statically in /var/www/omflash.dk/public_html/wp-content/plugins/UltimateTagWarrior/ultimate-tag-warrior-actions.php on line 638

Strict Standards: Non-static method UltimateTagWarriorActions::regExEscape() should not be called statically in /var/www/omflash.dk/public_html/wp-content/plugins/UltimateTagWarrior/ultimate-tag-warrior-actions.php on line 638

Strict Standards: Non-static method UltimateTagWarriorActions::regExEscape() should not be called statically in /var/www/omflash.dk/public_html/wp-content/plugins/UltimateTagWarrior/ultimate-tag-warrior-actions.php on line 639

Strict Standards: Non-static method UltimateTagWarriorActions::regExEscape() should not be called statically in /var/www/omflash.dk/public_html/wp-content/plugins/UltimateTagWarrior/ultimate-tag-warrior-actions.php on line 639

Strict Standards: Non-static method UltimateTagWarriorActions::replaceTagWithLink() should not be called statically in /var/www/omflash.dk/public_html/wp-content/plugins/UltimateTagWarrior/ultimate-tag-warrior-actions.php on line 643

En af de mest hardcore Flashkodere Joa Ebart har lavet et lille dokument med alle de tips og tricks til at optimere performance i ActionScript, som han selv er stødt på, og der er absolut et par guldkorn imellem.

De to som gør den allerstørste forskel er:

Genbrug objekter
Langsom:
for (;i<n;i++)
p = new Point(i, i);

Hurtig:
for (;i<n;i++)
{
p.x = i;
p.y = i;
}

Her er det cirka 40 gange hurtigere at genbruge objektet.

Undgå såvidt muligt try and catch
Langsom:
var o: Sprite;
for (;i<n;i++)
{
try
{
o.blendMode = BlendMode.ADD;
}
catch ( error: Error ) {}
}

Hurtig:
var o: Sprite;
for (;i<n;i++)
if ( o != null )
o.blendMode = BlendMode.ADD;

Her er det cirka 1000 gange hurtigere at teste på null.

Disse to og mange flere tips finder du i dette dokument:
ActionScript 3 optimization techniques by Joe Ebert

Og hvis du er i humør til lidt nørdgloser og teknisk snak, så vil jeg anbefale dig at kigge på hans egen blogpost om emnet, hvor særligt kommentarer bliver særdeles nørdede:
ActionScript 3 optimization techniques



Del:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg

2 kommentarer

  1. Martin Pagh Ludvigsen siger: (9. juni 2008 kl. 16:54 )

    Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /var/www/omflash.dk/public_html/wp-includes/functions-formatting.php on line 83

    Må lige knytte en kommentar til din try … catch ting - det er kun i de tilfælde, hvor der rent faktisk bliver smidt en exception, at det går langsomt, dvs hvis din catch-klausul bliver aktiveret. Ellers går det faktisk hurtigere, fordi den ikke skal køre null-testen.

    Ellers et godt tip - det viser nemlig, at try … catch ikke skal bruges til at dække over, at man ikke har styr på sine objekter.

  2. Mads Buch Stage siger: (10. juni 2008 kl. 08:57 )

    Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /var/www/omflash.dk/public_html/wp-includes/functions-formatting.php on line 83

    Hej Martin,

    Tak for kommentarerne!

    Har ikke selv kørt nogen test på det, bare vidererapporteret det som Joe Ebert har berettet, men det lyder logisk nok at det du siger passer, så tak for tippet :-)

    /Mads

Skriv en kommentar