简体   繁体   English

如何使用Flash将全屏图像作为背景

[英]How to put a fullscreen image as a background using Flash

I wonder how you can put a fullsize background image to a website using Flash, similar to how www.zugspitze.de does. 我不知道如何使用Flash将完整的背景图片放置到网站上,就像www.zugspitze.de一样。

I can copy the HTML code but what does the flash document looks like? 我可以复制HTML代码,但Flash文档是什么样的?

Thanks for your help. 谢谢你的帮助。 :-) :-)

Something like this should work. 这样的事情应该起作用。 Basically, you want to listen for the when the stage is resized, then change the width/height of your image so that it matches in at least one dimension. 基本上,您想听舞台调整大小时的声音,然后更改图像的宽度/高度,以使其在至少一个维度上匹配。

package {

    import flash.display.Sprite;
    import flash.events.Event;
    import flash.geom.Rectangle;

    public class BackgroundImage extends Sprite {        
        private var _imageHolder:Sprite = new Sprite();

        public function BackgroundImage() {
            addChild(_imageHolder);
            // load or attach image to _imageHolder.
            // if image is loaded externally, use the event for it's completion to call startResize, otherwise use the ADDED_TO_STAGE event.
            addEventListener(Event.ADDED_TO_STAGE, startResize, false, 0, true);
        }

        private function _startResize($evt:Event):void {
            removeEventListener(Event.ADDED_TO_STAGE, startResize);
            stage.addEventListener(Event.RESIZE, _setScale, false, 0, true);
            setScale(null);
        }

        private function setScale($evt:Event):void {
            var _stageRectangle:Rectangle = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
            if (_imageHolder.width / _stageRectangle.width > _imageHolder.height / _stageRectangle.height) {
                _imageHolder.height = _stageRectangle.height;
                _imageHolder.scaleX = _imageHolder.scaleY;
            } else {
                _imageHolder.width = _stageRectangle.width;
                _imageHolder.scaleY = _imageHolder.scaleX;
            }

        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM