JSFL出口“指南”动画

发布于 2024-12-21 12:41:57 字数 2144 浏览 3 评论 0原文

我需要将 FLA 中的时间轴动画转换为 AS3 代码(可能通过 XML)。问题在于实际上有数百个层和数千个帧。

虽然我了解 JSFL 的结构,但我无法通过循环进入时间线 -> 图层 -> 帧来找到“引导”动画。使用 curFrame.isMotionObject() 始终为 false。

这是我正在尝试做的事情的示例:

/* Gets all motions in all motion objects and exports to a file. */
fl.outputPanel.clear();

//store max layers/frames
var fcnt = fl.getDocumentDOM().getTimeline().frameCount;
var lcnt = fl.getDocumentDOM().getTimeline().layerCount;
fl.trace( "fl.getDocumentDOM().getTimeline().frameCount = " + fcnt );
fl.trace( "fl.getDocumentDOM().getTimeline().layerCount = " + lcnt );

//store pre-run layers/frames:
var origFr = fl.getDocumentDOM().getTimeline().currentFrame;
var origLyr = fl.getDocumentDOM().getTimeline().currentLayer;
fl.trace( "fl.getDocumentDOM().getTimeline().currentFrame = " + origFr );
fl.trace( "fl.getDocumentDOM().getTimeline().currentLayer = " + origLyr );

var totout = 0;
var curFrm;
var curl = origLyr;
var curf = origFr; 
var outstr = "";

for (curf = 0; curf < fcnt; curf++)
{
    // have the IDE go into the current frame:
    fl.getDocumentDOM().getTimeline().currentFrame = curf;

    // removed to test one layer only
    //for (curl = 0; curl < lcnt; curl = lcnt) // curl++) // curl = lcnt)
    //{

        // have the IDE go into the current layer:
        fl.getDocumentDOM().getTimeline().currentLayer = curl;

        if(curf > fl.getDocumentDOM().getTimeline().layers[curl].frames.length)
            break;

        curFrm = fl.getDocumentDOM().getTimeline().layers[curl].frames[curf];

        //this is always false. . . why?
        if (
            curFrm.isMotionObject() 
            //&& curFrm.hasMotionPath()
        ){
            totout++;
            //curFrm.selectMotionPath(true);
        }
        else{
            outstr += "There is no motion path\n";
        }

        //for testing:
        break;
    //}
    //for testing:
    //break;
}

//reset layers/frames back to pre-run status:
fl.getDocumentDOM().getTimeline().currentFrame = origFr;
fl.getDocumentDOM().getTimeline().currentLayer = origLyr;

fl.trace(outstr);
fl.trace("totout = " + totout);

I need to convert timeline animations in a FLA into AS3 code (through XML, probably). The problem is that there are literally hundreds of layers and thousands of frames.

Though I understand JSFL's structure, I am cannot find the "guides" animations by looping down into the timeline->layer->frame. Using curFrame.isMotionObject() is always false.

Here is a sample of what I am trying to do:

/* Gets all motions in all motion objects and exports to a file. */
fl.outputPanel.clear();

//store max layers/frames
var fcnt = fl.getDocumentDOM().getTimeline().frameCount;
var lcnt = fl.getDocumentDOM().getTimeline().layerCount;
fl.trace( "fl.getDocumentDOM().getTimeline().frameCount = " + fcnt );
fl.trace( "fl.getDocumentDOM().getTimeline().layerCount = " + lcnt );

//store pre-run layers/frames:
var origFr = fl.getDocumentDOM().getTimeline().currentFrame;
var origLyr = fl.getDocumentDOM().getTimeline().currentLayer;
fl.trace( "fl.getDocumentDOM().getTimeline().currentFrame = " + origFr );
fl.trace( "fl.getDocumentDOM().getTimeline().currentLayer = " + origLyr );

var totout = 0;
var curFrm;
var curl = origLyr;
var curf = origFr; 
var outstr = "";

for (curf = 0; curf < fcnt; curf++)
{
    // have the IDE go into the current frame:
    fl.getDocumentDOM().getTimeline().currentFrame = curf;

    // removed to test one layer only
    //for (curl = 0; curl < lcnt; curl = lcnt) // curl++) // curl = lcnt)
    //{

        // have the IDE go into the current layer:
        fl.getDocumentDOM().getTimeline().currentLayer = curl;

        if(curf > fl.getDocumentDOM().getTimeline().layers[curl].frames.length)
            break;

        curFrm = fl.getDocumentDOM().getTimeline().layers[curl].frames[curf];

        //this is always false. . . why?
        if (
            curFrm.isMotionObject() 
            //&& curFrm.hasMotionPath()
        ){
            totout++;
            //curFrm.selectMotionPath(true);
        }
        else{
            outstr += "There is no motion path\n";
        }

        //for testing:
        break;
    //}
    //for testing:
    //break;
}

//reset layers/frames back to pre-run status:
fl.getDocumentDOM().getTimeline().currentFrame = origFr;
fl.getDocumentDOM().getTimeline().currentLayer = origLyr;

fl.trace(outstr);
fl.trace("totout = " + totout);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨巷深深 2024-12-28 12:41:57

您可以使用“导出运动 XML”命令,您可以通过以下方式从 jsfl 调用该命令:

fl.runScript(fl.configURI + 'Javascript/MotionXML.jsfl', 'exportMotionXML');

据我所知,经典 Tween XML 格式与 补间动画 XML 格式。 Motion XML 功能非常方便,但未得到充分利用。
您也可以使用 copyMotionXML 并在 JSFL 中处理 XML,因为 JS 引擎支持 E4X

或者,如果您对 fl.motion 包中,您可以执行以下操作:

fl.runScript(fl.configURI + 'Javascript/MotionXML.jsfl', 'copyMotionAsAS3');

请注意,默认补间类比其他补间引擎慢,例如 TweenLite,并且您可能还需要在补间持续时间内使用计时器来计算补间何时完成后,您就可以再次获得对补间对象的动作脚本访问权限。

我在为 AudiA8 网站工作时使用了一点 MotionXML 功能,我们必须这样做与 The Mill 的一些漂亮渲染相匹配,我写了一个 使用此功能将 Mocha 关键帧导入到 Flash 时间轴。

You can use the Export Motion XML command, which you can call from jsfl via:

fl.runScript(fl.configURI + 'Javascript/MotionXML.jsfl', 'exportMotionXML');

As far as I remember the Classic Tween XML format is different from the Motion Tween XML format. The Motion XML features is quite handy and underused.
You can use copyMotionXML as well and handle the XML in JSFL as the JS engine supports E4X.

Alternatively, if you're happy with the Animator/AnimatorFactory classes from the fl.motion package, you can do this:

fl.runScript(fl.configURI + 'Javascript/MotionXML.jsfl', 'copyMotionAsAS3');

Note that the default tween classes are slower than other tween engines, like TweenLite, and you also might need to use a timer for the duration of the tween to work out when a tween is finished, so you can gain actionscript access to the tweened object again.

I've used the MotionXML feature a bit at work for the AudiA8 site we did as we had to match some interactivity over some beautiful renders from The Mill and I wrote an importer for Mocha Keyframes to Flash timeline using this feature.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文