Email Updates RSS Subscribe
Line

This blog is created and maintained by the technical team at Hook in an effort to preserve and share the insights and experience gained during the research and testing phases of our development process. Often, much of this information is lost or hidden once a project is completed. These articles aim to revisit, expand and/or review the concepts that seem worth exploring further. The site also serves as a platform for releasing tools developed internally to help streamline ad development.

Launch
Line

Hook is a digital production company that develops interactive content for industry leading agencies and their brands. For more information visit www.byhook.com.

Line

Utility – ReNamer (Flash Extension Panel)

Line
Posted on December 1st, 2009 by Jake
Line

The flash timeline, love it or hate it, you must admit that it will be with us for the foreseeable future. One of the quirks/issues/features of the timeline is that if you have the same instance on two separate keyframes on the same layer, they are really two different instances of the same library object. To over come this flash maps that object to the same reference in memory, assuming the instance is named the same on the two keys. Which means that its imperative that the naming is consistent and correct. Being as most Flash designers need to deal with this daily, we decided to make it a touch easier to get right.

Download Hook ReNamer

ReNamerImage

This panel lets you rename groups of instances by layer, object selection, or selected frames. Simply pick the type of renaming you want, fill in the new name, and click Submit. That’s it done and done.

If you have managed to read the Outliner post you will have some idea of how to interact with JSFL and the Flash IDE. This post will focus a bit more on the ActionScript side of the panel building process.

In order to call a function from within a JSFL file you can use the MMExecute command in ActionScript. It looks a bit like this:

MMExecute('fl.runScript(fl.configURI + file,functionName,"stuff1","stuff2")');

That ends up being a lot to type all the time, so we made a JSFLObj class to help with some of the convenience. To execute a JSFL function we made this method:

public function runScript(file:String, functionName:String, ...args):String
	{//runScript
		var execString:String = "fl.runScript((fl.configURI+\"" + file +"\"), \"" + functionName + "\"";
		var result:String;
 
		for (var i:int = 0; i < args.length; i++)
		{//tack on args
			execString += ", \"" + args[i] + "\"";
		}//tack on args
 
		execString += ")";
 
		//MMExecute('fl.runScript(fl.configURI + file,functionName,"stuff1","stuff2")');
		result = MMExecute(execString);
		return result;
	}//runScript

It can be called like this:

response = String(_jsfl.runScript("Hook/ReNamer/ReNamer.jsfl", "renameObjectsInSelectedLayers", _renameInputText.text));

We also now have a way of sending a string to the JSFL that will be turned into an object on the JSFL side of things. If you have seen the Outliner panel, this is the code that is executed to “reference” an object from the grid:

public function gridSelectionToString(list:Array):String
{//gridSelectionToString
	var result:String = "[";
	var count:int = 0;
 
	for each (var obj:Object in list)
	{//parse obj
		var curObj:Object = { };
 
		result += "{";
		result += ("\\\"name\\\":\\\"" + obj.Name + "\\\",");
		result += ("\\\"id\\\":\\\"" + obj.ID + "\\\",");
		result += ("\\\"locked\\\":\\\"" + obj.Locked + "\\\",");
		result += ("\\\"type\\\":\\\"" + obj.Type + "\\\",");
		result += ("\\\"scaleX\\\":\\\"" + obj.scaleX + "\\\",");
		result += ("\\\"scaleY\\\":\\\"" + obj.scaleY + "\\\",");
		result += ("\\\"x\\\":\\\"" + obj.x + "\\\",");
		result += ("\\\"y\\\":\\\"" + obj.y + "\\\",");
		result += ("\\\"rotation\\\":\\\"" + obj.rotation + "\\\",");
		result += ("\\\"layer\\\":\\\"" + obj.Layer + "\\\"");
		result += "}";
 
		//add comma
		if (count < list.length-1)
		{//not last
			result += ",";
		}//not last
 
		count++;
	}//parse obj
 
	result += "]";
 
	return result;
}//gridSelectionToString

Thats about it for the ReNamer panel. Hopefully this helps some of you guys out there. As always if you have any issues or success stories, please post them in the comments below.

Also below, you will find installation and usage instructions.

Instructions

A renaming utility to help keep your instance names straight across keyframes.

To install, save the .mxp file from the link below, and either double click on the .mxp or select File -> Install Extension in the Adobe Extension Manager. Finally restart Flash if you had it open during the install.

To use, simply select a method from the drop down list, type in a new instance name, and click the “Submit” button.

This panel is fairly stable, but if you find a bug, please let us know in the comments below!

Enjoy!

Download Hook ReNamer

This product is licensed under GPLv3.

Line
2 Responses to “Utility – ReNamer (Flash Extension Panel)”
  1. [...] he flash timeline, love it or hate it, you must admit that it will be with us for the foreseeable future. One of the quirks/issues/features of the timeline is that if you have the same instance on two separate keyframes on the same layer, they are really two different instances of the same library object. To over come this flash maps that object to the same reference in memory, assuming the instance is named the same on the two keys. Which means that its imperative that the naming is consistent and correct. Being as most Flash designers need to deal with this daily, we decided to make it a touch easier to get right. Download Hook ReNamer Full Article here [...]

  2. [...] If you are interested in seeing how some of this flash panel stuff is done, please check out our other posts on the subject: Hook Outliner and Hook ReNamer [...]


Leave a Reply

*

Line
Line
Pony