ActionScript 3 - Objektet der ikke var der, endnu!
torsdag, 29. november 2007Deprecated: 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 klassisk metode i ActionScript 2 når man skulle manipulere med objekter i et movieclip var følgende:
MitMC.gotoAndStop("login");
MitMC.Login_txt.text = "Klik for at logge ind";
Men, forsøger du at gøre det i AS3, så får du en fejl, da Login_txt først eksisterer i kodemæssig forstand når det er blevet renderet, det eksisterer ikke blot fordi du er hoppet hen i en frame hvor du ved at det er.
Ved hjælp af eventen RENDER er der dog en måde at gøre noget tilsvarende på:
MitMC.gotoAndStop("login");
MitMC.addEventListener(Event.RENDER, initiateLogin);
function initiateLogin(e:Event) {
MitMC.Login_txt.text = "Klik for at logge ind";
}
Det kræver lidt mere kode end tidligere, men det fungerer fint.
Hvorvidt det så er bad practice eller ej, det vil jeg lade op til andre om at vurdere, men engang imellem er det jo helt okay at hoppe over hvor gærdet er lavest