View Full Version : A challenge, perhaps can be done with Jsfl

11-18-2005, 11:30 AM
Dear Developers,
I am halfway into coding a mini-2d engine in flash, using a movie clip that holds around 430 images, every image in a seperate frame. The images are slices of a larger image, as in a grid.
I was wondering if there is any way to place images into a seperate keyframe dynamically ? Perhaps the question is can you create a keyframe dynamically ?
any help would be greatly appreciated, my fingers are going throught 430 images manually at the moment, I bet there is a better way.

12-09-2005, 01:11 PM
This is a just a fast hack to give you an idea of how to solve the problem.
What it dos is add a key frame for each item you have selected in the library (before running the script) and ads an item per frame (from your selection).

// Document Info
var _dom = fl.getDocumentDOM(); // Reference to the current open document
var _lib = _dom.library; // Reference to the current library
var _libItems = _lib.getSelectedItems(); // Array with the selected library items
var _timeline = _dom.getTimeline(); // Reference to the timline
var _itemCount = _libItems.length; // number of items to add.
var _x = 0; //Positioning x
var _y = 0; //Positioning y

for(var i = 0; i < _itemCount; i++)
_timeline.insertKeyframe (i);
_timeline.currentFrame = i;
_lib.addItemToDocument({x:_x, y:_y}, _libItems[i].name);


12-09-2005, 01:58 PM
Great stuff, I will try it, modify it, and post the working FLA.
Thanks for your time