在AIR 3.9的Flex Degrafa的Bezier样条线 [英] Flex Degrafa's bezier spline under AIR 3.9

查看:199
本文介绍了在AIR 3.9的Flex Degrafa的Bezier样条线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一直用Degrafa的图书馆,以利用其BezierSpline类的iOS上运行的移动Flex项目。的目的是为了能够直接在屏幕上绘制,由用户给定的手势的点的集合,然后转换成使用这个库Bezier曲线

I have a mobile Flex project running on iOS that has been using Degrafa's library in order to use its BezierSpline class. The purpose is to be able to draw directly on the screen, the collection of points given by the user gesture is then converted into a bezier curve using this library.

然而,我的应用最近已立即崩溃,因为它是显示含有至少一种这些曲线的一个页面。我没有得到任何错误,堆栈跟踪什么的,该应用程序是简单的死亡,我带回了iOS桌面。 显然,错误的BezierSpline类的.draw()函数中发生的地方。

However, my app has been recently crashing as soon as it was displaying a page containing at least one of these curves. I don't get any error, stacktrace or anything, the app is simply killed and I'm taken back to the iOS desktop. Apparently the error is occurring somewhere inside the .draw() function of the BezierSpline class.

另外,我注意到,这只是存在的对应用程序的发布版本,无论是通过AppStore的(貌似他们没有注意到它),或通过部署在iPad上发布包。一切工作正常,在仿真器或直接调试包装设备上。 因为我还没有作出任何版本的软件包了一段时间,我不知道该修改可能会导致此。我唯一​​知道的是,我最近更新的Flash Builder的4.7和AIR 3.9(这是需要这个项目的其他功能)。

Also, I've noticed that this is only occuring on release versions of the app, either through the AppStore (looks like they didn't notice it) or through a release package deployed on the iPad. Everything is working fine in the emulator or with a debug package directly on the device. Since I haven't made any release packages for some time, I'm not sure which modification may have caused this. The only thing I know is that I've recently updated Flash Builder to 4.7 and AIR to 3.9 (which is required for other features of this project).

所以,我基本上有三个问题:

So I basically have three questions:

  • 在这种情况下,可以在应用程序崩溃只在释放模式,而不是在调试模式?在code保持不变。

  • In which case can an app crash only in release mode and not in debug mode? The code remains the same.

已经有人遇到过使用Degrafa及其BezierSpline类那种问题?

Has someone ever encountered that kind of issue using Degrafa and its BezierSpline class?

也许这可以通过升级空运到最新的3.9版本引起的?

May this be caused by upgrading AIR to the latest 3.9 version?

修改:我刚刚测试了下一个Android设备完全相同的code,曲线显示的是正确的,所以这只是一个iOS设备上进行部署时存在的。

EDIT: I've just tested the exact same code under an Android device, the curve is displaying correctly, so this is only occuring when deployed on an iOS device.

推荐答案

我最终实现本真正有用的例子写的李挖洞的此处。 这是所有我需要在一个单一的呼叫:

I ended up implementing this really helpful example written by Lee Burrows here. Here is all I need in a single call:

static public function getPoint(t:Number, points:Array):Point
    {
        var x:Number = 0;
        var y:Number = 0;
        var n:uint = points.length-1;
        var factn:Number = factoral(n);

        for (var i:uint=0;i<=n;i++)
        {
            //calc binominal coefficent
            var b:Number = factn/(factoral(i)*factoral(n-i));
            //calc powers
            var k:Number = Math.pow(1-t, n-i)*Math.pow(t, i);
            //add weighted points to totals
            x += b*k*points[i].x;
            y += b*k*points[i].y;
        }

        return new Point(x, y);
    }

    static private function factoral(value:uint):Number
    {
        if (value==0) return 1;

        var total:Number = value;
        while (--value>1)
            total *= value;

        return total;
    }

使用这个类的一个示例code也可在上面的链接。

A sample code using this class is also available at the link above.

该解决方案唯一的缺点是,我要通过定义线条曲线将作出的金额手工处理的曲线平滑度(通过改变T增量)。但我可以和动态定义此增量取决于控制点的数量,或它们之间的距离。

The only drawback of this solution is that I have to handle manually the curve smoothness by defining the amount of lines the curve will be made of (by changing "t" incrementation). But I could as well define this incrementation dynamically depending of the amount of control points, or the distance between them.

反正这是绰绰有余的问题我有,希望这可以帮助别人。

Anyway this is more than enough for the problem I had, hope this helps someone else.

这篇关于在AIR 3.9的Flex Degrafa的Bezier样条线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆