{"id":164,"date":"2009-09-24T18:04:07","date_gmt":"2009-09-24T16:04:07","guid":{"rendered":"http:\/\/blog.ansuz.nl\/?p=164"},"modified":"2009-09-24T18:10:58","modified_gmt":"2009-09-24T16:10:58","slug":"flash-on-the-beach-09-play-with-vectors","status":"publish","type":"post","link":"http:\/\/blog.ansuz.nl\/index.php\/2009\/09\/24\/flash-on-the-beach-09-play-with-vectors\/","title":{"rendered":"Flash on the Beach 09 &#8211; Play with Vectors"},"content":{"rendered":"<p>This year I was only able to go to Flash on the Beach on the very last day. Never the less it was once again a really awesome experience and I learned a lot and got a lot of inspiration as well. I&#8217;ll try and post my notes from all the talks I&#8217;ve seen, but it might take a while&#8230;<\/p>\n<p><strong>23-09-2009 9.00 Koen de Wieggheleire &#8211; Play with Vectors<\/strong><br \/>\nKoen did a very in depth talk about the Vector class in AS3.<\/p>\n<p>The Vector class is a dence array which means that it can&#8217;t have any gaps, so something like the below would throw an error:<\/p>\n<div id=\"ig-sh-1\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">ActionScript<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"actionscript\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">myVector<span style=\"color: #66cc66\">&#091;<\/span><span style=\"color: #cc66cc\">0<\/span><span style=\"color: #66cc66\">&#093;<\/span> = <span style=\"color: #ff0000\">'bla'<\/span>; <span style=\"color: #808080;font-style: italic\">\/\/ See how we're skipping positions 1 and 2?<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">myVector<span style=\"color: #66cc66\">&#091;<\/span><span style=\"color: #cc66cc\">3<\/span><span style=\"color: #66cc66\">&#093;<\/span> = <span style=\"color: #ff0000\">'something else'<\/span>;<\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>You can you an array as a &#8216;data provider&#8217; to populate a Vector:<\/p>\n<div id=\"ig-sh-2\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">ActionScript<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"actionscript\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">myVector = Vector.<span style=\"color: #66cc66\">&amp;<\/span>lt;String<span style=\"color: #66cc66\">&amp;<\/span>gt;<span style=\"color: #66cc66\">&#040;<\/span>myArray<span style=\"color: #66cc66\">&#041;<\/span>;<\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>Using the Vector class will give you a performance boost of about 40 to 60%.<br \/>\nUnfortunately you can&#8217;t directly bind to a Vector in Flex, you can however write a wrapper class and bind to that. \ud83d\ude09<\/p>\n<p><strong><em>How to use in 3D<\/em><\/strong><\/p>\n<p>The Matrix3D class is somewhat complex to understand, but the image below should clarify it a bit<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" title=\"Matrix3D\" src=\"http:\/\/help.adobe.com\/en_US\/AS3LCR\/Flash_10.0\/images\/Matrix3Delements.jpg\" alt=\"\" width=\"300\" height=\"246\" \/><\/p>\n<p>You can use myDisplayObject.transform.matrix3D to retrieve a DO&#8217;s Matrix3D or assign a new matrix3D to it. There are also build in methods to user rather than creating a new Matrix3D all the time, see <a href=\"http:\/\/help.adobe.com\/en_US\/AS3LCR\/Flash_10.0\/flash\/geom\/Matrix3D.html\" target=\"_blank\">http:\/\/help.adobe.com\/en_US\/AS3LCR\/Flash_10.0\/flash\/geom\/Matrix3D.html<\/a><\/p>\n<p>Nice thing I only found out now about matrixes: You can skew objects with it! Rock on!!! \\m\/<\/p>\n<p><strong><em>How to use with 2D<\/em><\/strong><\/p>\n<p>Pretty much the entire graphics API in Flash relies on Vectors. The drawPath() method below (which is pretty much the core of drawing vector shapes) takes two Vectors (the Vector data type) as arguments.<\/p>\n<div id=\"ig-sh-3\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">ActionScript<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"actionscript\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">graphics.<span style=\"color: #006600\">drawPath<\/span><span style=\"color: #66cc66\">&#040;<\/span>commands, <span style=\"color: #0066CC\">data<\/span><span style=\"color: #66cc66\">&#041;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<ul>\n<li>the <em>commands<\/em> argument is a Vector containing GraphicPathCommands<\/li>\n<li>the <em>data<\/em> argument is a Vector containing x and y pairs that determine the path to draw.<\/li>\n<\/ul>\n<p>The new Illustrator can export to FXG and you can actually import this FXG data on the fly in Flash, parse it and draw the exact same.<\/p>\n<p>Some notes on UVT (texture) mapping:<\/p>\n<ul>\n<li>U matches up with the x location<\/li>\n<li>V matches up with the y location<\/li>\n<li>T determines the focal length<\/li>\n<\/ul>\n<p>The right value for T can be calculated with the following formula: T = focalLength \/ (focalLength + z)<\/p>\n<p>Useful links:<\/p>\n<ul>\n<li>Koen&#8217;s site: <a href=\"www.newmovieclip.com\" target=\"_blank\">www.newmovieclip.com<\/a><\/li>\n<li>The presentation online: <a href=\"http:\/\/newmovieclip.wordpress.com\/2009\/02\/23\/play-with-vectors-in-flash-cs4-presentation-online\/\" target=\"_blank\">http:\/\/newmovieclip.wordpress.com\/2009\/02\/23\/play-with-vectors-in-flash-cs4-presentation-online\/<\/a><\/li>\n<li>Files from the presentation, including FXG parser: <a href=\"https:\/\/share.acrobat.com\/adc\/adc.do?docid=e352dd84-1b09-472b-9ecd-5089c51019dc\" target=\"_blank\">https:\/\/share.acrobat.com\/adc\/adc.do?docid=e352dd84-1b09-472b-9ecd-5089c51019dc<\/a><\/li>\n<\/ul>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>This year I was only able to go to Flash on the Beach on the very last day. Never the less it was once again a really awesome experience and I learned a lot and got a lot of inspiration &hellip; <a href=\"http:\/\/blog.ansuz.nl\/index.php\/2009\/09\/24\/flash-on-the-beach-09-play-with-vectors\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,8,65],"tags":[91,31,28],"class_list":["post-164","post","type-post","status-publish","format-standard","hentry","category-actionscript2","category-actionscript-30","category-flex","tag-91","tag-flash-on-the-beach","tag-fotb"],"_links":{"self":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/164","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/comments?post=164"}],"version-history":[{"count":5,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/164\/revisions"}],"predecessor-version":[{"id":169,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/164\/revisions\/169"}],"wp:attachment":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/media?parent=164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/categories?post=164"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/tags?post=164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}