ActionScript:将框架应用于图像/背景?

发布于 2024-09-01 15:51:36 字数 2118 浏览 4 评论 0原文

我正在 Flash 中编辑自定义日历应用程序。这个应用程序的目的是让您选择自己的图像,并用它创建一个日历。基本上,您可以拖放您选择的图像,并应用框架/边框,或拖放装饰。 这是在您选择的装饰/图像上绘制边框/框架的代码段。

tempListener.onLoadInit = function(target_mc:MovieClip)
{
    var mcName = target_mc._name.substring(0, target_mc._name.indexOf("@", 0));
    if(mcName == "frame_Image")
    {
        target_mc.onPress = function()
        {
            if(_root.selectedImage != null)
            {
                var index = this._name.substring(this._name.indexOf("@",0)+1, this._name.length);
                var objPath = nodesFrames.childNodes[index-1].attributes.image;

                if(_root.selectedImage._name.split("@")[0] == "image")
                {
                    var mask = _root.selectedImage[_root.selectedImage._parent._name + "_" + _root.selectedImage._name + "_maskMc"];

                    frameImageWidth = mask._width;
                    frameImageHeight = mask._height;
                    frameImageXScale = -1;
                    frameImageYScale = -1;
                }
                else
                {
                    frameImageXScale = _root.selectedImage._xscale;
                    frameImageYScale = _root.selectedImage._yscale;

                    _root.selectedImage._xscale = 100;
                    _root.selectedImage._yscale = 100;                              

                    frameImageWidth = _root.selectedImage._width;
                    frameImageHeight = _root.selectedImage._height;             
                }

                if(_root.selectedImage["frame"])
                {}
                else
                {
                    _root.selectedImage.createEmptyMovieClip("frame",  _root.selectedImage.getNextHighestDepth());
                }
                var image_mcl1:MovieClipLoader = new MovieClipLoader();
                image_mcl1.addListener(_root.mclFrameListener);
                image_mcl1.loadClip("Images/" + objPath,  _root.selectedImage["frame"]);
            }
        }
    }

我需要以某种方式将所选的帧图像应用到整个背景 - 而不仅仅是装饰或图像。我该怎么办?

预先感谢您的投入。如果问题没有意义,请告诉我,我将附上一些可以帮助您了解上下文的图片。

I am editing a custom calendar application in flash. The purpose of this app is to let you select your own images, and create a calendar out of it. You can basically, drag and drop images of your choice and they apply frame/borders, or drag and drop embellishments.
Here is the piece of code that draws a border/frame on the embellishment/image of your choice.

tempListener.onLoadInit = function(target_mc:MovieClip)
{
    var mcName = target_mc._name.substring(0, target_mc._name.indexOf("@", 0));
    if(mcName == "frame_Image")
    {
        target_mc.onPress = function()
        {
            if(_root.selectedImage != null)
            {
                var index = this._name.substring(this._name.indexOf("@",0)+1, this._name.length);
                var objPath = nodesFrames.childNodes[index-1].attributes.image;

                if(_root.selectedImage._name.split("@")[0] == "image")
                {
                    var mask = _root.selectedImage[_root.selectedImage._parent._name + "_" + _root.selectedImage._name + "_maskMc"];

                    frameImageWidth = mask._width;
                    frameImageHeight = mask._height;
                    frameImageXScale = -1;
                    frameImageYScale = -1;
                }
                else
                {
                    frameImageXScale = _root.selectedImage._xscale;
                    frameImageYScale = _root.selectedImage._yscale;

                    _root.selectedImage._xscale = 100;
                    _root.selectedImage._yscale = 100;                              

                    frameImageWidth = _root.selectedImage._width;
                    frameImageHeight = _root.selectedImage._height;             
                }

                if(_root.selectedImage["frame"])
                {}
                else
                {
                    _root.selectedImage.createEmptyMovieClip("frame",  _root.selectedImage.getNextHighestDepth());
                }
                var image_mcl1:MovieClipLoader = new MovieClipLoader();
                image_mcl1.addListener(_root.mclFrameListener);
                image_mcl1.loadClip("Images/" + objPath,  _root.selectedImage["frame"]);
            }
        }
    }

I need to somehow apply the chosen frame image, to the entire background - not just to the embellishment or image. How do I go about this?

Thanks in advance for your inputs. Please let me know if the question doesn't make sense, I will attach some images that can help you with the context.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

友欢 2024-09-08 15:51:37

自从我编写 AS2 以来已经很长时间了,但是...您是否尝试过创建一个位于最底层的空 MovieClip?然后,您可以允许选定的帧图像成为该 MC 的子图像。

It's been a long time since I've written AS2, but... have you tried creating an empty MovieClip that sits in the lowest layer? You could then allow the selected frame image to be a child of that MC.

坏尐絯 2024-09-08 15:51:36

您可以使用蒙版剪辑创建一个新的位图,然后创建平铺背景。这是 as2 版本:

this.beginBitmapFill(tile);

这里解释了如何做到这一点:
http://www.kirupa.com/developer/flash8/tiledbackground_flash8.htm

唯一的区别是您可以从蒙版剪辑创建位图,而不是加载位图。

我希望它足够清楚,其他方式让我知道。

You could create a new Bitmap with the masked clip and then created a tiled background. This is the as2 version:

this.beginBitmapFill(tile);

And here it explains how to do it:
http://www.kirupa.com/developer/flash8/tiledbackground_flash8.htm

The only difference is instead of loading a bitmap you can create it from the masked clip.

I hope it's clear enough, other ways let me know.

晚雾 2024-09-08 15:51:36

Flash 中没有内置方法来设置背景图像,您必须自己实现逻辑。

因此,例如,如果您希望图像填充整个背景,您可能必须手动拉伸或平铺它,甚至可能需要在调整大小时进行拉伸或平铺。

There`s no built in way in Flash to set a background image, you have to implement the logic yourself.

So for example if you want the image to fill in the entire background, you might have to stretch or tile it manually, maybe even onResize.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文