<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:content="http://purl.org/rss/1.0/modules/content/">

    <channel>
    
    <title>Studio Koi Code Blog</title>
    <link>http://codeblog.studiokoi.com/share/code/index/</link>
    <description></description>
    <dc:language>en</dc:language>
    <dc:creator>info@studiokoi.com</dc:creator>
    <dc:rights>Copyright 2008</dc:rights>
    <dc:date>2008-08-26T01:35:01-05:00</dc:date>
    <admin:generatorAgent rdf:resource="http://www.pmachine.com/" />
    

    <item>
      <title>Making Anonymous Functions and Closures Work in ActionScript 2.0</title>
      <link>http://codeblog.studiokoi.com/share/site/making_anonymous_functions_and_closures_work_in_actionscript_20/</link>
      <guid>http://codeblog.studiokoi.com/share/site/making_anonymous_functions_and_closures_work_in_actionscript_20/#When:01:35:01Z</guid>
      <description>One of the most powerful idioms available in JavaScript is the anonymous function closure: e.g. (function(){})();. If you are unfamiliar with this, it simply creates an anonymous scope bubble that can be used to prevent automatic global variables, or trick JavaScript into allowing private variables. Unfortunately, this idiom isnt available in ActionScript 2.0. It simply doesnt work. (As of ActionScript 3.0, it works perfectly.)
 
This means that, on the surface, the only way to prevent time line variables from being constantly created is an init function of sorts. (ActionScript 2.0 has a pseudo global object which is the main time line of a movie level, and a totally global object named _global.) This also means that private variables are restricted to the creation of object classes. I personally get annoyed at times with classes in ActionScript. One of the things that has always bugged me with ActionScript 2.0 and the introduction of classes is that they are hard to make portable. (I work on no less than 3 computers in a single week, and 4&#45;5 when on business trips, so portability is paramount to my work.) Rather than being able to simply include the classes in the same folder as the flash working file (*.fla), you must specify where on the computer the includes are. This is just annoying if you work on the file on several different computers. There are a couple of ways to avoid naming the class include folder on each computer, but they are as much of a pain as the default method. Fortunately, there is a solution.

To reiterate, while this works in JavaScript and ActionScript 3.0, it will not in ActionScript 2.0:

&#40;function&#40;&#41;&#123;	//statements&#125;&#41;&#40;&#41;;&amp;nbsp;var myFunc = &#40;function&#40;&#41;&#123;	var hiddenVar = &amp;quot;hidden&amp;quot;;	return function&#40;&#41;	&#123;		return hiddenVar;	&#125;&#125;&#41;&#40;&#41;;hiddenVar		//undefinedmyFunc.hiddenVar; 	//undefinedmyFunc&#40;&#41;; 		//returns &amp;quot;hidden&amp;quot;

The good news about ActionScript 2.0 is that it retains the ability to pass anonymous functions as variables to another function. Like so:

var myArray = &#91;5,1,6,23,15&#93;;var sortedArray = myArray.sort&#40;function&#40;a, b&#41;&#123;	return a &#45; b;&#125;&#41;;trace&#40;sortedArray&#41;; //returns [1, 5, 6, 15, 23]

Knowing this, we can emulate anonymous function closures in ActionScipt 2.0. First we will create a global function that returns the function passed to it.
_global.closure = function&#40;f&#41;&#123;	return f;&#125;

To use it, you treat it the same as you would the parenteses in the javascript idiom:


closure&#40;function&#40;&#41;&#123;	//statements&#125;&#41;&#40;&#41;;

Changing the name to something shorter will make this more practical and the code a little cleaner.

_global.$ = function&#40;f&#41;&#123;	return f;&#125;&amp;nbsp;$&#40;function&#40;&#41;&#123;	//statements&#125;&#41;&#40;&#41;;

Given this new ability, we can now apply anonymous closures to our script without littering the time line object with useless variables. 

Lets use a hypothetical situation to illustrate how we might use the anonymous closure. In this script, we want to make 5 buttons that each need to trace their respective number when you click them. We could code each button individually, but that is messy and doesn&apos;t promote good code reuse. Instead, lets make a loop that makes all the buttons work, in addition to making it easier to add more buttons.

for &#40;var i = 1; i &amp;lt;= 5; i++&#41;&#123;	//for each button	this&#91;&amp;quot;click&amp;quot; + i + &amp;quot;_btn&amp;quot;&#93;.onPress = $&#40;function&#40;n&#41;&#123;		//return a function that has access to n via		// a closure		return function&#40;&#41;		&#123;			//trace the number passed to the parent closure			trace&#40;n&#41;;		&#125;	&#125;&#41;&#40;i&#41;; //pass in current loop iteration for caching&#125;

Now when you press click3_btn, it will trace &apos;3&apos; and click5_btn, &apos;5&apos;. In this way, we avoid creating useless variables inside each button, and we didn&apos;t have to create a singular use function.

Earlier I mentioned my slight distaste for how classes were implemented in ActionScript 2.0. Let me first caveat this statement by saying they are extremely useful and are wonderful for individuals or teams that have good version networks and servers. Just for myself and the smaller applications I write, I prefer portable objects. Lets see how we would write a singleton object with private variables and functions:

var bob = $&#40;function &#40;&#41;&#123;	//&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;	//private variables	var secret = &amp;quot;you found me&amp;quot;;	//&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;	//private functions	function compare&#40;a, b&#41;	&#123;		return a &amp;gt; b;	&#125;	//&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;	//constructor	var Bob = &#123;		//&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;		//public members/variables		works		:true,		getSecret	:function&#40;&#41;		&#123;			return secret;		&#125;,		getCompare	:function&#40;a, b&#41;		&#123;			return compare&#40;a, b&#41;;		&#125;	&#125;;	//&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;	//return object	return Bob;&#125;&#41;&#40;&#41;;//testtrace&#40;typeof bob&#41; 		//returns objecttrace&#40;bob.works&#41;;		//returns truetrace&#40;bob.getSecret&#40;&#41;&#41;;		//returns the string: you found metrace&#40;bob.secret&#41;;		//returns undefinedtrace&#40;bob.getCompare&#40;1, 2&#41;&#41;;	//returns falsetrace&#40;bob.compare&#40;1, 2&#41;&#41;;	//returns undefined function

As you can see with the tests, we have a singleton object with private functions and variables as well as public methods and members. With a little work, using the prototypal inheritance method, we can make this a reusable pseudo class:

var Bob = $&#40;function &#40;&#41;&#123;	//&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;	//private variables	var secret = &amp;quot;you found me&amp;quot;;	//&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;	//private functions	function compare&#40;a, b&#41;	&#123;		return a &amp;gt; b;	&#125;	//&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;	//constructor	var Bob = function &#40;&#41;	&#123;		//&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;		//public members/variables		this.works = true;	&#125;;	//&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;	//public methods	Bob.prototype.getSecret = function&#40;&#41;	&#123;		return secret;	&#125;;	Bob.prototype.getCompare = function&#40;a, b&#41;	&#123;		return compare&#40;a, b&#41;;	&#125;;	//&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;&#45;	//return constructor	return Bob;&#125;&#41;&#40;&#41;;//invokevar mybob = new Bob&#40;&#41;;//testtrace&#40;typeof Bob&#41;;		//returns functiontrace&#40;typeof mybob&#41;;		//returns object	trace&#40;mybob.works&#41;;		//returns truetrace&#40;mybob.getSecret&#40;&#41;&#41;;	//returns the string: you found metrace&#40;mybob.secret&#41;;		//returns undefinedtrace&#40;mybob.getCompare&#40;1, 2&#41;&#41;;	//returns falsetrace&#40;mybob.compare&#40;1, 2&#41;&#41;;	//returns undefined

So, with a single global function, we can bring the magic of anonymous function closures to ActionScript 2.0. Enjoy!</description>
      <dc:subject>Flash&#45;ActionScript</dc:subject>
      <dc:date>2008-08-26T01:35:01-05:00</dc:date>
    </item>

    <item>
      <title>Parsing a nested or name spaced object from a string in ECMAScript</title>
      <link>http://codeblog.studiokoi.com/share/site/parsing_a_nested_or_name_spaced_object_from_a_string_in_ecmascript/</link>
      <guid>http://codeblog.studiokoi.com/share/site/parsing_a_nested_or_name_spaced_object_from_a_string_in_ecmascript/#When:01:37:00Z</guid>
      <description>Often times when I am making dynamic scripts in Flash or JavaScript, I want to call an object method using a string. It may be a situation where I am stuck using fscommand (due to a customer request of a Flash version &amp;lt;8) or just writing script with script.

The problem that comes with this method is the advent of ActionScript 3 with Flash CS3/Flex 2 and the rising use in namespaces by JavaScript developers (myself included). Both encour a heavy usage of object methods instead of one&#45;off functions. Dynamically calling singleton functions is easy, you can just use subscript notation, e.g. object[&#8217;member/method&#8217;]. What you can&#8217;t do with this method is pass it any dot syntax and expect it to work e.g. object[&#8217;subobject.method&#8217;]. The subscript notation is only meant to work one level. So the previous example won&#8217;t work. In order to fix this issue and to make sending object methods/members in a single string a little easier, I wrote a function that takes a string and a base object (the default is the window object if no object reference is passed) and returns the method/member. (I know at this point that some will simply direct me to ECMAScript&#8217;s built in eval() function, but I personally avoid using it at all costs as it can have unintended, and unsecure results. I&#8217;ll let Stephen Chapmen tell you because this article is about something else.)



The function is executed somewhat simply by splitting the string at the dots and adding them as subscripts to one another in order. However, there are some other pieces to it that make it a little more friendly to mistakes and general usage.


function parseNameSpace&#40;s , o&#41;&#123;	//default to window if no object sent	var w = o || window, a;		//reutrn if parsing not necessary or not a method	if &#40; s.indexOf&#40;&apos;.&apos;&#41; == &#45;1 &#41;	&#123;		return &#40;typeof w&#91;s&#93; === &amp;quot;undefined&amp;quot;&#41; ? false : w&#91;s&#93; ;	&#125;		//make array for looping through	a = s.split&#40;&apos;.&apos;&#41;;		//run though members / methods	for &#40;var i = 0,l = a.length; i &amp;lt; l; i++&#41;	&#123;		w = w&#91;a&#91;i&#93;&#93;;	&#125;		//return object if it is valid, or return false	return &#40;typeof w === &amp;quot;undefined&amp;quot;&#41; ? false : w ;&#125;

The function takes two variables, first the string that you want to parse to an object member, and the second optional base object. The first variable w looks for the object &#8220;o&#8221; and if not found, defaults to &#8220;window&#8221; which is the default parent object of browser based JavaScript. (You could change it to &#8220;this&#8221; and it would work in ActionScript as well). Second, we check to see if the passed string has any dots in it. If not, we check to see if it is a regular function. This way you could use this function as a catch all even if you aren&#8217;t always passing nested functions. If it isnt a member of the window object, false is returned. If it does have dots, we split them into an array, and loop through it, making each a member of the previous using the subscript notation. Finally we check to see if the result is valid, and we return false if it isn&#8217;t, or a reference to the object itself.

Let&#8217;s take a look at a simple way to use it. Lets say we have an object literal with a subobject, and a method inside that.


var obj = &#123;	innerObj: &#123;		func: function&#40;&#41;&#123;			return &amp;quot;worked&amp;quot;;		&#125;	&#125;&#125;

Then we retrieve it via string with the function.


var objFunc = parseNameSpace&#40;&amp;quot;obj.innerObj.func&amp;quot;&#41;;alert&#40;objFunc&#40;&#41;&#41;; //shows &amp;quot;worked&amp;quot;

This should work most places as long as you are mindful of function scope. Enjoy!</description>
      <dc:subject>JavaScript</dc:subject>
      <dc:date>2008-01-10T01:37:00-05:00</dc:date>
    </item>

    <item>
      <title>Create Right Click Menus to Test AIR Files (Win/Mac)</title>
      <link>http://codeblog.studiokoi.com/share/site/create_right_click_menus_to_test_air_files_win_mac/</link>
      <guid>http://codeblog.studiokoi.com/share/site/create_right_click_menus_to_test_air_files_win_mac/#When:05:18:02Z</guid>
      <description>At the beginning of this year, when I first heard about A.I.R. I was excited to learn more about it and see what I could do with it. What really jumpstarted my interest was a trip to Cincinnati, OH to the Adobe onAIR Bus Tour. At this point I am full steam excited about working with AIR.

I work on a Windows machine at work and Mac at home, so I am also excited to see cross platform development. One thing that is a little wonky about AIR is the way that you test your applications. Since AIR is built with an SDK instead of a builder application, such as Flash, you have you use the terminal to launch the SDK. So I came up with methods for OS X and Windows XP to use right&#45;click contextual menus to test AIR applications. I will first note that you can use Aptana, Flex 3, Flash CS3, and Dreamweaver CS3 to test your AIR apps, but i thought i would make something for the hardcore coders. Though, I personally use all the aforementioned for AIR.

I will assume you have already installed the SDK on either system.

Windows XP: [skip to mac version]

In Windows XP, you can customize your right&#45;click menus for any filetype with the &apos;folder options&apos; panel. First, navigate to control panel, then folder options. Navigate to XML (It will be close to the bottom.).



If the button says &apos;Restore&apos; where you expect it to say &apos;Advanced&apos;, it is because you have changed the Windows default opening program for the xml file type. Click &apos;Restore&apos; first then you can click &apos;Advanced&apos;. (When you are finished, you can change the opening program back when you are finished, the menu will still stick.)

Next, click the &apos;edit&apos; button and we will create a new contextual command. You will need the full path of the location of your AIR SDK. For this example, I will use mine:

C:Program FilesAdobeAIR SDKbinadl.exe

This will application field in quotes, followed by &quot;%1&quot;. This will notate that you are opening the file right&#45;clicked with this program. (This works on most other windows programs as well.) Then give it a name you can remember. This is how it will show up in the contextual menu. Just replace my AIR bin location with yours.

&quot;C:Program FilesAdobeAIR SDKbinadl.exe&quot; &quot;%1&quot;



Now click OK and you should see your command in the window:



Now you can right&#45;click your AIR application.xml and test them right from the Windows file explorer:



The CMD prompt will open, then your air file should open. The CMD prompt will be your error output window.



&amp;nbsp;
OS X:

The Mac version will be somewhat similar, but we will use Automator to do the function. This means you will need at least OS X 10.4 for this tutorial.

Open Automator, and go to &apos;Finder&apos; in the Library menu, under Applications. Drag &apos;Get Selected Finder Items&apos; to the work space.



Next, go to &apos;Automator&apos; in the Library menu, and drag &apos;Run AppleScript&apos; to the work space under &apos;Get Selected Finder Items&apos;.



For the Applescript, I had a little help from Mac OS X Hints. You will need the directory for your Adobe AIR SDK. Mine is:

/Applications/Adobe AIR SDK/bin/adl

For this one, I will give the code to you. Paste this into the Applescript window and replace my AIR Adl location with yours:

&amp;nbsp;on run &#123;input, parameters&#125;	tell application &amp;quot;Terminal&amp;quot;		activate		if &#40;the &#40;count of the window&#41; = 0&#41; or ¬			&#40;the busy of window 1 = true&#41; then			tell application &amp;quot;System Events&amp;quot;				keystroke &amp;quot;n&amp;quot; using command down			end tell		end if		do script &amp;quot;&apos;/Applications/Adobe AIR SDK/bin/adl&apos; &amp;quot;&amp;quot; &amp;amp; &#40;POSIX path of ¬			&#40;input as string&#41;&#41; &amp;amp; &amp;quot;&amp;quot;&amp;quot; in window 1	end tell	return inputend run&amp;nbsp;

Next, we will save this as a Plug&#45;in. Under the File menu, select &apos;Save As Plug&#45;in..&apos;. Then select finder as the application and give it a name you can remember:




Now you can just right&#45;click your AIR application.xml, hover over Automater, and choose your new workflow to preview AIR projects!



Enjoy!</description>
      <dc:subject>AIR</dc:subject>
      <dc:date>2007-08-22T05:18:02-05:00</dc:date>
    </item>

    <item>
      <title>Expression engine 1.6 Preview and Rick Ellis Birthday Contest</title>
      <link>http://codeblog.studiokoi.com/share/site/expression_engine_16_preview_and_rick_ellis_birthday_contest/</link>
      <guid>http://codeblog.studiokoi.com/share/site/expression_engine_16_preview_and_rick_ellis_birthday_contest/#When:04:14:00Z</guid>
      <description>So Expression Engine is previewing version 1.6 (filled with LOADS of new features) and it is also EE CEO Rick Ellis&apos; Birthday. To celebrate this and some new software, they are having a photoshop contest that ends noon Tuesday June 19th, 2007. Check out the forums here for the other submissions. Here is the original blog post.

Without further adieu here are my entries.


View Larger

 
View Larger


View Larger



View Larger</description>
      <dc:subject>ExpressionEngine</dc:subject>
      <dc:date>2007-06-19T04:14:00-05:00</dc:date>
    </item>

    <item>
      <title>Import classes and Multiple ActionScript layers in Flash</title>
      <link>http://codeblog.studiokoi.com/share/site/import_classes_and_multiple_actionscript_layers_in_flash/</link>
      <guid>http://codeblog.studiokoi.com/share/site/import_classes_and_multiple_actionscript_layers_in_flash/#When:02:11:00Z</guid>
      <description>At work I am making a new Flash interface for a project, and my goal this time around was to make as many global functions out of repetitive ones as possible so we could save development time.

As I began writing and testing Prototype class extensions and global functions, I noticed something I had not run into before with flash. If Import classes on one ActionScript layer, and call it on another Actions layer, or even the next frame, it produces an ActionScript error.

Normally, I put all actions and functions on one layer and have no keyframes unless they are inside other MovieClips, or I need to animate something to audio cues. With this current project, there was going to be so much ActionScript, I decided to do more than one Actions layer so I could keep everything straight. Never having a reason to do this until now, I was not prepared for some of the problems I ran into. First and foremost being that: If import a class on one Actions layer, and I create a new class object from that group on another layer, I get a syntax error.

Here is a quick example. I have a MovieClip named &#8220;box1&#8221; and I am going to tween it with the Tween class. normally I would just put it all on the same layer like this:





import mx.transitions.Tween;import mx.transitions.easing.*;var boxTween:Tween = new Tween&#40;box1, &amp;quot;_x&amp;quot;, Regular.easeOut, box1._x, box1._x+300, 1, true&#41;;

This works perfectly and makes the box move across the screen on load. When I ran into the error was when I decided that I wanted all imports on one actions layer and the object on another. Like so:




I expected it to work just the same, as I have My publish settings set to ActionScript 2.0, top down, and Flash 8. Instead, I was presented with a nice error.




The problem is replicated also by putting the new Tween object in the following frame. Effectively, any frame that ISN&#8217;T the one I imported the class into. This strikes me as totally odd, as functions endure over frames and from layer to layer. I also tested this with other import classes besides the Tween class. I had the same issues with the Alert class and BitmapData class.

For now, the simple solution I came up with was making a function in the same frame/layer as the import classes that I would simply call elsewhere when I needed the tween to happen. This of course makes no sense to me at all, but it works perfectly.


import mx.transitions.Tween;import mx.transitions.easing.*;function tweenIt&#40;&#41; &#123;	var boxTween:Tween = new Tween&#40;box1, &amp;quot;_x&amp;quot;, Regular.easeOut, box1._x, box1._x+300, 1, true&#41;;&#125;

Calling this function in other frames and layers has worked so far, and has more than solved my problem. If you are using multiple tweens, or classes, you could use passthrough variables to be able to make the function usable in other situations.


import mx.transitions.Tween;import mx.transitions.easing.*;function tweenIt&#40;mc:MovieClip&#41;:Void &#123;	mc.boxTween = new Tween&#40;mc, &amp;quot;_x&amp;quot;, Regular.easeOut, mc._x, mc._x+300, 1, true&#41;;&#125;tweenIt&#40;box1&#41;

If I found out any more info as to why this is a problem, I will post it here. If anyone else has some insight, please leave me a comment.</description>
      <dc:subject>Flash&#45;ActionScript</dc:subject>
      <dc:date>2007-05-24T02:11:00-05:00</dc:date>
    </item>

    <item>
      <title>Dreamweaver Mass Find Replace Extension</title>
      <link>http://codeblog.studiokoi.com/share/site/dreamweaver_mass_find_replace_extension/</link>
      <guid>http://codeblog.studiokoi.com/share/site/dreamweaver_mass_find_replace_extension/#When:03:46:00Z</guid>
      <description>At work I work with a lot of local files, and repetitive file groups. Meaning, I might have 30 folders all with the same CSS file or JavaScript file. The trouble I run into with using a lot of the same files is changing them, then having to copy/paste the file a gillion times. It gets really old. (To answer your immediate question as to why I don&apos;t just use one file outside of all the folders; I have to send each folder as a separate package to the client because the server they go on handles them as single entities. This however is beside the point of today&apos;s post, because you can use this in many situations.)

I work on a corporate network, so i can only install approved programs on my work computer. This keeps me from using my preferred win32 text editor. However, since I work with Flash a lot, I also have DreamWeaver, which is an acceptable text editor in a pinch (as long as you never EVER use the WYSIWYG window).

After using DreamWeaver a while, I&apos;ve found that it does have a few very useful features. For instance, DreamWeaver has a lot of functions built into the api that can access the file system. These can be utilized within extensions; which brings me to today&apos;s goodie. The DreamWeaver Mass Find Replace extension.

I built this because of all the time I was wasting every time I needed to make changes to a file that was used multiple times. The nice part about DreamWeaver&apos;s access to the file system, is that it isn&apos;t restricted to just DreamWeaver file associations, so you can use this to replace any type of writable file. I use it for Swfs all the time.

Here is an example of how it works:

Open the extension and choose a master file (meaning, the file you want to replace all similarly named files with)
Choose the folder (and all sub folders) where you want to Find all files with the same name as the file you chose, and Replace them all with the chosen file.
Click OK.



That&apos;s it. You&apos;re done! This is a very simple, but powerful tool, so be careful using it. It overwrites all files with the same name as the replace file without warning.</description>
      <dc:subject>Extensions</dc:subject>
      <dc:date>2007-05-21T03:46:00-05:00</dc:date>
    </item>

    <item>
      <title>Moving away from the _root</title>
      <link>http://codeblog.studiokoi.com/share/site/moving_away_from_the_root/</link>
      <guid>http://codeblog.studiokoi.com/share/site/moving_away_from_the_root/#When:06:08:01Z</guid>
      <description>When working with multiple, nested MovieClips, or dynamic variables, sometimes you need your ActionScript to refer out to other MovieClips, or the main timeline of the swf file. When I was first teaching myself ActionScript, I learned to use _root to reference outside of functions or MovieClips.

It is this point in my learning that see how wrong I was to rely on _root for every outside&#45;the&#45;MovieClip function.

First lets look at how _root is wrongly commonly used:

button1_btn.onPress = function&#40;&#41;&#123;	_root.variableValue = 55	_root&#91;&amp;quot;myDynamicVariable&amp;quot;+1&#93;._visible = false&#125;

Let&apos;s assume that this button code is on the main timeline. First of all, if &apos;variableValue&apos; is on the maine timeline, and so is this button function, then you do not need to reference _root. When you call a function or variable inside of a function, Flash assumes already that you are referring to the timeline the parent function is in.

However, the dynamic variable on the second line poses a different problem. Most of the time, if you were going to do a dynamic variable without using _root, you would simply use &apos;this&apos;. Like so:

this&#91;&amp;quot;myDynamicVariable&amp;quot;+1&#93;._visible = false

Using &apos;this&apos; should be treated with as much caution as _root. Whenever you say &apos;this&apos; you mean the entity you are currently in. So, if you are writing a regular function, &apos;this&apos; refers to the main timeline, because the function is in the main timeline. This principle is implicit.

To illustrate, lets use the previous button example coded on the timeline and replace _root with &apos;this&apos;:

button1_btn.onPress = function&#40;&#41;&#123;	this.variableValue = 55	this&#91;&amp;quot;myDynamicVariable&amp;quot;+1&#93;._visible = false&#125;

First things first, this doesn&apos;t work (and this is what turns people to using _root). What confuses many people is why this works on the main timeline, inside regular functions, but not in this instance. When you write a button function like this, you are making a references to an event, onPress , given by the object button1_btn. So &apos;this&apos; refers to button1_btn and not the main timeline. To clarify, using &apos;this&apos; inside of a timeline written button function refers to the button, calling a variable or function works as it would inside a normal function.

In many places where you might use _root, you can also use _parent, which is one MovieClip out of where you are (_parent is stackable to go out as many times as you need). For the button code, by itself, it still wont work. 

button1_btn.onPress = function&#40;&#41;&#123;	_parent&#91;&amp;quot;myDynamicVariable&amp;quot;+1&#93;._visible = false&#125;

This function would refer to the parent of the timeline the function is in. Because as we just learned, if &apos;this&apos; isn&apos;t referred, the button function is treated as a normal timeline function. So to get the function to work without using _root, we need to combine the two.

button1_btn.onPress = function&#40;&#41;&#123;	this._parent&#91;&amp;quot;myDynamicVariable&amp;quot;+1&#93;._visible = false&#125;

This works because &apos;this&apos; refers to button1_btn, therefore _parent refers to button1_btn&apos;s parent, the timeline this function is in.

Now for the advanced solution.

Using this._parent could get a little redundant after a while, and would cease to work if you moved the function to a different MovieClip. The best solution i have found is to make a variable that is data&#45;typed as a MovieClip and refer it to the timeline you are wanting to reference.

var home:MovieClip = this

What this says is that anytime you call home you will be referring to the timeline. (You can also refer to other timelines by replacing &apos;this&apos; with _parent, MovieClip or MovieClip.ChildClip).

Let&apos;s see how it would work:

&amp;nbsp;var home:MovieClip = thisbutton1_btn.onPress = function&#40;&#41;&#123;	home&#91;&amp;quot;myDynamicVariable&amp;quot;+1&#93;._visible = false&#125;

So now you have no excuse what&#45;so&#45;ever to use _root unless you really REALLY mean it!</description>
      <dc:subject>Flash&#45;ActionScript</dc:subject>
      <dc:date>2007-05-07T06:08:01-05:00</dc:date>
    </item>

    <item>
      <title>Batch Publish Flash Plug&#45;in</title>
      <link>http://codeblog.studiokoi.com/share/site/batch_publish_flash_plug_in/</link>
      <guid>http://codeblog.studiokoi.com/share/site/batch_publish_flash_plug_in/#When:20:39:01Z</guid>
      <description>Lately I have been working on a project that has a lot of flash files that use external ActionScript files for similar functions. It helps that they have many of the functions external because you can make mass changes with one file.

For those not in the know, here is how you include an external ActionScript file:


#include &amp;quot;filepath/actionscript.as&amp;quot;

The downside of using external AS and changing it is that you have to publish every file that includes that script file. This gets to be a little tedious when doing it file by file, so I made a flash extension that will publish all files in a folder.

To use the extension, install the mxp, then restart flash. Under the commands menu, there will be a command called &#8220;BatchPublish&#8221;. Run it, then select the folder that contains your flash files that need to be published. This version does not publish files in sub&#45;folders, but I am working on that for the next version, which will also include a GUI.

Update 5&#45;16&#45;07: I made version 2 finally. Now it has a GUI and some better options for output. You can publish all FLAs in a directory (and all subdirectories within) to the folder of choice. Force Swf only, and save and compact on close.</description>
      <dc:subject>Extensions</dc:subject>
      <dc:date>2007-04-26T20:39:01-05:00</dc:date>
    </item>

    <item>
      <title>Playing Flash FLVs without the Flash Player</title>
      <link>http://codeblog.studiokoi.com/share/site/playing_flash_flvs_without_the_flash_player/</link>
      <guid>http://codeblog.studiokoi.com/share/site/playing_flash_flvs_without_the_flash_player/#When:22:12:01Z</guid>
      <description>Due to the rise in internet video, and the need for it to be easily played on different operatiing systems and browers, Flash FLVs have taken off in the last two years. In light of this phenomenon, I find myself more and more downloading FLV videos for later viewng.

The most common places you will see FLV video for the masses is of course YouTube and Google Video, but many more sites are catching on. Flash has 98% browser penetration, and works on Mac, PC, and Linux, so it is a no brainer.

So what do you do with all those downloaded FLVs? You could open Flash and make a quick SWF file to play it, but that would be annoying and wouldn&apos;t work at all for people without Flash Professional installed. The direct problem with FLVs is that they dont play in Windows Media Player or Linux&apos;s Totem player. If you are on a Mac, you can install Perian and Quicktime will play the FLVs You could convert them to normal video files with some free video conversion programs such as Media Coder for Windows or FFMpegX for Mac. You could also use a free online converter such as Media Convert.

However, all that could add up to time wasted. The solution I found to be the most pleasing and easy was to download the free VLC Media Player for Windows/Mac/Linux/Unix. VLC plays FLV files natively and vry clearly. The controlls are quite plain but intuitive, and it supports playlists for viewing multiple FLVs. Best of all, it also plays pretty much any other file format thrown at it. I have used it as my primary video player on Mac and PC for 2 years and have been very satisfied. I don&apos;t even open Windows Media Player anymore. VLC plays all Windows Media files out of the box. Plus, if you are on a heavily regulated network at work, or do not have install privelages, there is a no&#45;install thumbdrive version of VLC with all the same capabilities as the full install version!</description>
      <dc:subject>Flash&#45;ActionScript</dc:subject>
      <dc:date>2007-04-22T22:12:01-05:00</dc:date>
    </item>

    <item>
      <title>Disable &#8220;Click&#45;Through&#8221; on MovieClips in Flash</title>
      <link>http://codeblog.studiokoi.com/share/site/disable_click_through_on_movieclips_in_flash/</link>
      <guid>http://codeblog.studiokoi.com/share/site/disable_click_through_on_movieclips_in_flash/#When:06:48:00Z</guid>
      <description>At work we use a lot of fake pop&#45;ups in Flash to show information. Everything generally works very well, until we discovered that you can click buttons in flash that are underneath a movieclip or a graphic.

The first solution was to hard code disabling of MovieClips/buttons like so:

button1_btn.onPress = function&#40;&#41;&#123;     popUp_mc._visible = true;     button1._btn.enabled = false;     button2._btn.enabled = false;&#125;&amp;nbsp;popUpClose_btn.onPress = function&#40;&#41;&#123;     popUp_mc._visible = false;     button1._btn.enabled = true;     button2._btn.enabled = true;&#125;

As you can see, this is VERY messy and impractical, as every time you add another button, you have to edit the code for the pop&#45;up buttons to enable/disable it when shown.

One thing we did know up front is that if you put two buttons on top of one another, the one with the highest depth will over take the one below it. Therefore only the top one get&apos;s clicked. (The same is not true for rollovers, both items recieve a rollover event, but not click.)

So, we tried using a giant button below the background of the fake pop&#45;up movieclip. It worked in the fact that we could not click buttons below the MovieClip. What was not cool was the hand cursor that showed up over the entire MovieClip because we had a button in the background. Fortunatly, we discovered a built in ActionScript function that disables the hand cursor:

hiddenButton_btn.useHandCursor = false;

It solved our problem completely! Now we could have pop&#45;ups and not be able to click buttons underneath them while they were open.

Here is an example file.</description>
      <dc:subject>Flash&#45;ActionScript</dc:subject>
      <dc:date>2007-04-22T06:48:00-05:00</dc:date>
    </item>

    
    </channel>
</rss>