Action Script 3 新加载程序
我正在重新审视在 Action Script 2.0 中创建的简单图片查看器的一些代码,现在在 AS3 中承担相同的任务。目前我很清楚命令 .loadMovie 已不再使用。经过多次尝试寻找解决方案后,我却一无所获。
目前,我在舞台上有一个影片剪辑符号(target_mc),当我将鼠标悬停在按钮上时,我想从外部文件加载 jpeg。任何人都可以举例说明如何使用“新加载”变量来实现这一点。在 AS2 版本中,我也在按钮代码中使用(在发布时)。
Training_btn 是按钮实例。
请参阅下面的我的代码示例:
training_btn.addEventListener(MouseEvent.CLICK, imageOver);
function imageOver(evt:MouseEvent) {
this.target_mc.loadMovie("galleryimage/p_traininglink.jpg")
}
任何想法都会非常有帮助。
韦恩
I was revisiting some code for a simple picture viewer that I created in Action Script 2.0 now taking on the same task in AS3. At present i'm well aware that the command .loadMovie is no longer used. After numerous attempts to find a solution I have come up dry.
At the moment I have a movie clip symbol(target_mc) on the stage that I want to load jpegs from a external file when I mouseOver a button. Can any one give a example of how this should be approached using the "new load" variable.In the AS2 version i also used (on release) in the button code.
training_btn is the button instance.
Please see an example of my code below:
training_btn.addEventListener(MouseEvent.CLICK, imageOver);
function imageOver(evt:MouseEvent) {
this.target_mc.loadMovie("galleryimage/p_traininglink.jpg")
}
Any ideas would be very helpful.
Wayne
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Here at the Republic of Code 是一个关于如何使用 as3 中的加载器类
Here at the Republic of Code is an excellent step-by-step tutorial on how to work with the loader class in as3
是的
Yeap
因此,基本上,laoder 的整个结构在 AS 2 和 3 之间发生了变化。
现在您需要创建一个不同的对象来加载内容。
您可以做两件事:
这两种风格之间的区别很大,第一个将添加监听器并等待加载完成,然后它将调用您在侦听器中定义的方法来执行任何进一步的指令。
第二个开始加载内容并将加载器添加到显示列表中,以便在加载内容时自动显示。
1.
2)
这两种方法都是正确的,但我更喜欢使用第一种方法,因为它给你更多的控制权。您还可以通过监听ProgressEvent.PROGRESS来检查加载进度。
希望有帮助。在谷歌中搜索有关加载外部数据的更多信息,有很多关于这方面的资源。
So, basically the whole structure of the laoder has change between AS 2 and 3.
Now you need to create a different object that loads the content.
Than you can do two things:
The difference between these two style is big, the first one will add a listener and wait for the load to complete and after that it will call a method you define in the listener to do any further instuctions.
The second one starts loading the content and adds the loader to the display list so that when the content is loaded it automatically displays.
1.
2)
The two ways are correct but I prefer using the first one cause it gives you more controll. You can also check out the progress of loading by listening to the ProgressEvent.PROGRESS.
Hope it helps. Search in google for more info about loading external data, there's a lot of resource about that.
最好创建一个可以处理所有这些的类,但是为了回答您的问题,您的代码将类似于:
It would probably best to create a Class that would handle all of this, but to answer your question, your code would look something like: