Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将Flash Perlin函数从ActionScript 1转换为3_Flash_Actionscript 3_Function_Actionscript 1 - Fatal编程技术网

将Flash Perlin函数从ActionScript 1转换为3

将Flash Perlin函数从ActionScript 1转换为3,flash,actionscript-3,function,actionscript-1,Flash,Actionscript 3,Function,Actionscript 1,我有一些Flash的代码来模拟移动的云。它在AS1下工作,现在我已经将FLA文件更新为AS3和最低Flash版本10。这个代码有什么问题?你能帮我看看这个功能有什么问题吗 function createLiquidFlow(target) { target.counter = 1; target.pt = new flash.geom.Point(0, 0); target.mpoint = new flash.geom.Point(0, 0); // targe

我有一些Flash的代码来模拟移动的云。它在AS1下工作,现在我已经将FLA文件更新为AS3和最低Flash版本10。这个代码有什么问题?你能帮我看看这个功能有什么问题吗

function createLiquidFlow(target)
{
    target.counter = 1;
    target.pt = new flash.geom.Point(0, 0);
    target.mpoint = new flash.geom.Point(0, 0);
    // target.myBitmap = new flash.display.BitmapData(target._width, target._height, false, 0);
    target.myBitmap = new flash.display.BitmapData(target.width, target.height, false, 0 );
    target.myDispl = new flash.filters.DisplacementMapFilter(target.myBitmap, target.mpoint, 10, 2, 10, 15, "clamp");
    target.myList = new Array();
    target.myList.push(target.myDispl);
    target.filters = target.myList;
    target.addEventListener(Event.ENTER_FRAME,
                          function ()
                            {
                                trace("target.name = "+target.name);
                                trace("target.myBitmap = "+target.myBitmap);
                                trace("target.myBitmap.width = "+target.myBitmap.width);
                                trace("target.myBitmap.height = "+target.myBitmap.height);
                                trace("target.counter = "+target.counter);
                                var filterList = target.filters;
                                var offset = new Array();
                                offset[1] = new Object();
                                offset[1].x = target.counter;
                                offset[1].y = target.counter / 2;
                                target.myBitmap.perlinNoise(45, 6, 3, 50, true, false, 7, true, offset);
                                filterList.mapBitmap = target.myBitmap;
                                target.filters = filterList;
                                ++target.counter;
                            });
}

createLiquidFlow( movieClipLiquid )
我可以跟踪事件侦听器,但位图和柏林函数似乎不起作用。在输出SWF中没有视觉上的变化。短暂性脑缺血发作

target.name = liquid74_mc
target.myBitmap = [object BitmapData]
target.myBitmap.width = 950
target.myBitmap.height = 76
target.counter = 1
myFilterList = [object DisplacementMapFilter]
BEFORE myFilterList.mapBitmap = undefined
AFTER  myFilterList.mapBitmap = [object BitmapData]
BEFORE target.filters = [object DisplacementMapFilter]
AFTER  target.filters = [object DisplacementMapFilter]
target.name = liquid74_mc
target.myBitmap = [object BitmapData]
target.myBitmap.width = 950
target.myBitmap.height = 76
target.counter = 2
myFilterList = [object DisplacementMapFilter]
BEFORE myFilterList.mapBitmap = undefined
AFTER  myFilterList.mapBitmap = [object BitmapData]
BEFORE target.filters = [object DisplacementMapFilter]
AFTER  target.filters = [object DisplacementMapFilter]

答案是ActionScript3比ActionScript1对类型更严格。 Bitmap.perlinNoise需要一个偏移量,该偏移量是一个点对象数组。在Java中,这与

List<Point> points = new ArrayList<Point>()

您是否运行swf以便可以看到运行时错误,例如在FlashCSIDE或FlashBuilder中,或者使用FlashPlayer的调试版本?如果是,您是否看到任何错误消息?一件事是,事件处理程序函数需要接受一个参数,即事件对象,即使您不使用它。将向处理程序发送一个对象,并发送需要匹配的函数。因此,like.addEventListenerEvent.ENTER_FRAME,function e:Event。。。而不是你现在拥有的。您不应该使用偏移量[0]而不是基于零的偏移量[1]数组吗?我使用的是Flash CS55 Professional。没有错误。我添加了事件处理程序参数function:event。我还尝试了偏移量[0],没有更改。感谢Lars帮助我缩小此问题的范围。我还要感谢做这件事的Flep工作室的家伙
List<Object> points = new ArrayList<Object>()
function createLiquidFlow(target)
    target.counter = 1;
    target.pt = new flash.geom.Point(0, 0);
    target.mpoint = new flash.geom.Point(0, 0);
    // target.myBitmap = new flash.display.BitmapData(target._width, target._height, false, 0);
    target.myBitmap = new flash.display.BitmapData(target.width, target.height, false, 0 );
    target.myDispl = new flash.filters.DisplacementMapFilter(target.myBitmap, target.mpoint, 10, 2, 10, 15, "clamp");
    target.myList = new Array();
    target.myList.push(target.myDispl);
    target.filters = target.myList;
    target.addEventListener(
        Event.ENTER_FRAME,
          function (e:Event)
            {
                var myFilterList = target.filters;
                var offset = new Array();
                offset[0] = new Point(0, 0);
                offset[1] = new Point(target.counter, target.counter / 2);
                target.myBitmap.perlinNoise(45, 6, 3, 50, true, false, 7, true, offset);
                myFilterList.mapBitmap = target.myBitmap;
                target.filters = myFilterList;
                ++target.counter;
            });
    // Arguments to PerlinNoise function
    // baseX:Number — Frequency to use in the x direction. For example, to generate a noise that is sized for a 64 x 128 image, pass 64 for the baseX value.
    // baseY:Number — Frequency to use in the y direction. For example, to generate a noise that is sized for a 64 x 128 image, pass 128 for the baseY value.
    // numOctaves:uint — Number of octaves or individual noise functions to combine to create this noise. Larger numbers of octaves create images with greater detail. Larger numbers of octaves also require more processing time.
    // randomSeed:int — The random seed number to use. If you keep all other parameters the same, you can generate different pseudo-random results by varying the random seed value. The Perlin noise function is a mapping function, not a true random-number generation function, so it creates the same results each time from the same random seed.
    // stitch:Boolean — A Boolean value. If the value is true, the method attempts to smooth the transition edges of the image to create seamless textures for tiling as a bitmap fill.
    //  fractalNoise:Boolean — A Boolean value. If the value is true, the method generates fractal noise; otherwise, it generates turbulence. An image with turbulence has visible discontinuities in the gradient that can make it better approximate sharper visual effects like flames and ocean waves.
    //  channelOptions:uint (default = 7) — A number that can be a combination of any of the four color channel values (BitmapDataChannel.RED, BitmapDataChannel.BLUE, BitmapDataChannel.GREEN, and BitmapDataChannel.ALPHA). You can use the logical OR operator (|) to combine channel values.
    //  grayScale:Boolean (default = false) — A Boolean value. If the value is true, a grayscale image is created by setting each of the red, green, and blue color channels to identical values. The alpha channel value is not affected if this value is set to true.
    //offsets:Array (default = null) — An array of points that correspond to x and y offsets for each octave. By manipulating the offset values you can smoothly scroll the layers of a perlinNoise image. Each point in the offset array affects a specific octave noise function.                             
}

createLiquidFlow( movieClipLiquid )