关于淡入和淡出的非常简单的AS问题
很简单的问题。看看下面的代码。这是一个非常简单的带有进度条的加载程序。进度条是舞台上的一个符号,称为“条”。
我想要的只是在完成加载时淡出该栏,并淡入加载的图像。我尝试了多种方法但运气不佳。
var loader: Loader = new Loader();
addChild(loader);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
function completeHandler(evt:Event):void {
};
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
function progressHandler(evt:ProgressEvent):void {
var percent: int = Math.round(evt.bytesLoaded/ evt.bytesTotal * 100);
bar.width = percent;
};
var req:URLRequest = new URLRequest("encs1.jpg");
loader.load(req);
预先感谢任何能给我指点的人!
Very simple question. Take a look at the code below. It's a very simple loader with a progress bar. The progress bar is a symbol on the stage called "bar".
All I want is to fade out the bar when it finishes loading, and fade in the image that loads. I've tried a number of approaches without much luck.
var loader: Loader = new Loader();
addChild(loader);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
function completeHandler(evt:Event):void {
};
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);
function progressHandler(evt:ProgressEvent):void {
var percent: int = Math.round(evt.bytesLoaded/ evt.bytesTotal * 100);
bar.width = percent;
};
var req:URLRequest = new URLRequest("encs1.jpg");
loader.load(req);
Thanks in advance to anyone who can give me any pointers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
GTween
Tween
TweenLite
尝试这些库之一。 Flash 有一个内置的补间库 fl.transitions.Tween,但它并不像这些那么好。所提到的三个 API 也非常相似。
对于您的示例,您将执行此操作(使用 Tweener):
这将花费 0.5 秒将条形图调整到 alpha 0,将加载程序的内容(图像)调整到 alpha 1,花费 0.5 秒,在延迟 0.5 秒后,所以栏淡出,图像立即淡入。
补间动画缓动函数备忘单
GTween
Tweener
TweenLite
Try one of these libraries. Flash has a built in library for Tweening, fl.transitions.Tween, but it not nearly as nice as these. All three mentioned have a very similar API as well.
For your example, you would do this (with Tweener):
This will tween the bar to alpha 0 taking .5 seconds, tween the loader's content (the image) to alpha 1 taking .5 seconds, after a delay of .5 seconds, so the bar fades out and immediately the image fades in.
Cheat Sheet for Tweener easing functions
我实际上并没有进行太多的 Flash 开发,但我的一位同事喜欢使用 GTween 来制作简单的动画。
http://www.gskinner.com/libraries/gtween/
如果您查看演示你会发现你可以做一些高级的事情,但做基本的淡入和淡出也应该很简单。下面是基本动画的示例,设置变量 itemToTween、secondsToAnimate 并将 alpha 更改为您希望为当前属性设置动画的属性。
希望这对您有所帮助,直到有更多知识的人可以提供帮助。
I don't really do much flash development but a colleague of mine loves GTween for simple animation.
http://www.gskinner.com/libraries/gtween/
If you check the demos you will see you can do some advanced stuff but it is suppose to be very simple to do basic fading in and out too. Below is an example of basic animation, set the vars itemToTween, secondsToAnimate and change alpha to be the property you wish to animate the current property to.
Hope that helps you out a little until someone with more knowledge can help.