Форум Flasher.ru
Ближайшие курсы в Школе RealTime
Список интенсивных курсов: [см.]  
  
Специальные предложения: [см.]  
  
 
Блоги Правила Справка Пользователи Календарь Сообщения за день
 

Вернуться   Форум Flasher.ru > Flash > ActionScript 3.0

Версия для печати  Отправить по электронной почте    « Предыдущая тема | Следующая тема »  
Опции темы Опции просмотра
 
Создать новую тему  
Старый 02.12.2014, 16:12
sigur вне форума Посмотреть профиль Отправить личное сообщение для sigur Найти все сообщения от sigur
  № 1  
Ответить с цитированием
sigur

Регистрация: Dec 2014
Сообщений: 2
Question фотогалерея

Помогите пожалуйста!!!!!!
Как применить данный крипт до нескольких изображений.
что бы получилась фотогалерея.

Код AS3:
// The PictureClip class was created on the stage using simple drawing tools.
// Used "Modify > Convert to Symbol" to make a movieclip with "Export for ActionScript" selected
var mcFront:PictureClip = new PictureClip();
var mcBack:PictureClip = new PictureClip();
 
 
var scaleFactor:Number = 3;
var isMoving:Boolean = false;
 
// We create variables for the width and height of the board so we can scale the picture accordingly. 
//   These settings should be chosen with consideration of the pixel dimensions of the original picture.
var boardWidth:int=1000;
var boardHeight:int=900;
 
/* 
'board' provides a background on which the image resides. This serves no purpose other than containing
all of the relevant interactive items so that they can be easily placed and moved on the stage.
*/
var board:Sprite=new Sprite();
addChild(board);
 
//The size of the magnifying glass. You can change the values as you wish.
var glassWidth:int=100;
var glassHeight:int=100;
 
//The position of 'board' will detrmine the position of your picture within the main movie.
board.x=0;
board.y=0;
 
// Add the mcBack "background" version of the MovieClip as the first child of the board
board.addChild(mcBack);
 
/* 
	We think of spTopPlate like a "transparency slide" on which we will place the top copy (mcFront) 
	of the MovieClip and the 'magnifying glass' and frame. We do this so that we can move the 
	magnifying glass relative to the (unscaled) spTopPlate coordinate system.
*/
var spTopPlate:Sprite = new Sprite();
board.addChild(spTopPlate);
 
// mcFront will be the first child on spTopPlate
spTopPlate.addChild(mcFront);
 
// Create a frame for the 'magnifying glass' consisting of an unfilled rectangle with drop shadow.
var glassFrame:Shape=new Shape();
glassFrame.graphics.lineStyle(2,0);
glassFrame.graphics.drawRect(-glassWidth/2,-glassHeight/2,glassWidth,glassHeight);
glassFrame.filters = [ new DropShadowFilter(2) ];
 
// Initially hidden
glassFrame.visible = false;
 
// glassFrame will be the second child on spTopPlate
spTopPlate.addChild(glassFrame);
 
// Create the 'magnifying glass' that will be used as a mask on mcFront (eventually).
var glass:Sprite=new Sprite();
glass.graphics.lineStyle(0,0);
glass.graphics.beginFill(200);
glass.graphics.drawRect(-glassWidth/2,-glassHeight/2,glassWidth,glassHeight);
glass.graphics.endFill();
 
//Initially hidden
glass.visible = false;
 
// glass will be the third (topmost) child on spTopPlate
spTopPlate.addChild(glass);
 
// Use a mask so we only see that part of mcFront behind the magnifying glass.
mcFront.mask = glass;
 
// Add event listeners
board.addEventListener(MouseEvent.MOUSE_DOWN, zoomIn);
stage.addEventListener(MouseEvent.MOUSE_MOVE, glassMove);
stage.addEventListener(MouseEvent.MOUSE_UP, zoomOut);
 
// Event handler for MOUSE_DOWN event that performs zooming in and activating the 'glass' mask.
function zoomIn(mev:MouseEvent):void {
	/* 
	We want to use coordinates of the mouse but we want to keep the 'magnifying glass' cursor
	over the picture, so we find the point (goodX,goodY) that is the closest to the cursor but
	over which we cab still draw a valid magnifying glass.
	*/
	var goodX:Number = Math.max(board.mouseX,glassWidth/(2*scaleFactor));
	goodX = Math.min(goodX,boardWidth-glassWidth/(2*scaleFactor));
 
	var goodY:Number= Math.max(board.mouseY,glassHeight/(2*scaleFactor));
	goodY = Math.min(goodY,boardHeight-glassHeight/(2*scaleFactor));
 
	/* 
	externalCenter is the clicked point on mcBack and internalCenter is the scaled up 
	version of this point, which will be the same point on mcFront once it is scaled 
	in the next two lines.
	*/
	var externalCenter:Point=new Point(goodX,goodY);
	var internalCenter:Point=new Point(goodX*scaleFactor,goodY*scaleFactor);
 
	// Scale up mcFront to make internalCenter the correct point on mcFront
	mcFront.scaleX = scaleFactor;
	mcFront.scaleY = scaleFactor;
 
	// Reposition mcFront so that the "same" point on mcFront and mcBack are aligned.
	mcFront.x = externalCenter.x - internalCenter.x;
	mcFront.y = externalCenter.y - internalCenter.y;
 
	// Center the magnifying glass and its frame at the point (goodX,goodY).
	glass.x = goodX;
	glass.y = goodY;
 
	glassFrame.x = glass.x;
	glassFrame.y = glass.y;
 
	// Make glass visible
	glass.visible = true;
	glassFrame.visible = true;
 
	// Hide the (arrow) mouse cursor so we can see through the magnifying glass without the cursor in the way.
	Mouse.hide();
 
	/* 
	Activate the magnifying glass motion. See the glassMove function (the MOUSE_MOVE event handler)
	to see that the glassMove function returns immediately if the isMoving variable is false.
	*/
	isMoving = true;
}
 
// Event handler for the MOUSE_MOVE event. This effectively is the same as zoomIn above.
function glassMove(e:MouseEvent):void {
	// This function does nothing if the isMoving flag has not yet been set to true.
	if (!isMoving) return;
 
	/* 
	We want to use coordinates of the mouse but we want to keep the 'magnifying glass' cursor
	over the picture, so we find the point (goodX,goodY) that is the closest to the cursor but
	over which we cab still draw a valid magnifying glass.
	*/
	var goodX:Number = Math.max(board.mouseX,glassWidth/(2*scaleFactor));
	goodX = Math.min(goodX,boardWidth-glassWidth/(2*scaleFactor));
 
	var goodY:Number= Math.max(board.mouseY,glassHeight/(2*scaleFactor));
	goodY = Math.min(goodY,boardHeight-glassHeight/(2*scaleFactor));
 
	/* 
	We align mcFront with mcBack so that we can easily track a corresponding point on both. 
	After finding that point we will scale mcFront and realign (below).
	*/
	mcFront.x = mcBack.x;
	mcFront.y = mcBack.y;
 
	/* 
	externalCenter is the clicked point on mcBack and internalCenter is the scaled up 
	version of this point, which will be the same point on mcFront once it is scaled 
	in the next two lines.
	*/
	var externalCenter:Point=new Point(goodX,goodY);
	var internalCenter:Point=new Point(goodX*scaleFactor,goodY*scaleFactor);
 
	// Scale up mcFront to make internalCenter the correct point on mcFront
	mcFront.scaleX = scaleFactor;
	mcFront.scaleY = scaleFactor;
 
	// Reposition mcFront so that the "same" point on mcFront and mcBack are aligned.
	mcFront.x = externalCenter.x - internalCenter.x;
	mcFront.y = externalCenter.y - internalCenter.y;
 
	// Center the magnifying glass and its frame at the point (goodX,goodY).
	glass.x = goodX;
	glass.y = goodY;
 
	glassFrame.x = glass.x;
	glassFrame.y = glass.y;
 
	// The following method call makes smoother motion from a MOUSE_MOVE event.
	e.updateAfterEvent();
}
 
// Event handler for MOUSE_UP event that performs zooming out and removing the mask for mcFront.
function zoomOut(mev:MouseEvent):void {
 
	// Rescale mcFront and reposition to align with mcBack
	mcFront.scaleX = 1;
	mcFront.scaleY = 1;
	mcFront.x = mcBack.x;
	mcFront.y = mcBack.y;
 
	// Hide glass & glassFrame
	glass.visible = false;
	glassFrame.visible = false;
 
	// Show the mouse cursor again
	Mouse.show();
 
	// Stop the motion of the "glass"
	isMoving = false;
}


Последний раз редактировалось Wolsh; 02.12.2014 в 20:35.
Создать новую тему   Часовой пояс GMT +4, время: 14:08.
Быстрый переход
  « Предыдущая тема | Следующая тема »  

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.


 


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


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