Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   FAQ (http://www.flasher.ru/forum/forumdisplay.php?f=86)
-   -   Как сделать заливку фона текстурой? (http://www.flasher.ru/forum/showthread.php?t=65988)

mixey_lv 23.06.2005 22:43

Как сделать заливку фона текстурой?
 
... Т.е. взять маленький кусочек bg и раскопировать его...
Как в ХТМЛе функция?
нашел прототип такой штуки, но не понял как им пользоваться :confused:
Код:

/* Stage.tileImage([linkageName], [stageAlignX], [stageAlignY], [alpha], [tileTarget])
  --------------------------------------------------------------------------
  copyleft 2004 Joseph Balderson Design :: http://www.memoriesofsilence.com
  --------------------------------------------------------------------------
        Parameters:
                [linkageName] = the library linkage name of the mc containing the image to
                                tile;
                [stageAlignX&Y] = configures starting point of tile according to stage vertical
                                & horizontal alignment: "left", "center", "right"; note this
                                does not set the Stage.align parameter, merely aligns the tile
                                according to that alignment.
                [alpha] = alpha of the tile image;
                [tileTarget] = optional; target clip within which to create the tile (may be a
                                clip object or a string); note tileTarget must be full path
                                if clip is not in the same place as function call; if tileTarget
                                is absent, the tile is created in an empty movie clip below
                                all author-time content.

        Usage:
        // Best used with Stage.scaleMode = "noScale" so that the tile fills the browser window;

        // creates tile from backgroundTile library mc into an empty clip with a default alpha
        // of 100 situated below all author-time content with a stage alignment of dead-centre
        Stage.tileImage("backgroundTile", "center", "center");

        //... with a stage alignment of left&centre
        Stage.scaleMode = "noScale";
        Stage.align = "L"; // left centre
        Stage.showMenu = false;
        // don't show the menu, cause if you zoom you'll never get the stage size
        // to normal back unless you reload the page
        Stage.tileImage("backgroundTile", "left", "center", 99);

        // creates tile from backgroundTile library mc into clip named "background_mc"
        Stage.tileImage("backgroundTile", "center", "center", 99, "background_mc");

        Note: we don't use 'prototype' when creating the function because Stage is a fixed object
        and not a class
*/
Stage.tileImage = function(linkageName, stageAlignX, stageAlignY, alpha, tileTarget) {
        // get the Movie size
        var stageState = stage.scaleMode; // remember the initial state
        stage.scaleMode = "showAll";
        var movieW = stage.width;
        var movieH = stage.height;
        stage.scaleMode = stageState; // return stage to initial scale mode
        // set first instance name & depth depending on input params
        if (tileTarget == undefined) { // if tileTarget does not exist
                _root.createEmptyMovieClip("tileimage_mc", -16384);
                // note: depth -16384 is a special level reserved for dynamic content
                // that appears beneath all author-time content.
                var bgTarget_mc = _root.tileimage_mc;
        } else if (typeof tileTarget == "string") { // if tileTarget is a string
                var bgTarget_mc = eval("_root."+tileTarget);
        } else if (typeof tileTarget == "movieclip") { // if tileTarget is an object
                var bgTarget_mc = _root[tileTarget._name];
                // Note: we write this instead of _root.tileTarget, in case the user inputs "_root.name",
                // which would result in "_root._root.name", crashing the function
        } else {
                return; // function fails silently
        }
        // create first instance of image tile clip
        var backTile = bgTarget_mc.attachMovie(linkageName, "backTile0", 0);
        // get image dimensions from first instance
        var tileW = backTile._width;
        var tileH = backTile._height;
        // initialize grid
        var screenW = System.capabilities.screenResolutionX;
        var screenH = System.capabilities.screenResolutionY;
        var gridW = Math.ceil(screenW/tileW);
        var gridH = Math.ceil(screenH/tileH);
        var totalSqrs = gridW*gridH;
        // Configure starting point of grid
        //    configure X axis start
        if (stageAlignX != undefined && stageAlignX == "left") {
                var startX = 0;
        } else if (stageAlignX != undefined && stageAlignX == "right") {
                var startX = -(screenW-movieW);
        } else if (stageAlignX != undefined && stageAlignX == "center") {
                var startX = -(screenW/2-movieW/2); //width of actual movie
        } else {
                return; // function fails silently
        }
        //    configure Y axis start
        if (stageAlignY != undefined && stageAlignY == "top") {
                var startY = 0;
        } else if (stageAlignY != undefined && stageAlignY == "bottom") {
                var startY = -(screenH-movieH);
        } else if (stageAlignY != undefined && stageAlignY == "center") {
                var startY = -(screenH/2-movieH/2); //width of actual movie
        } else {
                return; // function fails silently
        }
        // set background clip start position
        bgTarget_mc._x = startX;
        bgTarget_mc._y = startY;
        // set grid alpha
        if (alpha != undefined) {
                var gridAlpha = alpha;
        } else {
                var gridAlpha = 100;
        }
        bgTarget_mc._alpha = gridAlpha;
        // tile image
        var i;
        var k;
        var j=1;
        for (k=0; k<=gridH; k++) {
                for (i=0; i<=gridW; i++) {
                        j++
                        var backTile = bgTarget_mc.attachMovie(linkageName, "backTile"+j, j);
                        backTile._x = tileW*i;
                        backTile._y = tileH*k;
                }
        }
};

Помогите советом

silin 24.06.2005 00:00

все сводится к тиражированию символа из библиотеки в мувик на самом нижнем уровне:
Код:

//'s' -linkage identifier мувика в библиотеке
var bg=this.createEmptyMovieClip('bg',-16384).attachMovie('s',0,0);
var w=bg._width,h=bg._height;
var nx=Math.ceil(Stage.width/w),ny=Math.ceil(Stage.height/h);
for(var i=nx*ny;--i;) bg.attachMovie('s',i,i,{_x:(i%nx)*w,_y:Math.floor(i/nx)*h})



Часовой пояс GMT +4, время: 09:37.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.