<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-7836560</id><updated>2008-06-10T13:12:49.455-04:00</updated><title type='text'>Everything you wanted to know about flash...</title><link rel='alternate' type='text/html' href='http://www.johnnystorm.com/flash/blog.php'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.johnnystorm.com/flash/johnnystorm.xml'/><author><name>Johnny Storm</name><uri>http://www.blogger.com/profile/09388240165336990332</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>14</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7836560.post-112835048549552083</id><published>2005-10-03T10:17:00.000-04:00</published><updated>2005-10-03T10:49:05.136-04:00</updated><title type='text'>Optimization tips.</title><content type='html'>Wow, have I been busy as of late. In hopes of maintaining food entering my body and a roof over my head I've been working like a dog as of late. Top that with Flash 8 coming out and I have been a busy boy.&lt;br /&gt;&lt;br /&gt;Don't believe me?&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.mishkanyc.com"&gt;Mishka NYC&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.selfmadetv.com"&gt;Self Made TV&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Ok, two sites for all this time of absence? I know it doesn't look like a lot, unfortunately, most of my recent work has been cleaning up after people's rather creative Flash skills. As a result I wanted to address some things that you can do to optimize your own work, this way I won't get a call to clean it up =) (wow that was really mean an cocky).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;OK optimization:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;1. Try to avoid using JPEGs. Its been my experience that JPEGs bloat file sizes. I am uncertain as to what is actually going on, if there is some sort of bug going on with the internal Flash compression battling the JPEG compression for dominance which results in bloated file sizes. Also to make your life easier its better to have a non-compressed file in the Flash movie, so you can adjust the compression across the file as opposed to on an individual basis.&lt;br /&gt;&lt;br /&gt;Use PNG files, you'll see a difference. If you don't believe me, experiment for yourself, create two identical Flash files one with a JPEG and one with a PNG and play around with it.&lt;br /&gt;&lt;br /&gt;My preference is for PNG files, and I've noticed a considerable size difference, but don't just trust me, see for yourself.&lt;br /&gt;&lt;br /&gt;2. Crop and resize bitmap images to the exact size you need. Bitmap files bloat file sizes, the bigger the image, the bigger the file, so if you import a file and then reduce it 50% you still have the file weight if it was at 100%. Also file appearance degrades if you blow up or reduce files. Its best to have them at 100% and cropped. Try to avoid cropping images with masks.&lt;br /&gt;&lt;br /&gt;3. Try to use a top left align for your symbols. Believe me, as someone who will have to clean up after you =) its easier for me if you use a top left registration. This will help you in the future when you begin scripting more, its easier to calculate the movieclips position if its registration is at 0,0. It'll take some getting used to but believe me you will appreciate it in the future.&lt;br /&gt;&lt;br /&gt;4. Don't use graphic symbols. Graphic symbols have only one purpose I can see, and that is for doing synched animations. If you have a one frame symbol, make it a movieclip. It would also help to get in the habit of giving your movieclip instance names as well, this is more for scripting, since you can control any movieclip that has an instance name. &lt;br /&gt;&lt;br /&gt;Graphic symbols are best used when you are hoping to synch audio with visual, for lip synching, or other time oriented animations. You can put all of your animation into a graphic symbol then put that symbol on the stage set to play once in the symbols property window.&lt;br /&gt;&lt;br /&gt;5. Try to avoid embedding large audio files. Flash has pretty much mastered loading external MP3 files, take advantage of that. MP3 files can stream on loading, so you won't loose much by loading it as an mp3 file and you will keep the file size down. Loading mp3 files are actually pretty easy, reference the Sound object in the Flash help files.&lt;br /&gt;&lt;br /&gt;6. Keep the actions on one layer and at the top. I'm an old school Director programmer, Director has its script channel at the top, it means all the code is in the exact same place all the time. Flash isn't the same.&lt;br /&gt;&lt;br /&gt;Because you can put code on any layer, any frame, finding all the code sometimes can be frustrating. Its best to move it all to the top in a layer labeled "Actions" this way not only can you find it, but others will be able to locate it as well.&lt;br /&gt;&lt;br /&gt;7. NEVER use gotoAndPlay() to go to a frame number, always give it a frame label. Frame numbers can change when you add or delete frames, once that happens all your code is useless, using frame labels allows you to add and delete frames without having to worry about any code that specifies a specific frame.&lt;br /&gt;&lt;br /&gt;To be continued...&lt;div class="blogger-post-footer"&gt;Copyright © 2005 JohnnyStorm.com&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.johnnystorm.com/flash/2005/10/optimization-tips.php' title='Optimization tips.'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7836560&amp;postID=112835048549552083&amp;isPopup=true' title='2 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.johnnystorm.com/flash/johnnystorm.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/112835048549552083'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/112835048549552083'/><author><name>Johnny Storm</name><uri>http://www.blogger.com/profile/09388240165336990332</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-7836560.post-112015763469886273</id><published>2005-06-30T14:37:00.000-04:00</published><updated>2005-07-01T10:25:09.616-04:00</updated><title type='text'>What good is reusable code... if you type it in every time.</title><content type='html'>And what good is a blog if you never update it?&lt;br /&gt;&lt;br /&gt;Saying that I've been busy is an understatement, its like saying el nino was a breeze. Recently I've done several websites:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.gossipgirl.net/" target="_blank"&gt;Gossip Girl&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.jimkrueger.com" target="_blank"&gt;JimKrueger.com&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Plus a photo booth kiosk done in Macromedia Director, I love director, its what Flash should be.&lt;br /&gt;&lt;br /&gt;Plus various other projects still in the works.&lt;br /&gt;&lt;br /&gt;But through out all of this, I've found myself using the same scripts over and over, so I thought I would post those scripts here, mainly for my own purposes, so I can easily cut and paste them (I end up referencing my site quite a bit) but also for those of you out there who would like to benefit from them as well.&lt;br /&gt;&lt;br /&gt;&lt;B&gt;XML&lt;/B&gt;&lt;br /&gt;I had put off using XML for a long time, mainly because of html formatting issues, well I managed to over come that. It is possible to use html formatting in XML within flash, you just have to use &amp;amp;lt; and &amp;amp;gt; instead of &lt; and &gt; so bold would be &amp;amp;lt;B&amp;amp;gt;. Once I figured out that I love XML, it makes formatting the data so easy. And processing XML in flash is really simple, here is a script I use over and over:&lt;br /&gt;&lt;br /&gt;&lt;div class="codex"&gt;&lt;pre&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;function&lt;/span&gt; myLoad&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;success&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #b1b100;"&gt;if&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;success&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;  myarray = &lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; &lt;span style="color: #0066CC;"&gt;Array&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt;  &lt;span style="color: #b1b100;"&gt;for&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;var&lt;/span&gt; aNode = &lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;.&lt;span style="color: #006600;"&gt;firstChild&lt;/span&gt;; aNode != &lt;span style="color: #000000; font-weight: bold;"&gt;null&lt;/span&gt;; aNode=aNode.&lt;span style="color: #006600;"&gt;nextSibling&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;   myarray.&lt;span style="color: #006600;"&gt;push&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt;   &lt;span style="color: #000000; font-weight: bold;"&gt;var&lt;/span&gt; i:&lt;span style="color: #0066CC;"&gt;Number&lt;/span&gt; = myarray.&lt;span style="color: #006600;"&gt;length&lt;/span&gt;-&lt;span style="color: #cc66cc;"&gt;1&lt;/span&gt;;&lt;br /&gt;   &lt;span style="color: #b1b100;"&gt;for&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;var&lt;/span&gt; &lt;span style="color: #0066CC;"&gt;name&lt;/span&gt; &lt;span style="color: #b1b100;"&gt;in&lt;/span&gt; aNode.&lt;span style="color: #006600;"&gt;attributes&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: #808080; font-style: italic;"&gt;//trace(name +":"+ aNode.attributes[name]);&lt;/span&gt;&lt;br /&gt;    myarray&lt;span style="color: #66cc66;"&gt;[&lt;/span&gt;i&lt;span style="color: #66cc66;"&gt;]&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;[&lt;/span&gt;&lt;span style="color: #0066CC;"&gt;name&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;]&lt;/span&gt; = aNode.&lt;span style="color: #006600;"&gt;attributes&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;[&lt;/span&gt;&lt;span style="color: #0066CC;"&gt;name&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;]&lt;/span&gt;;&lt;br /&gt;   &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt; &lt;span style="color: #b1b100;"&gt;else&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;trace&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"failed"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;var&lt;/span&gt; thisXML:&lt;span style="color: #0066CC;"&gt;XML&lt;/span&gt; = &lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; &lt;span style="color: #0066CC;"&gt;XML&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt;thisXML.&lt;span style="color: #006600;"&gt;onLoad&lt;/span&gt; = myLoad;&lt;br /&gt;&lt;span style="color: #0066CC;"&gt;XML&lt;/span&gt;.&lt;span style="color: #006600;"&gt;prototype&lt;/span&gt;.&lt;span style="color: #006600;"&gt;ignoreWhite&lt;/span&gt; = &lt;span style="color: #000000; font-weight: bold;"&gt;true&lt;/span&gt;;&lt;br /&gt;thisXML.&lt;span style="color: #006600;"&gt;load&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"filename.xml"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #0066CC;"&gt;MovieClip&lt;/span&gt;.&lt;span style="color: #006600;"&gt;prototype&lt;/span&gt;.&lt;span style="color: #006600;"&gt;clearActions&lt;/span&gt; = &lt;span style="color: #000000; font-weight: bold;"&gt;function&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #b1b100;"&gt;for&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #0066CC;"&gt;name&lt;/span&gt; &lt;span style="color: #b1b100;"&gt;in&lt;/span&gt; &lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #b1b100;"&gt;if&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #0066CC;"&gt;typeof&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;[&lt;/span&gt;&lt;span style="color: #0066CC;"&gt;name&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;]&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; == &lt;span style="color: #ff0000;"&gt;"function"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: #0066CC;"&gt;delete&lt;/span&gt; &lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;[&lt;/span&gt;&lt;span style="color: #0066CC;"&gt;name&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;]&lt;/span&gt;;&lt;br /&gt;  &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;This script will load an XML file and dump all of the xml attributes into an array. The format of the XML file is like so:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;?xml version="1.0" encoding="ISO-8859-1"?&amp;gt;&lt;br /&gt;&amp;lt;entry title="Star Wars" url="http://www.starwars.com" /&amp;gt;&lt;br /&gt;&amp;lt;entry title="Star Trek" url="http://www.startrek.com" /&amp;gt;&lt;br /&gt;&amp;lt;entry title="Stargate SG1" url="http://www.stargatesg1.com" /&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;When all is said and done you will end up with an associative array with attributes of title and url, you can access this data by using myarray[0].title.&lt;br /&gt;&lt;br /&gt;Another script I use quite a bit is a script that generates buttons for me. Now this script can be used to create the buttons, or to simply activate them. The script creates a "hit area" for the button, so you could just put a list of movie clips with text fields in them, then the script with create the hit area for you so you don't have to.&lt;br /&gt;&lt;br /&gt;The key aspect is the myColor part, I use getTransform to get the normal state of the background, so I can revert to it. This is helpful so that if you were to change the background color you wouldn't have to change the code:&lt;br /&gt;&lt;br /&gt;&lt;div class='codex'&gt;&lt;pre&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;var&lt;/span&gt; btns:&lt;span style="color: #0066CC;"&gt;Array&lt;/span&gt; = &lt;span style="color: #66cc66;"&gt;[&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"Home"&lt;/span&gt;, &lt;span style="color: #ff0000;"&gt;"Contact"&lt;/span&gt;, &lt;span style="color: #ff0000;"&gt;"Portfolio"&lt;/span&gt;, &lt;span style="color: #ff0000;"&gt;"Links"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;]&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;var&lt;/span&gt; &lt;span style="color: #0066CC;"&gt;menu&lt;/span&gt;:&lt;span style="color: #0066CC;"&gt;MovieClip&lt;/span&gt; = &lt;span style="color: #0066CC;"&gt;createEmptyMovieClip&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"menu"&lt;/span&gt;, &lt;span style="color: #0066CC;"&gt;getNextHighestDepth&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;var&lt;/span&gt; x:&lt;span style="color: #0066CC;"&gt;Number&lt;/span&gt; = &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;var&lt;/span&gt; y:&lt;span style="color: #0066CC;"&gt;Number&lt;/span&gt; = &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #b1b100;"&gt;for&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;var&lt;/span&gt; i = &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;; i&lt;btns.&lt;span style="color: #006600;"&gt;length&lt;/span&gt;; i++&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;var&lt;/span&gt; mc:&lt;span style="color: #0066CC;"&gt;MovieClip&lt;/span&gt; = &lt;span style="color: #0066CC;"&gt;menu&lt;/span&gt;.&lt;span style="color: #006600;"&gt;createEmptyMovieClip&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"menu"&lt;/span&gt;+i, &lt;span style="color: #0066CC;"&gt;menu&lt;/span&gt;.&lt;span style="color: #006600;"&gt;getNextHighestDepth&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;var&lt;/span&gt; bg:&lt;span style="color: #0066CC;"&gt;MovieClip&lt;/span&gt; = mc.&lt;span style="color: #006600;"&gt;createEmptyMovieClip&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"bg"&lt;/span&gt;, mc.&lt;span style="color: #006600;"&gt;getNextHighestDepth&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt; mc.&lt;span style="color: #006600;"&gt;createTextField&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"title"&lt;/span&gt;, mc.&lt;span style="color: #006600;"&gt;getNextHighestDepth&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;, &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;, &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;, &lt;span style="color: #cc66cc;"&gt;100&lt;/span&gt;, &lt;span style="color: #cc66cc;"&gt;20&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;var&lt;/span&gt; my_fmt:&lt;span style="color: #0066CC;"&gt;TextFormat&lt;/span&gt; = &lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; &lt;span style="color: #0066CC;"&gt;TextFormat&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt; &lt;span style="color: #0066CC;"&gt;with&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;my_fmt&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;font&lt;/span&gt; = &lt;span style="color: #ff0000;"&gt;"Arial"&lt;/span&gt;;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;size&lt;/span&gt; = &lt;span style="color: #cc66cc;"&gt;12&lt;/span&gt;;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;color&lt;/span&gt; = 0xFFFFFF;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;align&lt;/span&gt; = &lt;span style="color: #ff0000;"&gt;"left"&lt;/span&gt;;&lt;br /&gt; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #0066CC;"&gt;with&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;mc.&lt;span style="color: #006600;"&gt;title&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;multiline&lt;/span&gt; = &lt;span style="color: #000000; font-weight: bold;"&gt;false&lt;/span&gt;;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;html&lt;/span&gt; = &lt;span style="color: #000000; font-weight: bold;"&gt;false&lt;/span&gt;;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;embedFonts&lt;/span&gt; = &lt;span style="color: #000000; font-weight: bold;"&gt;false&lt;/span&gt;;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;selectable&lt;/span&gt; = &lt;span style="color: #000000; font-weight: bold;"&gt;false&lt;/span&gt;;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;wordWrap&lt;/span&gt; = &lt;span style="color: #000000; font-weight: bold;"&gt;false&lt;/span&gt;;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;text&lt;/span&gt; = btns&lt;span style="color: #66cc66;"&gt;[&lt;/span&gt;i&lt;span style="color: #66cc66;"&gt;]&lt;/span&gt;;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;autoSize&lt;/span&gt; = &lt;span style="color: #000000; font-weight: bold;"&gt;true&lt;/span&gt;;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;setTextFormat&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;my_fmt&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #0066CC;"&gt;with&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;bg&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #000000; font-weight: bold;"&gt;var&lt;/span&gt; w = mc._width;&lt;br /&gt;  &lt;span style="color: #000000; font-weight: bold;"&gt;var&lt;/span&gt; h = mc._height;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;beginFill&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;0xFF0000, &lt;span style="color: #cc66cc;"&gt;100&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;moveTo&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;, &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;lineTo&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;w, &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;lineTo&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;w, h&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;lineTo&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;, h&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;lineTo&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;, &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;endFill&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;br /&gt; mc.&lt;span style="color: #006600;"&gt;onRollOver&lt;/span&gt; = &lt;span style="color: #000000; font-weight: bold;"&gt;function&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #b1b100;"&gt;if&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;.&lt;span style="color: #006600;"&gt;myColor&lt;/span&gt; == &lt;span style="color: #000000; font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;.&lt;span style="color: #006600;"&gt;myColor&lt;/span&gt; = &lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; &lt;span style="color: #0066CC;"&gt;Color&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;.&lt;span style="color: #006600;"&gt;bg&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt;   &lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;.&lt;span style="color: #006600;"&gt;oldColor&lt;/span&gt; = &lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;.&lt;span style="color: #006600;"&gt;myColor&lt;/span&gt;.&lt;span style="color: #006600;"&gt;getTransform&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt;  &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;.&lt;span style="color: #006600;"&gt;title&lt;/span&gt;.&lt;span style="color: #006600;"&gt;textColor&lt;/span&gt; = 0x00FF00;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;.&lt;span style="color: #006600;"&gt;myColor&lt;/span&gt;.&lt;span style="color: #006600;"&gt;setRGB&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;0x990000&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;;&lt;br /&gt; mc.&lt;span style="color: #006600;"&gt;onRollOut&lt;/span&gt; = &lt;span style="color: #000000; font-weight: bold;"&gt;function&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;.&lt;span style="color: #006600;"&gt;title&lt;/span&gt;.&lt;span style="color: #006600;"&gt;textColor&lt;/span&gt; = 0xFFFFFF;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;.&lt;span style="color: #006600;"&gt;myColor&lt;/span&gt;.&lt;span style="color: #006600;"&gt;setTransform&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;.&lt;span style="color: #006600;"&gt;oldColor&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;;&lt;br /&gt; mc.&lt;span style="color: #006600;"&gt;onRelease&lt;/span&gt; = &lt;span style="color: #000000; font-weight: bold;"&gt;function&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #0066CC;"&gt;trace&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;._name&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;;&lt;br /&gt; mc._x = x;&lt;br /&gt; mc._y = y;&lt;br /&gt; &lt;span style="color: #808080; font-style: italic;"&gt;//y+=mc._height;&lt;/span&gt;&lt;br /&gt; x += mc._width;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;I'm not done with this entry yet :) I just have a lot of work to do...&lt;div class="blogger-post-footer"&gt;Copyright © 2005 JohnnyStorm.com&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.johnnystorm.com/flash/2005/06/what-good-is-reusable-code-if-you-type.php' title='What good is reusable code... if you type it in every time.'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7836560&amp;postID=112015763469886273&amp;isPopup=true' title='1 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.johnnystorm.com/flash/johnnystorm.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/112015763469886273'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/112015763469886273'/><author><name>Johnny Storm</name><uri>http://www.blogger.com/profile/09388240165336990332</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-7836560.post-111574476541519276</id><published>2005-05-10T13:02:00.000-04:00</published><updated>2005-05-10T13:06:05.426-04:00</updated><title type='text'>The sorting hat... uh... flash</title><content type='html'>I had been looking for a way to sort depths based on scale, the smaller mcs being moved to the back and the larger ones moved to the front. I looked and looked and couldn't find anything but I was able to write this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;.&lt;span style="color: #006600;"&gt;onEnterFrame&lt;/span&gt; = &lt;span style="color: #000000; font-weight: bold;"&gt;function&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;var&lt;/span&gt; temp:&lt;span style="color: #0066CC;"&gt;Array&lt;/span&gt; = &lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; &lt;span style="color: #0066CC;"&gt;Array&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt; &lt;span style="color: #b1b100;"&gt;for&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;var&lt;/span&gt; &lt;span style="color: #0066CC;"&gt;name&lt;/span&gt; &lt;span style="color: #b1b100;"&gt;in&lt;/span&gt; &lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #b1b100;"&gt;if&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #0066CC;"&gt;typeof&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;[&lt;/span&gt;&lt;span style="color: #0066CC;"&gt;name&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;]&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; == &lt;span style="color: #ff0000;"&gt;"movieclip"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;   temp.&lt;span style="color: #006600;"&gt;push&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;mc:&lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;[&lt;/span&gt;&lt;span style="color: #0066CC;"&gt;name&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;]&lt;/span&gt;, scale:&lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;[&lt;/span&gt;&lt;span style="color: #0066CC;"&gt;name&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;]&lt;/span&gt;._yscale&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt;  &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;br /&gt; temp.&lt;span style="color: #006600;"&gt;sortOn&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;"scale"&lt;/span&gt;, &lt;span style="color: #cc66cc;"&gt;16&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt; &lt;span style="color: #0066CC;"&gt;trace&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;temp.&lt;span style="color: #006600;"&gt;length&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt; &lt;span style="color: #b1b100;"&gt;for&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;var&lt;/span&gt; i = &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;; i &lt; temp.&lt;span style="color: #006600;"&gt;length&lt;/span&gt;; i++&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: #000000; font-weight: bold;"&gt;var&lt;/span&gt; mc:&lt;span style="color: #0066CC;"&gt;MovieClip&lt;/span&gt; = temp&lt;span style="color: #66cc66;"&gt;[&lt;/span&gt;i&lt;span style="color: #66cc66;"&gt;]&lt;/span&gt;.&lt;span style="color: #006600;"&gt;mc&lt;/span&gt;;&lt;br /&gt;  mc.&lt;span style="color: #006600;"&gt;swapDepths&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #0066CC;"&gt;this&lt;/span&gt;.&lt;span style="color: #006600;"&gt;getNextHighestDepth&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt; &lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #0066CC;"&gt;updateAfterEvent&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now it is a little buggy, when mcs overlap and they are the same percentage, the "blink" but its enough to get you started if you were looking for something similar :)&lt;div class="blogger-post-footer"&gt;Copyright © 2005 JohnnyStorm.com&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.johnnystorm.com/flash/2005/05/sorting-hat-uh-flash.php' title='The sorting hat... uh... flash'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7836560&amp;postID=111574476541519276&amp;isPopup=true' title='1 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.johnnystorm.com/flash/johnnystorm.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/111574476541519276'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/111574476541519276'/><author><name>Johnny Storm</name><uri>http://www.blogger.com/profile/09388240165336990332</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-7836560.post-111383318600278136</id><published>2005-04-18T10:04:00.000-04:00</published><updated>2005-04-18T10:06:26.003-04:00</updated><title type='text'>Adobe Acquires Macromedia</title><content type='html'>&lt;a href="http://www.adobe.com/aboutadobe/invrelations/adobeandmacromedia.html" target="_blank"&gt;Adobe Acquires Macromedia&lt;/A&gt; not sure how I feel about this... it could be a good thing or it could pretty much ruin my career...&lt;div class="blogger-post-footer"&gt;Copyright © 2005 JohnnyStorm.com&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.johnnystorm.com/flash/2005/04/adobe-acquires-macromedia.php' title='Adobe Acquires Macromedia'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7836560&amp;postID=111383318600278136&amp;isPopup=true' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.johnnystorm.com/flash/johnnystorm.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/111383318600278136'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/111383318600278136'/><author><name>Johnny Storm</name><uri>http://www.blogger.com/profile/09388240165336990332</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-7836560.post-110948580221308974</id><published>2005-02-27T01:12:00.000-05:00</published><updated>2005-02-27T01:30:02.216-05:00</updated><title type='text'>Action Script 2.0 in the hizzie!</title><content type='html'>&lt;A href="http://www.amazon.com/exec/obidos/ASIN/0596006527/johnnystormco-20" target="_blank"&gt;&lt;IMG src="http://images.amazon.com/images/P/0596006527.01._PE34_SCMZZZZZZZ_.jpg" width="117" height="154" border="0" alt="cover" hspace="3" vspace="3" align="left"&gt;&lt;/A&gt;&lt;br /&gt;Ok, so I'm white, aside from that I decided to look into Flash's Action Script 2.0. I had been putting it off for 2 very good reasons:&lt;br /&gt;&lt;br /&gt;1. Most of my clients weren't familiar with AS 2.0.&lt;br /&gt;2. I prefered the prototype method over classes.&lt;br /&gt;&lt;br /&gt;But I had been getting freelance requests involving AS 2.0 so I figured it was time to venture into it. I had picked up a book: &lt;A href="http://www.amazon.com/exec/obidos/ASIN/0596006527/johnnystormco-20" target="_blank"&gt;Essential ActionScript 2.0&lt;/A&gt; by Colin Moock as a primer, but I have to admit, the book was a bit confusing. Don't let me stop you from buying it, I've heard its the industry standard, I'm just not a fan.&lt;br /&gt;&lt;br /&gt;Anyways, I plowed into AS 2.0 with hesitation, but I have to admit, I am enjoying it so far. In the near future I will write some simple classes for you, my eager viewer, to use as a primer into how to use AS 2.0.&lt;br /&gt;&lt;br /&gt;In the meantime, my first attempt at writing a class has yielded my TextScroller Class, its a nifty little code-driven scrollbar for use with text fields. So I spent the weekend working on it, I wrapped it, provided some documentation, and you can download it for free at the link below.&lt;br /&gt;&lt;br /&gt;If you like it, please let me know, also I'd love feedback on how to make improvements. I already have ideas for 2 additional scrollbar scripts.&lt;br /&gt;&lt;br /&gt;Anyways enjoy :)&lt;br /&gt;&lt;br /&gt;-js&lt;br /&gt;&lt;br /&gt;&lt;A href="http://www.johnnystorm.com/flash/downloads/JS_TextScroller.zip"&gt;&lt;IMG src="/flash/images/icon-mxp.gif" width="36" height="47" border="0"&gt; TextScroller Class&lt;/A&gt;&lt;br /&gt;The TextScroller class lets you create a dynamic scrollbar used for scrolling dynamic and input text fields. &lt;br /&gt;You can modify the attributes of the scrollbar for customization.&lt;div class="blogger-post-footer"&gt;Copyright © 2005 JohnnyStorm.com&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.johnnystorm.com/flash/2005/02/action-script-20-in-hizzie.php' title='Action Script 2.0 in the hizzie!'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7836560&amp;postID=110948580221308974&amp;isPopup=true' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.johnnystorm.com/flash/johnnystorm.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/110948580221308974'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/110948580221308974'/><author><name>Johnny Storm</name><uri>http://www.blogger.com/profile/09388240165336990332</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-7836560.post-110737386490441257</id><published>2005-02-02T14:34:00.000-05:00</published><updated>2005-02-02T15:12:00.426-05:00</updated><title type='text'>I seem to remember something about a blog...</title><content type='html'>Ok, so its been SEVERAL months since I last posted, but given my schedule:&lt;br /&gt;&lt;br /&gt;&lt;A href="http://www.santa-kid.com" target="_blank"&gt;James Patterson's Santa Kid&lt;/A&gt; (flash production and programming)&lt;br /&gt;&lt;A href="http://www.datinggamebook.com" target="_blank"&gt;Dating Game&lt;/A&gt; (flash production and programming)&lt;br /&gt;&lt;A href="http://www.comicon.com/cgi-bin/pulse.cgi?http%3A//www.comicon.com/cgi-bin/ultimatebb.cgi%3Fubb%3Dget_topic%26f%3D36%26t%3D003358" target="_blank"&gt;Marvel Comics: Livewires #1&lt;/A&gt; (letterer)&lt;br /&gt;&lt;A href="http://www.fusionpartnersinc.com" target="_blank"&gt;Fusion Partners&lt;/A&gt; (Design, production and programming)&lt;br /&gt;&lt;br /&gt;You can see I was a little busy... but to make up for it I have some great new extensions, which I think you'll like:&lt;br /&gt;&lt;br /&gt;&lt;A href="http://www.johnnystorm.com/flash/downloads/JS_duplicate_layers.zip"&gt;JS Duplicate Layers&lt;/A&gt; &lt;br /&gt;This Extension duplicates the selected layers.&lt;br /&gt;&lt;br /&gt;&lt;A href="http://www.johnnystorm.com/flash/downloads/JS_frame_labels.zip"&gt;JS Frame Label window&lt;/A&gt; &lt;br /&gt;This extension allows you to view all of the frame labels in your flash movie. You can jump to a frame label by clicking once on the name, and edit the frame label by clicking twice.&lt;br /&gt;&lt;br /&gt;And some code, some of its mine and some I found on some other site, which was a nice little piece of code:&lt;br /&gt;&lt;br /&gt;This code allows you to add custom entries to the context menu when you right click on a Flash 7 movie:&lt;br /&gt;&lt;P class="code"&gt;function fbHandler(obj, item) {&lt;br /&gt;&lt;SPAN style="margin:5"&gt;getURL("http://www.johnnystorm.com", "_blank");&lt;/SPAN&gt;&lt;br /&gt;}&lt;br /&gt;var my_cm = new ContextMenu();&lt;br /&gt;fb_cmi = new ContextMenuItem("v0.3 designed by JohnnyStorm.com", fbHandler, true);&lt;br /&gt;my_cm.customItems.push(fb_cmi);&lt;br /&gt;this.menu = my_cm;&lt;br /&gt;Stage.showMenu = true;&lt;br /&gt;my_cm.hideBuiltInItems();&lt;br /&gt;&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;And this is a loader code I created, which I use over and over again, yet always have to search to find, so I am posting it here so I will always have access to it:&lt;br /&gt;&lt;P class="code"&gt;function createLoader() {&lt;br /&gt;&lt;SPAN style="margin:5"&gt;createEmptyMovieClip("loader", 100);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;loader._x = Stage.width/2;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;loader._y = Stage.height/2;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;var w = 200;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;var h = 10;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;var p1 = -(w/2);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;var p2 = -(h/2);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;with (loader) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;moveTo(p1, p2);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;lineStyle(0, 0xFFFFFF);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;lineTo(p1, p2+h);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;lineTo(p1+w, p2+h);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;lineTo(p1+w, p2);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;lineTo(p1, p2);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;loader.createEmptyMovieClip("progress", 5);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;loader._visible = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;var w = 1;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;var h = 6;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;var p1 = -(w/2);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;var p2 = -(h/2);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;with (loader.progress) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;moveTo(p1, p2);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;beginFill(0xFFFFFF);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;lineTo(p1, p2+h);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;lineTo(p1+w, p2+h);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;lineTo(p1+w, p2);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;lineTo(p1, p2);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;endFill();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;loader.onEnterFrame = function() {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;Y = getBytesLoaded();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;C = getBytesTotal();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;X = int((Y*100)/C);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;this.progress._width = X*2;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;//this.progress._x = -(this.progress._width/2);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;if (X&gt;=100) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;delete this.onEnterFrame;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;play();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;this.removeMovieClip();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;} else {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;this._visible = true;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;};&lt;/SPAN&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;And this is a nifty little prototype that removes all actions from a mc:&lt;br /&gt;&lt;P class="code"&gt;MovieClip.prototype.clearActions = function() {&lt;br /&gt;&lt;SPAN style="margin:5"&gt;for (name in this) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;if (typeof (this[name]) == "function") {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;delete this[name];&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;}&lt;/SPAN&gt;&lt;br /&gt;};&lt;br /&gt;&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;Ok that's all for now, I'll be back soon, I promise.&lt;div class="blogger-post-footer"&gt;Copyright © 2005 JohnnyStorm.com&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.johnnystorm.com/flash/2005/02/i-seem-to-remember-something-about.php' title='I seem to remember something about a blog...'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7836560&amp;postID=110737386490441257&amp;isPopup=true' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.johnnystorm.com/flash/johnnystorm.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/110737386490441257'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/110737386490441257'/><author><name>Johnny Storm</name><uri>http://www.blogger.com/profile/09388240165336990332</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-7836560.post-109759904498071883</id><published>2004-10-12T13:35:00.002-04:00</published><updated>2004-10-12T12:40:19.350-04:00</updated><title type='text'>Do androids dream in code?</title><content type='html'>Ok, I realize that its been a while since I last posted, I really don't have a great excuse, just that I've been distracted lately. It is now three weeks till the 2004 election, and I've been focusing some of my energies in getting people to register and to vote. I don't want to start a political debate, so I'll just say, I don't care who you vote for, but please vote.&lt;br /&gt;&lt;br /&gt;Ok, on to the good stuff. A friend of mine asked me about how to integrate Flash, PHP and MySQL, so I thought I would dedicate this posting to that, so that he alone wouldn't benefit from what I am writing.&lt;br /&gt;&lt;br /&gt;For this example you'll need a MySQL database, and an understanding of how to set it up. If you aren't familar with MySQL there are plenty of online resources including &lt;A href="http://dev.mysql.com/"&gt;http://dev.mysql.com/&lt;/A&gt;.&lt;br /&gt;&lt;br /&gt;Since this is a portfolio example the TABLE should be portfolio related, I am including the MySQL structure that I am using:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;#&lt;br /&gt;# Table structure for table 'portfolio'&lt;br /&gt;#&lt;br /&gt;CREATE TABLE portfolio (&lt;br /&gt;  id int(11)  DEFAULT '' NOT NULL auto_increment,&lt;br /&gt;  category varchar(50)    ,&lt;br /&gt;  title varchar(50)  DEFAULT '' NOT NULL ,&lt;br /&gt;  client varchar(50)    ,&lt;br /&gt;  sub_client varchar(75)    ,&lt;br /&gt;  position varchar(50)    ,&lt;br /&gt;  url varchar(200)    ,&lt;br /&gt;  description text    ,&lt;br /&gt;  type varchar(50)    ,&lt;br /&gt;  thumbnail varchar(200)    ,&lt;br /&gt;  date_added date    ,&lt;br /&gt;  active int(11)  DEFAULT '0' NOT NULL ,&lt;br /&gt;  UNIQUE id(id),&lt;br /&gt;  KEY title (title)&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;# ----------- Dump ends -----------&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;So the TABLE structue would have the following fields:&lt;br /&gt;&lt;br /&gt;&lt;B&gt;id&lt;/B&gt; this is a unique identifier which ensures there are no duplicate entry errors.&lt;br /&gt;&lt;B&gt;category&lt;/B&gt; this is used to sort the information, for instance (Flash, Graphic Design, HTML).&lt;br /&gt;&lt;B&gt;title&lt;/B&gt; this is the title of the entry ie "My Website".&lt;br /&gt;&lt;B&gt;client&lt;/B&gt; this is the client the work was done for.&lt;br /&gt;&lt;B&gt;sub_client&lt;/B&gt; this is the client's client, I use this because I do a lot of work for studios who do work for other clients.&lt;br /&gt;&lt;B&gt;position&lt;/B&gt; this is is what I did on the project, ie Designer, Programmer, Production.&lt;br /&gt;&lt;B&gt;url&lt;/B&gt; the url of the online example.&lt;br /&gt;&lt;B&gt;description&lt;/B&gt; a description of the entry.&lt;br /&gt;&lt;B&gt;type&lt;/B&gt; the type of the entrie ie: Animation, Graphic Design, Programming.&lt;br /&gt;&lt;B&gt;thumbnail&lt;/B&gt; the filename of the related thumbnail ie: mywebsite.jpg.&lt;br /&gt;&lt;B&gt;date_added&lt;/B&gt; when I added the entry to the portfolio.&lt;br /&gt;&lt;B&gt;active&lt;/B&gt; a true or false value (1 or 0) which indicates wether the entry is active, makes it easier to remove entries without deleting it from the database.&lt;br /&gt;&lt;br /&gt;Now the first part we need is a php script that will pull the contents of the TABLE and present it in a format that Flash can use. This is the script I currently use:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;&amp;lt;? &lt;br /&gt;&lt;SPAN style="margin:5"&gt;/*First we connect to the database, normally have this as a seperate file so that if the information changes I only have to change it in one location*/&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;include ("connect.php");&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;/*Select all active entries from the TABLE where the category = $CAT this allow us to only select on category at a time.*/&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;$sql      = "SELECT * FROM portfolio WHERE category = '$CAT' AND active = 0 ORDER BY $FIELD";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;$result   = @mysql_query( $sql );&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;$num_rows = @mysql_num_rows( $result );&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;$error    = mysql_error();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;/*here we are establishing a counter variable for use in individualizing the entries*/&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;$int = 1;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;/*$num_rows is the number of rows the query returns, if it 0 then no entries were found and so we want the code to stop here*/&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;if($num_rows != 0) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;/*This code will cycle through each entry the query returns*/&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;while($row = mysql_fetch_array($result)) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;$id          = urlencode($row[id]);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;$category    = urlencode($row[category]);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;$title       = urlencode($row[title]);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;$client      = urlencode($row[client]);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;$subclient   = urlencode($row[subclient]);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;$position    = urlencode($row[position]);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;$url         = urlencode($row[url]);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;$description = urlencode($row[description]);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;$thumbnail   = urlencode($row[thumbnail]);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;$output .= "&amp;title$int=$title&amp;\n";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;$output .= "&amp;client$int=$client&amp;\n";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;if (isset($subclient)) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:20"&gt;$output .= "&amp;subclient$int=" . $subclient ."&amp;\n";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;/*Some of the values may be empty in those cases we don't want to return a value.*/&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;if(isset($position)) { $output .= "&amp;position$int=$position&amp;\n"; }&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;$output .= "&amp;url$int=$url&amp;\n";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;if(isset($type)) { $output .= "&amp;type$int=$type&amp;\n"; }&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;if(isset($thumbnail)) { $output .= "&amp;thumbnail$int=$thumbnail&amp;\n"; }&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;$output .= "&amp;description$int=$description&amp;\n";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;$output .= "&amp;date_added$int=$date_added&amp;\n";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15"&gt;$int++;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;echo $output;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;} else {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;/*The var status is used in Flash to determine if an error has occured.*/&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;echo "&amp;status=error&amp;\n";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:10"&gt;exit;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;/*A little trick I picked up, every time you open a MySQL connection it stays open for several hours. The more connections you have the slower MySQL runs, so its best if you close out the connection manually just as an added precaution.*/&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;mysql_free_result($result);&lt;/SPAN&gt;&lt;br /&gt;?&amp;gt;&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;So once this is all done you should get the following output:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;&amp;title1=title&amp;&lt;br /&gt;&amp;client1=client&amp;&lt;br /&gt;&amp;subclient1=subclient&amp;&lt;br /&gt;&amp;position1=position&amp;&lt;br /&gt;&amp;url1=url&amp;&lt;br /&gt;&amp;type1=type&amp;&lt;br /&gt;&amp;description1=description&amp;&lt;br /&gt;&amp;date_added1=0000-00-00&amp;&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;Once this is done you can use one of my previous scripts to process the entries. The best approach would be to dump the date into an associative array, this would allow you to access each entry and its properties easily.&lt;br /&gt;&lt;br /&gt;Ok, give that a shot, I may come back and add the modified AS code, if you have an comments just let me know.&lt;div class="blogger-post-footer"&gt;Copyright © 2005 JohnnyStorm.com&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.johnnystorm.com/flash/2004/10/do-androids-dream-in-code_109759904498071883.php' title='Do androids dream in code?'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7836560&amp;postID=109759904498071883&amp;isPopup=true' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.johnnystorm.com/flash/johnnystorm.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/109759904498071883'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/109759904498071883'/><author><name>Johnny Storm</name><uri>http://www.blogger.com/profile/09388240165336990332</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-7836560.post-109535566998722607</id><published>2004-09-16T13:26:00.000-04:00</published><updated>2004-09-22T18:22:39.576-04:00</updated><title type='text'>Can I instant message a flash movie?!?</title><content type='html'>Ok, I realize there was no post last week, I am sure the three of you reading this on a weekly basis felt I had let you down. Well, let me assure you, there was a good reason, I quit my job. I felt the demands of my life, including this website, necessitated me quitting my job so I could focus on them instead. Ok, I know what you're thinking, you may know Flash, but I wouldn't quit your day job... &lt;br /&gt;&lt;br /&gt;Ok bad puns aside, I am no longer fully employed, but I am taking on projects on a freelance basis, which means I am available for projects, contract work, consultations, and teaching sessions.&lt;br /&gt;&lt;br /&gt;Ok, self-promotion aside, let's get into this week's tutorial:&lt;br /&gt;&lt;br /&gt;&lt;B&gt;Local Connections&lt;/B&gt;&lt;br /&gt;What is a local connection? Well, imagine two Flash movies communicating on a web page without the need of an external scripting language such as javascript. Flash allows you to set up a local connection between multiple flash movies, and guess what, its actually very simple to do.&lt;br /&gt;&lt;br /&gt;Simple you say?!? NOTHING is simple in flash... prepare to be stand corrected, I even have sample files.&lt;br /&gt;&lt;br /&gt;To set up a local connection you have to identify the movie you want to communicate with, and then set up functions to receive and send information between the two movies.&lt;br /&gt;&lt;br /&gt;As you should have noticed, I have two Flash movies that can communicate with each other, one movie acts as the menu, and the other movie acts as the display engine. I intentionally separated the two movies so you can see that they are not one movie.&lt;br /&gt;&lt;br /&gt;So here is the code for part 1 movie:&lt;br /&gt;&lt;br /&gt;&lt;? include $DOCUMENT_ROOT . "/flash/tutorials/part1.htm"; ?&gt;&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;var receiving_lc:LocalConnection = new LocalConnection();&lt;br /&gt;receiving_lc.loadEntry = function(title:String, description:String, thumbnail:String) {&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;theTitle.text = title;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;theTitle.autoSize = true;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;theDescription.text = description;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;thumbnail_mc.loadMovie(thumbnail);&lt;br /&gt;};&lt;br /&gt;receiving_lc.connect("part1");&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;Ok the key point to look here is &lt;I&gt;receiving_lc.connect("part1");&lt;/I&gt; this is where we set up the name of the movie that will receive connections. Think of this as an email address or telephone number. You can't call or email someone without using the number or address. &lt;br /&gt;&lt;br /&gt;And as you can see we have a function called &lt;I&gt;loadEntry&lt;/I&gt; this function is what we will call from our sending movie. As you can see it's set up similarly to how functions normally look.&lt;br /&gt;&lt;br /&gt;Here is the code for part 2:&lt;br /&gt;&lt;br /&gt;&lt;? include $DOCUMENT_ROOT . "/flash/tutorials/local.htm"; ?&gt;&lt;br /&gt;&lt;? include $DOCUMENT_ROOT . "/flash/tutorials/localconnection.php"; ?&gt;&lt;br /&gt;&lt;P class="code"&gt;&lt;SPAN id="code" align="center" style="position:relative;"&gt;&lt;A href="javascript:showCode()"&gt;SHOW CODE&lt;/A&gt;&lt;/SPAN&gt;&lt;br /&gt;function loadEntry(i) {&lt;br /&gt;&lt;SPAN style="margin:5"&gt;trace(vendors[i].title);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;trace(vendors[i].description);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;trace(vendors[i].thumbnail);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;var sending_lc:LocalConnection = new LocalConnection();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;sending_lc.send("part1", "loadEntry", vendors[i].title, vendors[i].description, vendors[i].thumbnail);&lt;/SPAN&gt;&lt;br /&gt;}&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;Ok I realize that is a lot of code, and you may recognize some of it from one of my previous tutorials. To make things easier I'm only going to focus on the part that matters most, and that would be this part:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;function loadEntry(i) {&lt;br /&gt;&lt;SPAN style="margin:5"&gt;trace(vendors[i].title);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;trace(vendors[i].description);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;trace(vendors[i].thumbnail);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;var sending_lc:LocalConnection = new LocalConnection();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:5"&gt;sending_lc.send("part1", "loadEntry", vendors[i].title, vendors[i].description, vendors[i].thumbnail);&lt;/SPAN&gt;&lt;br /&gt;}&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;This function is activated when you click on one of the buttons, I am using a trace function for development testing, since you can only test the local connection via a web browser. As you can see that the actual connection function is quite simple, I am using ActionScript 2.0 syntax here, but you should be able run it in ActionScript 1.0 by removing the &lt;I&gt;:syntax&lt;/I&gt; (sending_lc:LocalConnection).&lt;br /&gt;&lt;br /&gt;Since all of the code is handled inside of flash you do not have to do anything special with the html in order for it to work.&lt;br /&gt;&lt;br /&gt;From my pov this appears to be pretty straight forward, but I will bounce it off some people and make adjustments as necessary. If you have any comments or questions for elaboration please feel free to contact me.&lt;br /&gt;&lt;br /&gt;-js&lt;div class="blogger-post-footer"&gt;Copyright © 2005 JohnnyStorm.com&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.johnnystorm.com/flash/2004/09/can-i-instant-message-flash-movie.php' title='Can I instant message a flash movie?!?'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7836560&amp;postID=109535566998722607&amp;isPopup=true' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.johnnystorm.com/flash/johnnystorm.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/109535566998722607'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/109535566998722607'/><author><name>Johnny Storm</name><uri>http://www.blogger.com/profile/09388240165336990332</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-7836560.post-109415717022359959</id><published>2004-09-02T16:31:00.000-04:00</published><updated>2004-09-04T14:17:46.050-04:00</updated><title type='text'>Move it on over...</title><content type='html'>.So here it is, not Monday, again, and no new post. Originally when I started this I had intended it to be a weekly update. The plan was to have something new to read every Monday morning, cause as I  learned on my state sponsored holiday, little things like website updates mean a lot. Granted, this ain't no Homestarrunner but new content is new content. Unfortunately my schedule as of late has been a bit demanding, so I'm going to aim for Wednesdays, for a while, it also doesn't help that I write most of this on an iPaq. As I've intimated on several occasions, I'm a Mac guy, so getting data off of the iPaq is a pain in the ass.&lt;br /&gt;&lt;br /&gt;&lt;B&gt;SHUT UP ALREADY AND GET TO THE GOOD STUFF!!!&lt;/B&gt; ... is ActionScript really the "good stuff"?&lt;br /&gt;&lt;br /&gt;Ok, one of the key things to remember about coding, is the relationships. As Joshua Davis once said;&lt;/SPAN&gt; If you want a movieclip to move across the screen, the simply find the distance between the two points and divide it in half. Then keep find the distance again, rinse repeat, rinse repeat.&lt;br /&gt;&lt;br /&gt;You get the idea. So basically what he said was to treat every situation with a simple solution, use your brain to find solutions you are comfortable with, instead of ones that will impress your sixth grade math teacher, Mr. Frankenfield. &lt;br /&gt;&lt;br /&gt;So, following that logic, let's make a movieclip movie across the screen.&lt;br /&gt;&lt;br /&gt;Create a movieclip, a box, a square, a picture of Sponge Bob Square-pants, whatever. Give the mc an instance name of "mc1" and apply the following code to the mc, not the frame.&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;onClipEvent(load) {&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;this.starty = this._y;&lt;/SPAN&gt;&lt;br /&gt;}&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;Now I try to stay away from using mc code, instead use the onEnterFrame, style instead, but I've had the best luck with this, so why not go with what works. You may also notice I like to use more descriptive names for my variables, this helps to remember what each variable is for especially since I am bad at commenting my code.&lt;br /&gt;&lt;br /&gt;So now in the frame script add this:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;mc1.onEnterFrame = function() {&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;this.stopy = this.starty+200;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;this._x -= (this._x-this.stopy)/3;&lt;/SPAN&gt;&lt;br /&gt;};&lt;/SPAN&gt;&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;Ok, this is the ULTRA basic code. If you test your movie you'll see it move across the screen. As you can see all I am doing is finding the difference, and dividing it into thirds. The reason why I'm doing that is to give it an "eased" effect.&lt;br /&gt;&lt;br /&gt;So that's great, you can move stuff around. You can even have the movement happen on a mouse click but let's go one step further. Let's say you want to have something happen once you get from point a to b? You may want to have the clip fade out or maybe movie in another direction, regardless of what you want to have happen when it reaches that point first you need to determine if that point has been reached.&lt;br /&gt;&lt;br /&gt;Now I know what you're thinking, why not just test to see if the position has been reached? Test to see if it's greater, lesser, or equal to the new point? Well, since we are dividing the value by 3, we will never get a true value. To test this trace the _x value and you'll see what I mean.&lt;br /&gt;&lt;br /&gt;So instead let's look for a value we can test for, in our case we can test the difference. Please modify the script as follows:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;mc1.onEnterFrame = function() {&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;this.stopy = this.starty+200;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;this.diff = (this._x-this.stopy)/3;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;this._x -= this.diff;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;if (Math.floor(Math.abs(this.diff)) == 0) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:30px"&gt;trace("delete " + this._name + ".onEnterFrame;&lt;/SPAN&gt;");&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:30px"&gt;delete this.onEnterFrame;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;}&lt;br /&gt;};&lt;/SPAN&gt;&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;Ok so only two real changes:&lt;br /&gt;1. Addition of the variable diff which we'll use for testing.&lt;br /&gt;2. Addition of an if then statement.&lt;br /&gt;&lt;br /&gt;The first is pretty easy to understand, the second I'll explain. Because distance is constantly shrinking eventually it will reach 0, but since we really won't notice much difference with numbers smaller then one, we can use this as our test value. I'm using Math.abs to convert the number to a positive number and Math.floor to round the number to a whole number. For clean up purposes I am deleting the onEnterFrame script. Any other action can happen here. For instance:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;mc1.onEnterFrame = function() {&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;this.stopy = this.starty+200;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;this.diff = (this._x-this.stopy)/3;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;if (Math.floor(Math.abs(this.diff)) == 0) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:30px"&gt;if (this._alpha&gt;0) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:45px"&gt;this._alpha -= 10;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:30px"&gt;} else {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:45px"&gt;trace("delete "+this._name+".onEnterFrame;&lt;/SPAN&gt;");&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:45px"&gt;delete this.onEnterFrame;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:30px"&gt;}&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;} else {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:30px"&gt;this._x -= this.diff;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;}&lt;br /&gt;};&lt;/SPAN&gt;&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;Now the clip fades out after sliding to the right.&lt;br /&gt;&lt;br /&gt;&lt;B&gt;&lt;I&gt;So what would I use this for?&lt;/I&gt;&lt;/B&gt; Well on application for this would be, say, having a tabbed menu item that extends on click. It could slide up or out, then the menu items could fade in one by one. Or, for instance, you could have movieclips that slide from left to right one after the other. Basically you can do whatever you want, you only have to imagine it.&lt;br /&gt;&lt;br /&gt;Ok that's it for now, hopefully I can finish my next entry earlier then this week, or last week. Enjoy.&lt;div class="blogger-post-footer"&gt;Copyright © 2005 JohnnyStorm.com&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.johnnystorm.com/flash/2004/09/move-it-on-over.php' title='Move it on over...'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7836560&amp;postID=109415717022359959&amp;isPopup=true' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.johnnystorm.com/flash/johnnystorm.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/109415717022359959'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/109415717022359959'/><author><name>Johnny Storm</name><uri>http://www.blogger.com/profile/09388240165336990332</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-7836560.post-109355519063117807</id><published>2004-08-26T17:18:00.000-04:00</published><updated>2004-08-26T17:22:39.260-04:00</updated><title type='text'>Quick like a bunny...</title><content type='html'>Ok, I'm going to make this one quick, cause it's thursday and well, its a cool feature but not a lot to say about it.&lt;br /&gt;&lt;br /&gt;What I want to talk about is the "apply()" function, very cool. If you have any experience with Macromedia Director "apply()" is akin to the "do" function., essentially you can execute code through "apply()".&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;function myFunction() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;trace(arguments);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;var turtles = new Array("Raphael", "Michaelangelo", "Leonardo", "Donatello");&lt;br /&gt;myFunction.apply(null,turtles);&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;Ok I lied, its not as akin to the "do" command in Director, but its still cool, essentially you can execute function using "apply()" this is essential, to say, execute a function after an action occurs. For instance:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;MovieClip.prototype.fadeOut = function(i, action) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var actions = arguments.slice(2, arguments.length);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.onEnterFrame = function() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (this._alpha&gt;0) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this._alpha -= i;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(action != null) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_root[action].apply(this, actions);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;delete this.onEnterFrame;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;};&lt;br /&gt;};&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;this is a simple fade out script, it causes the movieclip to fade out, but once the movieclip is finished fading out, you have the option to trigger an event. In this case it would act like:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;mc1.fadeOut(10, proceed, 0, 0);&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;proceed would be the function to execute and the 0, 0 would be arguments to pass onto proceed for it to work effectively (function proceed(x, y)). &lt;br /&gt;&lt;br /&gt;For more information (confusing information) check out the entry on &lt;A href="http://livedocs.macromedia.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flash_MX_2004&amp;file=00001355.html" target="_blank"&gt;LiveDocs&lt;/A&gt;.&lt;div class="blogger-post-footer"&gt;Copyright © 2005 JohnnyStorm.com&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.johnnystorm.com/flash/2004/08/quick-like-bunny.php' title='Quick like a bunny...'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7836560&amp;postID=109355519063117807&amp;isPopup=true' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.johnnystorm.com/flash/johnnystorm.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/109355519063117807'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/109355519063117807'/><author><name>Johnny Storm</name><uri>http://www.blogger.com/profile/09388240165336990332</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-7836560.post-109340053701626734</id><published>2004-08-24T22:19:00.000-04:00</published><updated>2004-08-25T11:31:25.830-04:00</updated><title type='text'>Hey some of us have to work...</title><content type='html'>Its been a really busy week so new post yet, so instead I uploaded a new extension:&lt;br /&gt;&lt;br /&gt;&lt;A href="http://www.johnnystorm.com/flash/downloads/JS_export_bitmap.zip"&gt;&lt;B&gt;JS-Export Bitmap&lt;/B&gt;&lt;/A&gt;&lt;br /&gt;This extension adds functionality to Flash. It allows you to export selected bitmaps or movieclips as png files with transparencies. This is useful for fla files who's source files are not available.&lt;br /&gt;&lt;br /&gt;I haven't tested this on a PC yet, cause I don't have Flash on my PC, so if someone does install it on a PC and it doesn't work... BUY A MAC!!!! HA!&lt;br /&gt;&lt;br /&gt;No seriously, if there is a problem do me a favor and shoot me an email.&lt;br /&gt;&lt;br /&gt;Thanks&lt;br /&gt;&lt;br /&gt;-js&lt;br /&gt;&lt;br /&gt;***UPDATE***&lt;br /&gt;&lt;br /&gt;I was able to do some testing on a PC and got it working for the most part, there are a few quirks on the PC I may or may not be able to work out. For one you have to include the .png extension when naming your file and for some reason gifs aren't exporting correctly. Everything seems to be working fine on the Mac though.&lt;div class="blogger-post-footer"&gt;Copyright © 2005 JohnnyStorm.com&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.johnnystorm.com/flash/2004/08/hey-some-of-us-have-to-work.php' title='Hey some of us have to work...'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7836560&amp;postID=109340053701626734&amp;isPopup=true' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.johnnystorm.com/flash/johnnystorm.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/109340053701626734'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/109340053701626734'/><author><name>Johnny Storm</name><uri>http://www.blogger.com/profile/09388240165336990332</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-7836560.post-109278121196556882</id><published>2004-08-16T18:19:00.000-04:00</published><updated>2004-09-05T01:18:32.410-04:00</updated><title type='text'>And now for something completly different... Arrays?</title><content type='html'>After finishing my first tutorial involving arrays (thanks to Jason for testing out my code for me) the three individuals who read it (and you know who you are) suggested I write even more about them. As if what the world needed more of was blogs about arrays, but who am I to disappoint my fans... without them I'd... well... I'd sleep more that's for sure.&lt;br /&gt;&lt;br /&gt;So what more is there to learn about arrays?&lt;br /&gt;Puuulenty... I had just hit the top of the iceberg, so to speak, and so there is plenty more. If you open the flash help section to arrays, you'll see a plethora of commands and functions. I highly reccomend you go through every entry to help familiarize yourself with the commands and provide another reason not to go outside (does the sun still shine?). To put thing in practical terms let's create a menu similar to my portfolio menu on the main site (insert shameless plug). I use php and mySql to manage my portfolio, but don't worry, for now we'll use a text file.&lt;br /&gt;&lt;br /&gt;I should say now, that these examples could use xml as well, but to be honest, I'm not entirely sold on it. Instead we'll use a text file and the name=value pair separated by the &amp;. This is similar to how variables are processed in a form using the get action. &lt;br /&gt;&lt;br /&gt;So step one, open your favorite text editor and while your at it go ahead and create a new flash movie. Save both files in the same location and for this exercise name the flash file "loadvars.fla" and the text file "data.ini". &lt;br /&gt;&lt;br /&gt;Now your already asking me what the significance is of using the .ini extension, and the answer is easy, there is none. What extension you use is irrelevant, as long as the file is plain text,  I just prefer to use .ini.&lt;br /&gt;&lt;br /&gt;After you've saved focus on the text file. What we are going to do here is create a file flash can use, which contains the information we want to be populated in our menu.&lt;br /&gt;&lt;br /&gt;To do this we are going to format the data in name value pairs which are seperated by the ampersand (&amp;). So to start type the following into the text file:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;&amp;title1=Star Wars&amp;&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;Ok, let's take a look at what we did; the first we did was start the line with an ampersand, because flash parses the information using the ampersand as the item delimiter it is best to start and end each line with one. Also because flash has special use for the ampersand you cannot use it in your text without breaking the code. So instead use a series of characters to represent the ampersand, %26 (this is called unicode which I will go into depth more about later), so for instance:&lt;br /&gt;&lt;br /&gt;A&amp;P would be A%26P&lt;br /&gt;&lt;br /&gt;The equal sign also has to be converted and it's code is: %00.&lt;br /&gt;&lt;br /&gt;So let's get to the meet of it shall we? Make your text file look like the following:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;&amp;lname1=Parker&amp;&lt;br /&gt;&amp;lname2=Storm&amp;&lt;br /&gt;&amp;lname3=Richards&amp;&lt;br /&gt;&amp;lname4=Grimm&amp;&lt;br /&gt;&amp;lname5=Storm&amp;&lt;br /&gt;&amp;lname6=Rogers&amp;&lt;br /&gt;&amp;lname7=Stark&amp;&lt;br /&gt;&amp;lname8=Banner&amp;&lt;br /&gt;&amp;lname9=Murdock&amp;&lt;br /&gt;&amp;lname10=Einstein&amp;&lt;br /&gt;&amp;fname1=Peter&amp;&lt;br /&gt;&amp;fname2=Johnny&amp;&lt;br /&gt;&amp;fname3=Reed&amp;&lt;br /&gt;&amp;fname4=Ben&amp;&lt;br /&gt;&amp;fname5=Sue&amp;&lt;br /&gt;&amp;fname6=Steve&amp;&lt;br /&gt;&amp;fname7=Tony&amp;&lt;br /&gt;&amp;fname8=Bruce&amp;&lt;br /&gt;&amp;fname9=Matt&amp;&lt;br /&gt;&amp;fname10=Frank&amp;&lt;br /&gt;&amp;email1=pparker@dailybugle.com&amp;&lt;br /&gt;&amp;email2=jstorm@ff.org&amp;&lt;br /&gt;&amp;email3=rrichards@ff.org&amp;&lt;br /&gt;&amp;email4=bgrimm@ff.org&amp;&lt;br /&gt;&amp;email5=sstorm@ff.org&amp;&lt;br /&gt;&amp;email6=srogers@avengers.gov&amp;&lt;br /&gt;&amp;email7=tstark@avengers.gov&amp;&lt;br /&gt;&amp;email8=bruce.banner@usarmy.gov&amp;&lt;br /&gt;&amp;email9=matt_murdock@murdocknelson.com&amp;&lt;br /&gt;&amp;email10=f.einstein@madman.com&amp;&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;Wow that's a lot. You may not think so copying &amp; pasting... But I'm writing this on a PDA.&lt;br /&gt;&lt;br /&gt;Now thanks to flash, the next part is significantly easier, previously, in flash, you used the "loadvars" command. Now while this was effective at importing information into flash, it was a bit clunky in processing the information, namely when testing if it had loaded or not.&lt;br /&gt;&lt;br /&gt;But now in flash MX 2004 you can use the loadVars object to load information, which includes an onloaded event. The beauty of this is you no longer have to test when the load is completed, you just specify what actions to take when it is loaded.&lt;br /&gt;&lt;br /&gt;So now focusing on our flash file enter the following into the frame 1 action:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;loadVarsText = new LoadVars();&lt;br /&gt;loadVarsText.onLoad = function(success) {&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;if(success) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;trace("data loaded");&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;} else {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;trace("load failed");&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;}&lt;br /&gt;loadVarsText.load("data.ini.");&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;Ok, so the first thing we did was establish a new object. Notice the o in object is capitalized, remember that case-sensitivity is very important. The second thing we did was establish what to do once the data is loaded. In this case we are testing to see wether the load was successful or not. We're doing this via the success attribute, which returns a true if successful and a false if not. This is, obviously, useful, especially if your movie is dependant upon external data.&lt;br /&gt;&lt;br /&gt;So the next step is to process the data into a useable form. Our end goal is to create a spreadsheet style menu to present our data. To help us in this the first thing we are going to do is transfer our data to an associative array. The reason we are going to do this is simple: sorting.&lt;br /&gt;&lt;br /&gt;The most brilliant aspect of using an associative array is the sortOn feature. Now you can sort an array alpha-numerically, but with the sortOn function you can sort an associative array based on a specific property. This is ideal for us since we are importing first and last names, so we can sort on the last name or the first.&lt;br /&gt;&lt;br /&gt;&lt;B&gt;Add the following code to your flash file:&lt;/B&gt;&lt;br /&gt;&lt;P class="code"&gt;vendors = new Array();&lt;br /&gt;for(var i = 1; loadVarsText["iname"+i] != null; i++) {&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;vendors.push({lname: loadVarsText["iname"+i],  fname: loadVarsText["fname"+i], email: loadVarsText["email"+i]});&lt;br /&gt;}&lt;/P&gt;&lt;br /&gt; &lt;br /&gt;Ok, so now our data is in an array. You'll notice two things here: loadVar[] and != null. Since we are using an object to store the data we have to access it from there as well. This is unlike the previous way which dumped the data into a specified target. Also since we used a naming convention with our data (lname1, lname2, etc...) we use != null to keep the loop going until all the data is processed.&lt;br /&gt;&lt;br /&gt;So now it's in an array, let's have some fun, well as much fun can be had with arrays. As an added treat we're giong to use nothing but code, not as a means of showing off, but as a means of showing you what is possible.&lt;br /&gt;&lt;br /&gt;&lt;B&gt;As always please enter the following code:&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;loadVarsText = new LoadVars();&lt;br /&gt;loadVarsText.onLoad = function(success) {&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;if (success) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;vendors = new Array();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;for (var i = 1; this["lname"+i] != null; i++) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;vendors.push({lname:this["lname"+i], fname:this["fname"+i], email:this["email"+i]});&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;vendors.sortOn(lname);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;createMenu();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;createFields();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;createButtons();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;} else {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;trace("not loaded");&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;};&lt;br /&gt;loadVarsText.load("data.ini");&lt;br /&gt;function createMenu() {&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;var colX = 0;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;var n = 0;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;for (var name in vendors[0]) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;createEmptyMovieClip("col"+n, this.getNextHighestDepth());&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;this["col"+n]._x = colX;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;this["col"+n]._y = 0;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;colX += 100;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;var x = 0;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;var y = 0;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;for (var i = 0; i&amp;lt;vendors.length; i++) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;if (_root["roll"+i] == null) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;_root["roll"+i] = new Object();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;AsBroadcaster.initialize(_root["roll"+i]);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;if (this["col"+n]["menu"+i] == null) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this["col"+n].createEmptyMovieClip("menu"+i, this["col"+n].getNextHighestDepth());&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this["col"+n]["menu"+i]._y = y;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;y += 20;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this["col"+n]["menu"+i].createEmptyMovieClip("bg", this["col"+n]["menu"+i].getNextHighestDepth());&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;with (this["col"+n]["menu"+i].bg) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;lineStyle(1, 0xCCCCCC, 100);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;beginFill(0x000066);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;moveTo(0, 0);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;lineTo(100, 0);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;lineTo(100, 20);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;lineTo(0, 20);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;lineTo(0, 0);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;endFill();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this["col"+n]["menu"+i].createTextField("theText", this["col"+n]["menu"+i].getNextHighestDepth(), 2, 2, 96, 16);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;with (this["col"+n]["menu"+i].theText) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;type = "dynamic";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;border = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;background = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;password = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;multiline = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;html = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;embedFonts = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;selectable = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;wordWrap = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;var my_fmt = new TextFormat();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;with (my_fmt) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;font = "Arial";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;size = 10;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;color = 0xFFFFFF;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;this["col"+n]["menu"+i].theText.text = vendors[i][name];&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;this["col"+n]["menu"+i].theText.setTextFormat(my_fmt);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;this["col"+n]["menu"+i].myObj = this["roll"+i];&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;this["col"+n]["menu"+i].myField = name+"_field";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;this["col"+n]["menu"+i].onRollOver = function() {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this.myObj.broadcastMessage("myRollOver");&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;};&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;this["col"+n]["menu"+i].onRollOut = function() {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this.myObj.broadcastMessage("myRollOut");&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;};&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;this["col"+n]["menu"+i].onRelease = function() {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this.myObj.broadcastMessage("myRelease");&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;};&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;this["col"+n]["menu"+i].myRollOver = function() {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this.theText.textColor = 0xCCCCCC;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this.myColor = new Color(this.bg);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this.myState = this.myColor.getTransform();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this.myColor.setRGB(0x0077A3);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;};&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;this["col"+n]["menu"+i].myRollOut = function() {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this.theText.textColor = 0xFFFFFF;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this.myColor.setTransform(this.myState);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;};&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;this["col"+n]["menu"+i].myRelease = function() {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;var my_fmt = new TextFormat();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;with (my_fmt) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;font = "Arial";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;size = 10;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;&lt;SPAN style="margin-left: 5px;"&gt;color = 0x000000;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;_root[this.myField].text = this.theText.text;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;_root[this.myField].setTextFormat(my_fmt);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;};&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;_root["roll"+i].addListener(this["col"+n]["menu"+i]);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;n++;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;}&lt;br /&gt;function createFields() {&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;var n = 0;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;var textX = 325;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;var textY = 5;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;for (var name in vendors[0]) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;var fieldHeader = name+"_header";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;createTextField(fieldHeader, 50+n, textX, textY+2, 55, 20);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;with (this[fieldHeader]) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;type = "dynamic";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;border = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;background = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;password = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;multiline = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;html = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;embedFonts = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;selectable = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;wordWrap = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;var my_fmt = new TextFormat();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;with (my_fmt) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;font = "Arial";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;size = 10;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;color = 0x000000;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;text = name+":";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;setTextFormat(my_fmt);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;var fieldName = name+"_field";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;createTextField(fieldName, 100+n, textX+45, textY, 150, 20);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;with (this[fieldName]) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;type = "input";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;border = true;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;background = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;password = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;multiline = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;html = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;embedFonts = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;selectable = true;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;wordWrap = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;setTextFormat(my_fmt);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;textY += 25;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;n++;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;}&lt;br /&gt;&lt;!--HERE--&gt;&lt;br /&gt;function createButtons() {&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;var n = 0;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;var x = 0;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;var y = 350;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;for (var name in vendors[0]) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;createEmptyMovieClip(name+"_btn", 150+n);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;this[name+"_btn"]._x = x;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;this[name+"_btn"]._y = y;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;with (this[name+"_btn"]) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;lineStyle(1, 0xCCCCCC, 100);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;beginFill(0x000066);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;moveTo(0, 0);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;lineTo(100, 0);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;lineTo(100, 20);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;lineTo(0, 20);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;lineTo(0, 0);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;endFill();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;this[name+"_btn"].category = name;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;this[name+"_btn"].createTextField("theText", 5, 2, 2, 96, 16);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;with (this[name+"_btn"].theText) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;type = "dynamic";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;border = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;background = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;password = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;multiline = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;html = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;embedFonts = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;selectable = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;wordWrap = false;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;var my_fmt = new TextFormat();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;with (my_fmt) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;font = "Arial";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;size = 10;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;color = 0xFFFFFF;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;align = "center";&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;text = "sortOn "+name;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;setTextFormat(my_fmt);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;this[name+"_btn"].onRelease = function() {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;vendors.sortOn(this.category);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;createMenu();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;};&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;x += 105;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;n++;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;}&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;Ok, I realize there is a lot of code, so hopefully you just copied and pasted it. A lot of this is rather advanced, so for now just ignore the parts you don't understand. I wrote this all in code so that you can test it withouth having to download any .fla files, I will explain everything in time, but for now lets discuss the parts important to what we are doing.&lt;br /&gt;&lt;br /&gt;So we imported the data and we populated an array with the information. One of the key things we did was "sortOn", which allowed us to sort the array based on the lName. The code also created three buttons which allow you to sort the array based on each field. If you test the movie you will see what I mean.&lt;br /&gt;&lt;br /&gt;I used code to create all of the movieclips, text, etc... so you can see what is possible. Feel free to poke around this code to get an ide of what is possible, but for now let's take a step back.&lt;br /&gt;&lt;br /&gt;I want you to recreate what I did using code, create three buttons, with the text "sortOn lname", "sortOn fname", and "sortOn email". Feel free to make these buttons as pretty as you like. Next create three textfields, "lname_field", "fname_field", and "email_field". And finally create a movieclip to be used for the menu items. Include a textfield which has an instance name of "theText", make it dynamic and make sure that it isn't selectable. Also for this exercise please align the movieclip in the upper left corner.&lt;br /&gt;&lt;br /&gt;Give the movieclip two frames, be sure to put a stop(); action in frame one and alter the movieclip in frame two to be the rollover state. Under linkage properites check "Export for ActionScript" and set the identifier as "menu". By default "Export in first frame" is checked, so be sure to leave that checked.&lt;br /&gt;&lt;br /&gt;Once finished, use the following script, this is just a paired down version of my previous script, I've eliminated all of the code that might be confusing, to give you a better idea of what is going on here.&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;loadVarsText = new LoadVars();&lt;br /&gt;loadVarsText.onLoad = function(success) {&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;if (success) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;vendors = new Array();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;for (var i = 1; this["lname"+i] != null; i++) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;vendors.push({lname:this["lname"+i], fname:this["fname"+i], email:this["email"+i]});&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;vendors.sortOn(lname);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;createMenu();&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;} else {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;trace("not loaded");&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;};&lt;br /&gt;loadVarsText.load("data.ini");&lt;br /&gt;function createMenu() {&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;var colX = 0;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;var n = 0;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;for (var i = 0; i&amp;lt;vendors.length; i++) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;createEmptyMovieClip("col"+n, this.getNextHighestDepth());&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;this["col"+n]._x = colX;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;this["col"+n]._y = 0;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;colX += 100;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;var x = 0;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;var y = 0;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;for (var i = 0; i&amp;lt;vendors.length; i++) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;if (this["col"+n]["menu"+i] == null) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this["col"+n].attachMovie("menu", "menu"+i, i+1);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this["col"+n]["menu"+i]._y = y;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;y += this["col"+n]["menu"+i]._height;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;this["col"+n]["menu"+i].theText.text = vendors[i][name];&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;this["col"+n]["menu"+i].myText = vendors[i][name];&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;this["col"+n]["menu"+i].myIndex = n;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;this["col"+n]["menu"+i].onRollOver = function() {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this.gotoAndStop(2);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this.theText.text = this.myText;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;};&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;this["col"+n]["menu"+i].onRollOut = function() {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this.gotoAndStop(1);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this.theText.text = this.myText;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;};&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;this["col"+n]["menu"+i].onRelease = function() {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;popData(this.myIndex);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;};&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;n++;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;}&lt;br /&gt;function popData(i) {&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;lname_field.text = vendors[i].lname;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;fname_field.text = vendors[i].fname;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;email.text = vendors[i].email;&lt;/SPAN&gt;&lt;br /&gt;}&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;The biggest difference you'll see in my all code version and this paired down version is that only one menu item hilights at a time. This is because I was using an undocumented function called AsBroadcaster. I've only begun to play around with this myself, and found it rather confusing at first, but I'll go into that later. For now let's take a look at what's going on here:&lt;br /&gt;&lt;br /&gt;Essentially what is happening is that I have imported the data, pushed it into an array, and then I created a movieclip for each category, and then a menu item for each entry. So we end up with 27 movieclips. The reason why I used a movieclip for each category instead of just 27 movieclips side by side, is 1. its easier, and 2. if I decide to affect the columns, I can affect them one at a time much easier. For instance, if I wanted to mask it or to fit in a specific area.&lt;br /&gt;&lt;br /&gt;Also, when I perform a sortOn, I am not recreating the menu items, just the content in them. This saves times and won't affect any placement settings you have, and since the number of items hasn't changed there is no real reason to remove and recreate them.&lt;br /&gt;&lt;br /&gt;Now let's add some code to change the menus on release, this can be later adapted for rollover if desired, but this will be a clunkier way then using the AsBroadcaster method. Append your file accordingly:&lt;br /&gt;&lt;P class="code"&gt;function popData(index) {&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;for (var i = 0; this["col"+i] != null; i++) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;for(var n = 0; this["col"+i]["menu"+n] != null; i++) {;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;if(index == n) {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this["col"+i]["menu"+i].gotoAndStop(2);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;} else {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 20px;"&gt;this["col"+i]["menu"+i].gotoAndStop(1);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 15px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 10px;"&gt;i++;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;lname_field.text = vendors[index].lname;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;fname_field.text = vendors[index].fname;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin-left: 5px;"&gt;email.text = vendors[index].email;&lt;/SPAN&gt;&lt;br /&gt;}&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;This code basically cycles through the all of the columns and rows and either sets them to the clicked state or the unclicked state based on which button has been clicked.&lt;br /&gt;&lt;br /&gt;&lt;B&gt;AIGHT!&lt;/B&gt; That's it for now... this was a doozy, hopefully next weeks article won't be a severe... speaking of which... guess I better get started... ciao.&lt;div class="blogger-post-footer"&gt;Copyright © 2005 JohnnyStorm.com&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.johnnystorm.com/flash/2004/08/and-now-for-something-completly.php' title='And now for something completly different... Arrays?'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7836560&amp;postID=109278121196556882&amp;isPopup=true' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.johnnystorm.com/flash/johnnystorm.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/109278121196556882'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/109278121196556882'/><author><name>Johnny Storm</name><uri>http://www.blogger.com/profile/09388240165336990332</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-7836560.post-109210557774371436</id><published>2004-08-09T22:37:00.000-04:00</published><updated>2004-09-04T14:40:13.266-04:00</updated><title type='text'>An array of this and array of that...</title><content type='html'>The whole point of this web site is to present flash from a more every man's... Err... Every person's point of view. For the most part what I've found online and in books is either very technical or very dumbed down. I'm hoping to present a third option, while I plan to be quite technical, I hope to present it in a format that is neither dumbed down, or condescending.&lt;br /&gt;&lt;br /&gt;To that end, I thought I would start with arrays: A friend asked me why he should use arrays. It's a fair question, and the reason I would use arrays is different then his need. But since the array concept is sort of central to the whole flash object structure, it's a good concept to familiarize you with. &lt;br /&gt;&lt;br /&gt;&lt;DIV class="header"&gt;What exactly is an array?&lt;/DIV&gt; Think of an array as a list of items separated by commas. The best example of an array can be found in your email client, in the field where you indicate who you want to send an email to. As you add names to the field they are separated by commas and there you have your first array. &lt;br /&gt;Now let's translate that into flash. Open a new flash document and label the first layer &amp;quot;Actions&amp;quot;, organization will be extremely useful when editing old files so it's a good idea to start right away.&lt;br /&gt;In frame one of the actions layer and type the following code:&lt;br /&gt; &lt;br /&gt;&lt;P class="code"&gt;myArray = new Array();&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;Now my plan here is to explain every line of code so that you don't just mimic what I am doing but rather you understand why it is I am doing what I am doing.&lt;br /&gt;&lt;br /&gt;In the first line we have &amp;quot;myArray = new Array();&amp;quot; this is the standard way to set up an empty array. There is another way to set up an array, which is less descriptive, for the sake of completion I will include it, but for my examples I will use the standard way.&lt;br /&gt;&lt;br /&gt;The alternative way to establish an array is myArray = [];&lt;/SPAN&gt;&lt;br /&gt;&lt;br /&gt;Now there are two kinds of arrays, standard arrays, which appear just like lists separated by commas, and associated arrays, which essentially is an array which contains other arrays. Confusing? No doubt, but don't worry about that right now, we're going to focus on the standard array for now and touch on associative arrays later.&lt;br /&gt;&lt;br /&gt;The second line of code to enter is:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;myArray.push(&amp;quot;pparker@dailybugle.com&amp;quot;);&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;There, we've just entered our first value into the array, the &amp;quot;push&amp;quot; command is used to append the entry contained within the parentheses into the list at the very end. Once you've entered the code add the following then test the movie:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;trace(myArray.toString());&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;If everything went well you should notice in your output window pparker@dailybugle.com, now you have an array with one value. Its good to note that Flash MX 2004 is Case-sensitive, so be sure that all of the cases are properly set, if you were to say use myArray = new array(); instead of new Array(), first Flash will yell at you and second your script may not work. So now let's move on to adding another value to the array:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;myArray.push("jstorm@ff.org");&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;put that line between the first push line and the trace line and you should see pparker@dailybugle.com, jstorm@ff.org essentially a list of email addresses separated by commas. I should point out that the &amp;quot;toString()&amp;quot; command takes the Array, which consists of objects, and converts it to a string, if you are curious to see what I mean by objects, remove the &amp;quot;toSTring()&amp;quot; from the trace command and see what I mean.&lt;br /&gt;&lt;br /&gt;Now here is the most tricky part of an array, one that still manages to confuse me even though I've been using them for years. Arrays were developed so that you can access the information in them, simply by saying which point in the list you want. This is done by using the brackets: [] and using a number known as the index, to signify which value to retrieve. As an example change the trace action as such:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;trace(myArray[1]); &lt;/P&gt;&lt;br /&gt;&lt;br /&gt;If done correctly it will return jstorm@ff.org. Now you'll notice that I use the number one in the brackets and yet it returned the second value instead of the first. That is because some genius decided to start counting with zero instead of one, thus forever making our lives complicated, as far as arrays go that is. So to obtain the very first value of the array us a zero like such:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;trace(myArray[0]);&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;By using the index to determine where in the array to retrieve information, you can also use the index to specify where to set information. To make your life even more complicated, instead of using the &amp;quot;push()&amp;quot; command to add a value to the array, try this:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;myArray[2] = "bgrimm@ff.org";&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;If you run a trace, you will see that the new value has been added to the end of the list, this is because I told the array I want the third value to be the new information. This is true of editing entries already in the array, if you had but a number one instead of 2 you would see that the second value had been replaced with our new value and two values remain.&lt;br /&gt;&lt;br /&gt;Which leads me to my next point, which is, how do you determine how many values are in an array? Well that's easy and complicated at the same time, it's easy because you can use the &amp;quot;length&amp;quot; value to determine how many values are inside, but the length value will always be one number higher then the last index of the array. Have I confused you yet? Well let me show you what I mean.&lt;br /&gt;&lt;br /&gt;Add the following code and test the movie:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;myArray = new Array();&lt;/SPAN&gt;&lt;br /&gt;myArray.push(&amp;quot;pparker@dailybugle.com&amp;quot;);&lt;/SPAN&gt;&lt;br /&gt;myArray.push("jstorm@ff.org");&lt;/SPAN&gt;&lt;br /&gt;myArray[2] = "bgrimm@ff.org";&lt;/SPAN&gt;&lt;br /&gt;myArray[3] = "rrichards@ff.org";&lt;/SPAN&gt;&lt;br /&gt;myArray[4] = "sstorm@ff.org";&lt;/SPAN&gt;&lt;br /&gt;trace(&amp;quot;length:&amp;quot;+myArray.length);&lt;/SPAN&gt;&lt;br /&gt;trace(&amp;quot;first value:&amp;quot;+myArray[0]);&lt;/SPAN&gt;&lt;br /&gt;trace(&amp;quot;last value:&amp;quot;+myArray[myArray.length]);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;If properly entered &amp;quot;pparker@dailybugle.com&amp;quot; will be returned for the first value but you will see an &amp;quot;undefined&amp;quot; returned for the last value. To correctly obtain the last value use myArray[myArray.length-1] instead. See, complicated, and easy to forget, especially when you get into dates and you try to pull the month out of the date array.&lt;br /&gt;&lt;br /&gt;So keep that in mind that everything in an array is on place lower or one number lower then where logic would dictate it would be.&lt;br /&gt;&lt;br /&gt;So now that we've created an array, you're probably still wondering what's all the hub bub? Well it's a valid point, but let's look at it like this. Say you want to create a menu for use in your movie. Your menu has 5 menu items that all look the same, except for the text. Now you could manually create 5 menu items, place them where you want, assign them each code, or, you could use ActionScript to do it all for you, save you some time, and make making revisions easier. Let me show you what I mean.&lt;br /&gt;&lt;br /&gt;The worst part of this whole scenario is that I am planning on leaping light years ahead, difficulty wise, to explain this exercise. If for some reason you are unable to understand everything, please, continue on with the exercise, and hopefully everything will make sense by the end. I will lightly touch on things now, but I will revisit them at a later point in time, if for some reason you cannot wait for a full explanation, the Flash in application help is a good source of information and explanations, and is where I learned most of what I know.&lt;br /&gt;&lt;br /&gt;First thing I want you to do is set up your array, we're going to make an array with 5 entries, to make it easier, for now, we're just going to change the title of the menu, and leave additional information for later.&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;myArray = new Array(&amp;quot;Home&amp;quot;, &amp;quot;Portfolio&amp;quot;, &amp;quot;Resume&amp;quot;, &amp;quot;About&amp;quot;, &amp;quot;Contact&amp;quot;);&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;So we have an array of five objects or 5 entries. Next thing I want you to do is create a simple box on the stage that will serve as our menu, create a text field on top of it centered and be sure to specify &amp;quot;dynamic&amp;quot; in the properties menu. For now no other values are necessary, but feel free to tweak the textfield to your own design. For the sake of this example please select &amp;quot;center&amp;quot; for the text align. Be sure to enter in a name in the instance filed of the properties menu, for the sake of this exercise please use &amp;quot;myText&amp;quot;.&lt;br /&gt;&lt;br /&gt;Once you are finished select the entire menu box and convert it to a symbol, for the sake of ease choose a top left align, and give the if the button under the cancel button says &amp;quot;advanced&amp;quot; click it to expand to the advanced mode and enter in &amp;quot;menu&amp;quot; into the &amp;quot;Identifier:&amp;quot; field. This will automatically select &amp;quot;Export for ActionScript&amp;quot; and &amp;quot;Export in first frame&amp;quot;, leave those settings for now.&lt;br /&gt;&lt;br /&gt;Basically what we did was create a shared object in the library that we will be able to use via ActionScript in our movie. What we are doing is similar to the duplicateMovieClip() command, but unlike the duplicateMovieClip() command, this doesn't require the movieclip to be on the stage when the script is executed.&lt;br /&gt;&lt;br /&gt;The next thing we are going to do is execute a for loop. The for loop is a really powerful tool in flash, and allows you to do a lot of really cool things, for now we are going to use it to go through every index of the array and retrieve the value. There are other ways to do this, but for now we'll use the for loop.&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;for(var i = 0; i &amp;lt; myArray.length; i++) {&lt;br /&gt;&lt;br /&gt;}&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;As you can see there are parentheses, curly brackets and semi colons. The parentheses determine what actions the for loop will take, the semi-colon will delineate them, and the curly brackets indicates what actions will happen during each loop;&lt;/SPAN&gt;&lt;br /&gt;&lt;br /&gt;Now let's break down the for loop:&lt;br /&gt;&lt;br /&gt;for(var i = 0; what we've done here is establish the first value of I for the loop. Since we are using an array, this number should be zero to start at the beginning of the array. This is essentially the same as pointing to the pinkie of your left hand before you begin counting to ten. You'll notice the &amp;quot;Var&amp;quot; in there, there are two types of variables in flash, local and global, a local variable is specified by &amp;quot;var&amp;quot; and will only be used in the for loop, a global variable, without the var, can be used by anything in the current timeline, since I is a throw away number or since we won't use it past the for loop, use the var in front, as you begin to code more, you'll find that you will use the same variable names over and over again, so its good to start good practices now.&lt;br /&gt;&lt;br /&gt;i &amp;lt; myArray.length; this is probably the only time an array indexing starting at zero comes in handy. Basically we want to loop as many times as there are values in the array. We are going to continue the loop until the I value is less then (&amp;lt;) the length of the array. Because the length number is always one number higher then the last index in the array, we can test for a less then value. If, however, you wanted to manually test it, and use the number of the last index, you would have to use the less then or equal to (&amp;lt;=) because the loop will stop at the number if less then, and you would be one value short.&lt;br /&gt;&lt;br /&gt;i++) { this tells the I variable that it should increment itself by one after the loop has completed. It is the equivalent of saying I = i+1 (as in flash 4) to make things easy, you simply use two plus signs to increment by one and two minus signs to decrease by one;&lt;/SPAN&gt;&lt;br /&gt;&lt;br /&gt;Now everything inside the curly brackets is what we want to have happen during the loop, this takes place after the initial value of I is set and before i is incremented. In this case let's test it out by tracing the value so put the following between the curly brackets:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;for(var i = 0; i &amp;lt; myArray.length; i++) {&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;trace(myArray[i]);&lt;/SPAN&gt;&lt;br /&gt;}&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;If done correctly you will see all the values of your array, if you want to get tricky try adding:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;trace(i +&amp;quot;:&amp;quot;+myArray[i]);&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;And this will show you the index in correspondence to its value;&lt;/SPAN&gt;&lt;br /&gt;&lt;br /&gt;So ready to take it up a notch? Ok, add the following code, don't worry I'll explain it all line by line but for now just enter it as is, its all text on purpose so you can copy and paste it, but it may help to retype it so you can understand what's going on.&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;myArray = new Array(&amp;quot;Home&amp;quot;, &amp;quot;Portfolio&amp;quot;, &amp;quot;Resume&amp;quot;, &amp;quot;About&amp;quot;, &amp;quot;Contact&amp;quot;);&lt;/SPAN&gt;&lt;br /&gt;var x = 100;&lt;br /&gt;var y = 100;&lt;br /&gt;for(var i = 0; i &amp;lt; myArray.length; i++) {&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;attachMovie(&amp;quot;menu&amp;quot;, &amp;quot;menu&amp;quot;+i, i+1);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;_root[&amp;quot;menu&amp;quot;+i].myText.text = myArray[i];&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;_root[&amp;quot;menu&amp;quot;+i].myText.autoSize = &amp;quot;center&amp;quot;;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;_root[&amp;quot;menu&amp;quot;+i]._x = x;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;_root[&amp;quot;menu&amp;quot;+i]._y = y;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;y+=_root[&amp;quot;menu&amp;quot;+i]._height;&lt;/SPAN&gt;&lt;br /&gt;}&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;After you finish test the movie, if everything went well you should have a five instances of the menu movieclip, and the text should have changed to reflect the entry of the array. Pretty cool right? Imagine what else you could do, say, pass the menu item information to use on a mouse action, or pass it a color value to use when you rollover the menu. For the sake of this exercise we're going to add one more action, so you can get a feel for what's going on, please append your script to look like this:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;myArray = new Array(&amp;quot;Home&amp;quot;, &amp;quot;Portfolio&amp;quot;, &amp;quot;Resume&amp;quot;, &amp;quot;About&amp;quot;, &amp;quot;Contact&amp;quot;);&lt;/SPAN&gt;&lt;br /&gt;var x = 100;&lt;br /&gt;var y = 100;&lt;br /&gt;for(var i = 0; i &amp;lt; myArray.length; i++) {&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;attachMovie(&amp;quot;menu&amp;quot;, &amp;quot;menu&amp;quot;+i, i+1);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;_root[&amp;quot;menu&amp;quot;+i].myText.text = myArray[i];&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;_root[&amp;quot;menu&amp;quot;+i].myText.autoSize = &amp;quot;center&amp;quot;;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;_root[&amp;quot;menu&amp;quot;+i]._x = x;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;_root[&amp;quot;menu&amp;quot;+i]._y = y;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;_root[&amp;quot;menu&amp;quot;+i].onRelease = function() {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:30px"&gt;trace(this.myText.text);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;y+=_root[&amp;quot;menu&amp;quot;+i]._height;&lt;/SPAN&gt;&lt;br /&gt;}&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;If you test the movie, and you probably already did, you'll see that the text in the text field will appear in the output window when you click the menu item, not an elaborate script, but it should give you some idea what is possible with this script. Now let's break it down:&lt;br /&gt;&lt;br /&gt;myArray = new Array(&amp;quot;Home&amp;quot;, &amp;quot;Portfolio&amp;quot;, &amp;quot;Resume&amp;quot;, &amp;quot;About&amp;quot;, &amp;quot;Contact&amp;quot;); This should be easy.&lt;br /&gt;&lt;br /&gt;var x = 100; this variable will be used to determine the _x value of the menu option. var y = 100; this variable will be used to determine the _y value of the menu option, and because we are making a drop down menu this variable will be incremented the height of the menu. If you want to experiment you could increment the x the width of the menu instead, to have a top nav instead.&lt;br /&gt;&lt;br /&gt;for(var i = 0; i &amp;lt; myArray.length; i++) {&lt;br /&gt; attachMovie(&amp;quot;menu&amp;quot;, &amp;quot;menu&amp;quot;+i, i+1); ok here is the good&lt;br /&gt; stuff. Remember before I mentioned duplicate movie? Well this is similar except&lt;br /&gt; instead of duplicating a movieclip on the stage, it grabs a movieclip from&lt;br /&gt; the library and puts it on the stage in the (0, 0) position. &lt;br /&gt;&lt;br /&gt; _root[&amp;quot;menu&amp;quot;+i].myText.text = myArray[i]; this is a textField value of the contents of the textField. We want the values of the arrays in this field so we are individually populating them after creating a new object or movieclip.&lt;br /&gt;&lt;br /&gt;Something good to point out now, do you remember when I said arrays were closely tied to flash? Well here is an example, Flash sees the objects or movieclips on the stage as objects in an array. So similar to an array you can access the object not only by their index, but by their name, and thanks to probably THE most innovation of Flash, you can do that by specifying a dynamic variable. A dynamic variable is a variable that can be assigned or accessed by combining two values in this case &amp;quot;menu&amp;quot; + I, a literal translation of this would be &amp;quot;menu0&amp;quot; for the first value and &amp;quot;menu1&amp;quot; for the second, or second time through the loop.&lt;br /&gt;&lt;br /&gt;Because of this way of dealing with objects or movieclips, it makes life easy, say when trying to remove any movieclip you created. You can simply test to see if the movieclip exists to continue the loop, like such:&lt;br /&gt;&lt;br /&gt;for(var i = 0; _root[&amp;quot;menu&amp;quot;+i] != null; i++) {&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;Here I am simple checking to see if &amp;quot;menu0&amp;quot;, &amp;quot;menu1&amp;quot;, &amp;quot;menu2&amp;quot;, etc&amp;hellip; exists and if it exists then execute commands.&lt;br /&gt;&lt;br /&gt; _root[&amp;quot;menu&amp;quot;+i].myText.autoSize = &amp;quot;center&amp;quot;; this is a bit advanced, so you'd better off looking it up in the help section, but basically it tells the box to shrink or expand based on how much text is in it. In this case it shrinks or expands based on a center alignment;&lt;/SPAN&gt;&lt;br /&gt;&lt;br /&gt; _root[&amp;quot;menu&amp;quot;+i]._x = x; this tells the newly created mc to go to point x;&lt;br /&gt; _root[&amp;quot;menu&amp;quot;+i]._y = y; this tells the newly created mc to go to&lt;br /&gt; point y;&lt;/SPAN&gt;&lt;br /&gt;&lt;br /&gt; _root[&amp;quot;menu&amp;quot;+i].onRelease = function() { this may be a bit advanced too but this is the KEY to dynamic movieclip generation. Essentially what I am doing here is assigning a mouse release command via code. This would be the equivalent of putting on(Release) { in a button's script window, but instead this is a movieclip, that I want to act as a button. The beauty of this is I can remove the script simply by saying &amp;quot;delete menu1.onRelease;&amp;quot; and the menu option has been neutered. This is great if you want to have a menu item deactivated after a click, or any other mouse action.&lt;br /&gt;&lt;br /&gt; trace(this.myText.text);&lt;/SPAN&gt;&lt;br /&gt; }&lt;br /&gt; y+=_root[&amp;quot;menu&amp;quot;+i]._height; this increments the y value by the height&lt;br /&gt; of the current menu so the next one will appear underneath it;&lt;/SPAN&gt;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;So as I said, if you have done everything correctly you should have a menu of all the objects in the array.&lt;br /&gt;&lt;br /&gt;So what next? Well let's take it up a notch and talk about associated arrays, as I said before these are arrays within arrays, so instead of a list of text separated by commas, this would be a list of lists separated by commas. What is the point of this you may ask? Well imagine you want to add other things to the menu, say for instance, you want to launch a website when you click on it. &lt;br /&gt;&lt;br /&gt;There are two parts of the associated array, the identifier and the value, for instance:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;myMenu = new Array(); or in this case myMenu = [:];&lt;/SPAN&gt;&lt;br /&gt;myMenu.push({name: &amp;quot;Star Wars&amp;quot;}); &lt;/P&gt;&lt;br /&gt;&lt;br /&gt;So what we have here is the beginning of our associated array, we have one entry with a &amp;quot;title&amp;quot; attribute that has a value of &amp;quot;Star Wars&amp;quot;. To access this value you would do so via:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;trace(myMenu[0].title); this would return &amp;quot;Star Wars&amp;quot;.&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;You can also assign values in the same way:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;myMenu[0].title = &amp;quot;Stargate Sg1&amp;quot;;&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;Now we don't just want titles for the menus we also want urls to coincide with them, to this we will add a second value to the array:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;myMenu[0].url = "http://www.starwars.com";&lt;/P&gt;&lt;br /&gt;&lt;br /&gt;We now have an associative array with two attributes title and url, so let's get to the meat of it, copy the following script:&lt;br /&gt;&lt;br /&gt;&lt;P class="code"&gt;myMenu = new Array();&lt;/SPAN&gt;&lt;br /&gt;myMenu.push({title: &amp;quot;Star Wars&amp;quot;, url: "http://www.starwars.com"});&lt;/SPAN&gt;&lt;br /&gt;myMenu.push({title: &amp;quot;Stargate&amp;quot;, url: "http://www.stargatesg1.com"});&lt;/SPAN&gt;&lt;br /&gt;myMenu.push({title: &amp;quot;Star Trek&amp;quot;, url: "http://www.startrek.com"});&lt;/SPAN&gt;&lt;br /&gt;myMenu.push({title: &amp;quot;Babylon 5&amp;quot;, url: "http://www2.warnerbros.com/babylon5/"});&lt;/SPAN&gt;&lt;br /&gt;myMenu.push({title: &amp;quot;Andromeda&amp;quot;, url: "http://www.andromedatv.com/"});&lt;/SPAN&gt;&lt;br /&gt;var x = 100;&lt;/SPAN&gt;&lt;br /&gt;var y = 100;&lt;/SPAN&gt;&lt;br /&gt;for(var i = 0; i &amp;lt; myMenu.length; i++) {&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;attachMovie(&amp;quot;menu&amp;quot;, &amp;quot;menu&amp;quot;+i, i+1);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;_root[&amp;quot;menu&amp;quot;+i].myText.text = myMenu[i].title;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;_root[&amp;quot;menu&amp;quot;+i].url = myMenu[i].url;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;_root[&amp;quot;menu&amp;quot;+i].myText.autoSize = &amp;quot;center&amp;quot;;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;_root[&amp;quot;menu&amp;quot;+i]._x = x;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;_root[&amp;quot;menu&amp;quot;+i]._y = y;&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;_root[&amp;quot;menu&amp;quot;+i].onRelease = function() {&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:30px"&gt;getURL(this.url);&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;}&lt;/SPAN&gt;&lt;br /&gt;&lt;SPAN style="margin:15px"&gt;y+=_root[&amp;quot;menu&amp;quot;+i]._height;&lt;/SPAN&gt;&lt;br /&gt;}&lt;/P&gt;&lt;br /&gt; &lt;br /&gt;The big difference here is that we are accessing the title attribute for the textfield and we are setting a variable inside the movieclip to the url attribute. This will be used to launch the url. There are other ways, more complicated ways to do this, you could always access the array on mouse click, but that may be more confusing later on.&lt;br /&gt;&lt;br /&gt;If everything went well you'll have a menu that will launch a series of websites on click. As you can see there is a foundation here to do even cooler and more useful things. Once you throw some loaded variables into the mix, via a text file or php &amp;amp;mySql the uses are unlimited. &lt;br /&gt;&lt;br /&gt;There you go, my very first tutorial, hopefully it did its job, I may update it at some point based on feedback and well editing. &lt;div class="blogger-post-footer"&gt;Copyright © 2005 JohnnyStorm.com&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.johnnystorm.com/flash/2004/08/array-of-this-and-array-of-that.php' title='An array of this and array of that...'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7836560&amp;postID=109210557774371436&amp;isPopup=true' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.johnnystorm.com/flash/johnnystorm.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/109210557774371436'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/109210557774371436'/><author><name>Johnny Storm</name><uri>http://www.blogger.com/profile/09388240165336990332</uri><email>noreply@blogger.com</email></author></entry><entry><id>tag:blogger.com,1999:blog-7836560.post-109149722678126104</id><published>2004-08-02T22:39:00.000-04:00</published><updated>2004-08-02T23:16:58.980-04:00</updated><title type='text'>...but were afraid to ask...</title><content type='html'>&lt;A HREF="http://www.amazon.com/exec/obidos/ASIN/1590593049/johnnystormco-20" target="_blank"&gt;&lt;IMG SRC="http://images.amazon.com/images/P/1590593049.01.MZZZZZZZ.jpg" border="0" alt="cover" hspace="3" vspace="3" align="left"&gt;&lt;/A&gt;&lt;br /&gt;&lt;br /&gt; So I finally decided to get off my ass and decided to start writing about some of the stuff I have been doing in Flash. Mainly I decided to start this Blog, because when I was doing research, finding information that would answer my questions was extremely difficult. So the idea here is to pass along some of what I've learned and to present articles which will appear in a google search so people don't have to go through all of the trouble I did while I learned what it is I did.&lt;br /&gt;&lt;br /&gt;Recently I started playing around with JSFL (JavaScript Flash), a scripting language similar to macros, which allows you to automate actions in Macromedia Flash MX 2004. It also allows you to extend the capabilities of Flash, creating commands, tools, behaviors, etc... JSFL is an incredible scripting language but almost impossible to figure out using online resources.&lt;br /&gt;&lt;br /&gt;So first off I would recommend the &lt;A HREF="http://www.amazon.com/exec/obidos/ASIN/1590593049/johnnystormco-20" target="_blank"&gt;&lt;B&gt;&lt;I&gt;Extending Macromedia Flash MX 2004: Complete Guide and Reference to JavaScript Flash&lt;/I&gt;&lt;/B&gt;&lt;/A&gt; book, you can even buy it through Amazon and help make me some money. *hint* *hint* also I have created a few extensions available for download, in them you can see examples of JSFL, the XML to UI, and flash interfaces. I plan to make the sources for all of these available, just be patient.&lt;br /&gt;&lt;br /&gt;So feel free to download the following extensions, they were developed for Macromedia Flash MX 2004 and requires &lt;A href="http://www.macromedia.com/exchange/em_download/" target="_blank"&gt;Macromedia Extension manager&lt;/A&gt; to use. There are four available:&lt;br /&gt;&lt;br /&gt;&lt;A href="http://www.johnnystorm.com/flash/downloads/JS_convert_symbol.zip"&gt;JS-Convert To Symbol&lt;/A&gt; This extension adds functionality to Flash. Its an extended version of the Flash interface which creates symbols. I added the ability to add instance names, automatically create layers, and name those layers.&lt;br /&gt;&lt;br /&gt;&lt;A href="http://www.johnnystorm.com/flash/downloads/JS_Nudge.zip"&gt;JS-Nudge&lt;/A&gt; This extension allows you to move selected items using inputed settings.&lt;br /&gt;&lt;br /&gt;&lt;A href="http://www.johnnystorm.com/flash/downloads/JS_createBox.zip"&gt;JS-Create Sized Rectangle&lt;/A&gt; This extension allows you to create rectangles using defined settings. You can define the width, height and the corner radius.&lt;br /&gt;&lt;br /&gt;&lt;A href="http://www.johnnystorm.com/flash/downloads/JS_change_case.zip"&gt;JS-Change Case&lt;/A&gt; This extension allows you to change the case of text.&lt;div class="blogger-post-footer"&gt;Copyright © 2005 JohnnyStorm.com&lt;/div&gt;</content><link rel='alternate' type='text/html' href='http://www.johnnystorm.com/flash/2004/08/but-were-afraid-to-ask.php' title='...but were afraid to ask...'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7836560&amp;postID=109149722678126104&amp;isPopup=true' title='0 Comments'/><link rel='replies' type='application/atom+xml' href='http://www.johnnystorm.com/flash/johnnystorm.xml' title='Post Comments'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/109149722678126104'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7836560/posts/default/109149722678126104'/><author><name>Johnny Storm</name><uri>http://www.blogger.com/profile/09388240165336990332</uri><email>noreply@blogger.com</email></author></entry></feed>