Reputation: 67
I'm trying to export data for sprite animation. I have several MovieClips in a stage and keyframes with different positons/angle to make an animation. When I try to write x,y data to a file I can't reach data outside of first frame.
function testWrite():void {
var fileRef:FileReference;
var txt:String;
var fr:int;
txt = "";
// 'Head' is the name one of MovieClips
for (fr = 0; fr < 4; fr++) {
txt += "frame: " + currentFrame + ", " + Head.x + "\n";
nextFrame();
Head.nextFrame();
}
fileRef = new FileReference();
fileRef.save(txt, "testExport.txt");
}
testWrite();
This is a function I'm using for it, but no matter if I use nextFrame() or gotoAndStop(x) it won't change frame. Both Head.x and Head.currentFrame stays the same.
Can anyone help me with this?
Upvotes: 0
Views: 24
Reputation: 67
Ok, I've solved it.
var txt:String = "";
stop();
function write():void {
txt += Head.x + "\n";
}
function writeOut(event:KeyboardEvent):void
{
var file:FileReference;
file = new FileReference();
file.save(txt, "testExport.txt");
}
function frame(e:Event):void {
if (currentFrame <= 3) {
write();
nextFrame();
}
}
this.addEventListener(Event.ENTER_FRAME, frame);
stage.addEventListener(KeyboardEvent.KEY_DOWN, writeOut);
Upvotes: 1