AS3垂直梯度大时不正确
这似乎是一件非常简单的事情,并且有大量关于该主题的教程。但他们都没有帮助我解决这个问题,而且我一辈子也无法找出问题所在。
我正在尝试创建一个具有垂直渐变的简单 Flash AS3 GUI 组件。我创建了精灵,并使用 beginGradientFill 和其上具有 90 度弧度角的矩阵绘制渐变。如果您查看此输出,您会发现它没有创建黑到白的垂直渐变。
package
{
import flash.display.GradientType;
import flash.display.Shape;
import flash.display.Sprite;
import flash.geom.Matrix;
public class Main extends Sprite
{
public function Main()
{
var theWidth : Number = 800;
var theHeight: Number = 100;
var shape1:Shape = new Shape();
var matrix:Matrix = new Matrix();
matrix.createGradientBox(theWidth , theHeight, Math.PI*0.5, 0, 0);
var colors:Array = [ 0xffffff, 0x000000];
var alphas:Array = [ 1, 1];
var ratios:Array = [ 0, 255];
shape1.graphics.lineStyle(2,0xa1b0b6);
shape1.graphics.beginGradientFill(GradientType.LINEAR,colors, alphas, ratios, matrix);
shape1.graphics.drawRect( 0.0, 0.0, theWidth , theHeight);
shape1.graphics.endFill();
addChild(shape1);
}
}
}
如果我更改
matrix.createGradientBox(800, 100, Math.PI*0.5, 0, 0);
为
matrix.createGradientBox(800, 100, Math.PI, 0, 0);
它工作正常 - 但水平 - 为什么应用 90 度填充不起作用?
谢谢你的帮助,我真的不知道这有什么问题
This seems to be a very straight forward thing to do and there are loads of tutorials about the subject. None of them are helping me get this right though, and I can't for the life of me figure out what's wrong.
I'm trying to create a simple Flash AS3 GUI component that has a vertical gradient. I create the sprite, and draw the gradient with beginGradientFill and a matrix with a 90 degree radian angle on it. If you look at this output, you see that its not creating a black to white vertical gradient.
package
{
import flash.display.GradientType;
import flash.display.Shape;
import flash.display.Sprite;
import flash.geom.Matrix;
public class Main extends Sprite
{
public function Main()
{
var theWidth : Number = 800;
var theHeight: Number = 100;
var shape1:Shape = new Shape();
var matrix:Matrix = new Matrix();
matrix.createGradientBox(theWidth , theHeight, Math.PI*0.5, 0, 0);
var colors:Array = [ 0xffffff, 0x000000];
var alphas:Array = [ 1, 1];
var ratios:Array = [ 0, 255];
shape1.graphics.lineStyle(2,0xa1b0b6);
shape1.graphics.beginGradientFill(GradientType.LINEAR,colors, alphas, ratios, matrix);
shape1.graphics.drawRect( 0.0, 0.0, theWidth , theHeight);
shape1.graphics.endFill();
addChild(shape1);
}
}
}
If I change
matrix.createGradientBox(800, 100, Math.PI*0.5, 0, 0);
to
matrix.createGradientBox(800, 100, Math.PI, 0, 0);
it works fine - but horizontally - why is it that applying 90 degrees the fill does not work?
Thanks for your help, I really don't know whats wrong with this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
解决方案是通过盒子的高度来平移 Y 中的矩阵,在 FP9 中工作很愚蠢,如果不这样做,对我来说工作得很好,孵化器构建起来看起来很糟糕,又回到了 10.3 糟糕..现在可能是这样由中心旋转的矩阵或现在需要平移的东西。
The solution would be to translate the Matrix in Y by the height of the box, it's silly working in FP9 worked fine for me without doing that, had the incubator build and looked bad, went back to 10.3 bad again.. might be that now the matrix it's rotated by the center or something that now translation is needed.
如果不测试您的代码,您似乎可能正在描述 Mario Klingemann 有解决方案的这个问题(当然)。
http://www.quasimondo.com/archives/000689.php
Without testing your code, it seems like you may be describing this issue that Mario Klingemann has a solution to (of course).
http://www.quasimondo.com/archives/000689.php
只是为了确认,这是 Flash 播放器问题。
Just to confirm, this was a Flash player issue.