在Flash动态UI窗口绘制? [英] Dynamic UI window drawing in Flash?

查看:185
本文介绍了在Flash动态UI窗口绘制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不知道,如果这个问题属于这里,但我会努力。所以,我即将从导演将我的项目| Shockwave播放器(如果你曾经听说过这些)到Flash Player的原因很多,虽然我正在考虑如何更好地开始我有一个问题,这着实让我惊叹。给点。

Wasn't sure if this question belongs here, but I'll try. So I'm about to move my project from Director | Shockwave Player (if you ever heard of these) to Flash Player for numerous reasons and while I'm thinking how to better start off I got a question which really made me wonder. To the point.

目前的董事在用户界面(如小型的警报或大窗户,很多在其中的元素),每个游戏窗口绘制的根据需要的 - 这意味着实际窗口的图形图像被放在一起从配置(各种像宽度,高度和所有元素及其属性的属性),从无数件的图形(例如,窗口的背景是从9小块象4个角取得,四角为动态的宽度和高度与1之间4中间片中央片以填充窗口),然后再加入到阶段。这种方法可以很容易地编辑每一个图形元素,而无需重新绘制实际的窗户,一切都在他们,如果我们想更改配色方案或改进的东西在一个元素。这也节省了资源,窗户被请求时,只绘制。

Currently in Director each game window in the user interface (like small alerts or large windows with lot of elements in them) is drawn upon need - meaning that the actual window's graphical image is being put together from configuration (all sorts of properties like width, height and all elements and their properties) from numerous pieces of graphics (e.g. window background is made from 9 small pieces like the 4 corners, 4 middle pieces between corners for dynamic width and height and 1 central piece to fill the window) and then added to stage. This approach makes it easy to edit each graphical element without having to redraw the actual windows and everything in them if we would like to change the color scheme or improve something in a element. It also saves the resources as windows are being drawn only when requested.

现在我要弄清楚它是否值得在Flash写这样code也为相反只是创建的所有窗口,并把它们在图书馆和添加到舞台在需要的时候。你怎么看?是否值得写这样的实现?

Now I got to figure out if it's worth writing such code in Flash too as opposite to just creating all the windows and placing them in the library and adding to stage when they are requested. What do you think? Is it worth writing such implementation?

推荐答案

IMO,它取决于1)如何舒适与Flash的绘图API /绘图类,2)如何灵活的每个窗口/对话框必须是。

IMO, it depends on 1) How comfortable you are with Flash's drawing API / graphics class, and 2) How flexible each window/dialog needs to be.

如果它更容易只是把它们放在一起为静态对象 - 如果他们不一定需要灵活地改变尺寸/款式不多(你能指望他们一方面有多少次必要的,因为它改变在导演最初做了很多年前?),这显然更容易不是通过时间/精力来动态地重新创建它们,特别是如果你不是很熟悉Flash的绘图API来做到这一点。

If it's easier to just throw them together as static objects -- and if they don't necessarily need the flexibility to change dimensions/style much (can you count on one hand how many times they've needed to change since it was originally done in Director many years ago?), it's obviously easier to do this than going through the time/energy to recreate them dynamically, especially if you're not very comfortable with Flash's drawing API.

这是说,一个不少,可以动态地实现与Flash的绘图API,因此,如果你有时间/兴趣我当然建议挖掘和做正确的方式,如果你想了解它的绘图API

That said, a lot can be accomplished dynamically with Flash's drawing API, so if you have the time/interest I'd certainly suggest digging in and doing it the "right" way if you want to familiarize yourself with the drawing API.

我的方法做这样的事情通常是这样的:

My method for doing this sort of thing usually goes like this:

  • 创建扩展雪碧/影片剪辑一个单独的类;像Dialog.as。
  • 创建公共的init(),显示()和隐藏()方法,以及一个私人build()方法。
  • 的init()后您的应用程序的初始化调用一次,并采取了一些全局参数扶住内部(填充,颜色等)。
  • 显示()函数采用文本(字符串)的参数,甚至是雪碧/影片剪辑 - 不管它是什么,你要在此对话框中显示。当所谓的(当你想生成一个窗口),它使用了这一点 - 加任何初始化参数初始化时最初传递() - 绘制自己,然后取消隐藏自己(吐温的阿尔法财产,或者干脆设置。可见性)。
  • 当你想关闭该对话框中,确保调用隐藏()方法,该方法首先把自己隐藏,然后清除任何已创建(删除监听器等),使了下一次调用后,它可以绘制自己的新鲜。

有也可能是有意义的传递到该对象的引用舞台(在原始的init()调用),以便它可以在舞台上相应地居中和大小本身,也的AddChild本身的顶端显示列表,以便它总是高于一切。

It might also make sense to pass into this object a reference to the Stage (in the original init() call), so that it can center and size itself accordingly on the stage, and also addChild itself to the top of the display list so that it's always above everything else.

我希望这有助于。

这篇关于在Flash动态UI窗口绘制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆