Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 1.0/2.0 (http://www.flasher.ru/forum/forumdisplay.php?f=93)
-   -   BitmapData.draw() (http://www.flasher.ru/forum/showthread.php?t=100539)

chingachgoog 29.08.2007 19:04

BitmapData.draw()
 
На таймлайне (где-нибудь за видимой областью) символ targ (кружочек, с точкой отсчета в левом верхнем углу и сторонами 100х100 для простоты).
Собственно я его масштабирую (_xscale) и пытаюсь снять с него скриншот:

Код:

import flash.display.BitmapData;

myBitmapData = new BitmapData(500, 500, false, 0x00CCCCCC);

mc = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());
targ._xscale=targ._yscale=500


mc.onPress = function() {
    myBitmapData.draw(targ)
        trace(targ._width+" "+targ._xscale)
}

Скриншот снимается с НЕМАСШТАБИРОВАННОГО клипа (хотя он реально увеличился)

Далее, усложняю.
Помещаю в targ (пустой) клип-кружочек (все тот же) с именем ttt

Код:

import flash.display.BitmapData;

myBitmapData = new BitmapData(500, 500, false, 0x00CCCCCC);

mc = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());
targ.ttt._xscale=targ.ttt._yscale=500


mc.onPress = function() {
    myBitmapData.draw(targ)
        trace(targ._width+" "+targ._xscale)
}

Все! Теперь скриншот как и задумывалось показывает увеличенный кружочек.

Вопрос: как же все-таки действует метод draw()???

etc 29.08.2007 19:06

Прочитайте про второй параметр в draw.

chingachgoog 29.08.2007 19:28

Спасибо.
Помогло. Причем _xscale вовсе не нужен:

Код:

import flash.display.BitmapData;
import flash.geom.Matrix;


myBitmapData = new BitmapData(500, 500, false, 0x00CCCCCC);

mc = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());

myMatrix = new Matrix();
myMatrix.scale(5,5)

mc.onPress = function() {
    myBitmapData.draw(targ,myMatrix)
        trace(targ.ttt._width+" "+targ.ttt._xscale+" "+targ._width+" "+targ._xscale)
}



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

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