Показать сообщение отдельно
Старый 07.07.2011, 02:01
flashfoxter вне форума Посмотреть профиль Отправить личное сообщение для flashfoxter Найти все сообщения от flashfoxter
  № 10  
Ответить с цитированием
flashfoxter

Регистрация: Jun 2011
Сообщений: 91
Код AS3:
package {
	import flash.display.*;
	import flash.events.*;
	import flash.net.*;
	import com.greensock.*;
 
	public class Presentation extends Sprite {
		private var left:Left;
		private var right:Right;
		private var slides:Sprite;
		private var picture:Loader;
		private var buttons:Array;
 
		private var currentPicture:int = -1;
 
		public function Presentation():void {
			createSlides();
			createButtons();
			trace(currentPicture);
		}
 
		private function createButtons():void {
			left = new Left();
			left.x = 12;
			left.y = 180;
			left.alpha = 0.4;
			right = new Right();
			right.x = 468;
			right.y = 180;
			right.alpha = 0.4;
			addChild(right);
			addChild(left);
			buttons = new Array(left,right);
			buttons.forEach(buttonsListener);
 
		}
		private function createSlides():void {
			slides = new Sprite();
			for (var i:int=1; i<=4; i++) {
				picture = new Loader();
				picture.load(new URLRequest("pic"+i+".jpg"));
				picture.x = 480 * i;
				slides.addChild(picture);
			}
			slides.x = -480;
			addChild(slides);
		}
		private function buttonsListener(element:*, index:int, arr:Array) {
			element.addEventListener(MouseEvent.MOUSE_OVER,selectItem);
			function selectItem(e:MouseEvent):void {
				TweenLite.to(element, 1, {alpha:1});
			}
			element.addEventListener(MouseEvent.MOUSE_OUT,unselectItem);
			function unselectItem(e:MouseEvent):void {
				TweenLite.to(element, 1, {alpha: 0.4});
			}
			element.addEventListener(MouseEvent.CLICK, clickItem);
			function clickItem(e:MouseEvent):void {
				trace(currentPicture);
				if (index == 1 && Math.abs(currentPicture) != 4) {
					currentPicture--;
					TweenLite.to(slides, 1, {x:currentPicture*480});
				} else if (index==0 && Math.abs(currentPicture)!=1) {
					currentPicture++;
					TweenLite.to(slides, 1, {x:currentPicture*480});
				} else {
					TweenLite.to(slides, 0.5, {x:-480});
					currentPicture = -1;
				}
 
			}
		}
	}
 
}
Добавлено через 3 минуты
Посмотрите в publish setting стоит галка Automatically declare stage instances ?


Последний раз редактировалось flashfoxter; 07.07.2011 в 02:40.