AS3 嵌入图像而不是绘制图形
我有一个需要修改的自定义 AS3 滚动条。滚动滑块(滚动条的可拖动部分)当前仅通过绘制矩形来完成。但我需要它看起来更像一个真正的滚动条。不知道如何修改下面的代码来导入/使用滚动拇指图像:
scrollThumb = new Sprite();
scrollThumb.graphics.lineStyle();
scrollThumb.graphics.beginFill(0x0066ff);
scrollThumb.graphics.drawRect(0, 0, 1, 1);
addChild(scrollThumb);
我知道我会通过执行以下操作来嵌入图像:
[Embed(source="images/image1.png")] private static var Image1Class:班级;
但是如何将scrollThumb = 设置为图像呢?
谢谢!
I've got a custom AS3 scrollbar that I need to modify. The scroll thumb (the draggable part of a scrollbar) is currently just done by drawing a rectangle. But I need it to look more like a real scrollbar. Not sure how to modify the below code to import/use a scroll thumb image:
scrollThumb = new Sprite();
scrollThumb.graphics.lineStyle();
scrollThumb.graphics.beginFill(0x0066ff);
scrollThumb.graphics.drawRect(0, 0, 1, 1);
addChild(scrollThumb);
I know that I would embed an image by doing something like this:
[Embed(source="images/image1.png")] private static var Image1Class:Class;
But then how do I set the scrollThumb = to the image?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要这样做:
图像被作为 BitmapDatas 调用,因此如果您想将其作为 Sprite 进行操作,
Images get called in as BitmapDatas so you need to do
or if you want to manipulate it as a Sprite:
我认为它应该很简单:
I think it should be as simple as: