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

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

Версия для печати  Отправить по электронной почте    « Предыдущая тема | Следующая тема »  
Опции темы Опции просмотра
 
Создать новую тему Ответ
Старый 07.07.2008, 00:03
M.™ вне форума Посмотреть профиль Отправить личное сообщение для M.™ Найти все сообщения от M.™
  № 1  
Ответить с цитированием
M.™
[+4 18.07.08]

Регистрация: Sep 2006
Сообщений: 39
Attention Импорт изображений

Привет форумчане.....
Столкнулся с одной флэшкой которая загружает изображения с кокого то внешке.
Т.е. у меня, на пример есть галерея....семейный фотоальбом, и хочется не приклеивать каждый раз через прогу изображения....а сделать так, чтобы поставив изображения в папку с .swf файлом и флэшка сола загружала изображение в .swf фаил.
Как я понял это делается с помощью скриптов....
Заранее благодарю....

Старый 07.07.2008, 00:49
scarbo вне форума Посмотреть профиль Отправить личное сообщение для scarbo Найти все сообщения от scarbo
  № 2  
Ответить с цитированием
scarbo
 
Аватар для scarbo

Регистрация: Jun 2008
Адрес: курский вокзал
Сообщений: 1,114
Пожалте классический пример:
1)создаем XML файл:
Код:
<?xml version="1.0"?>
<gallery>
	<img><![CDATA[0.jpg]]></img>
	<img><![CDATA[1.jpg]]></img>
	<img><![CDATA[2.jpg]]></img>
	<img><![CDATA[3.jpg]]></img>
	<img><![CDATA[4.jpg]]></img>
	<img><![CDATA[5.jpg]]></img>
	<img><![CDATA[6.jpg]]></img>
	<img><![CDATA[7.jpg]]></img>
	<img><![CDATA[8.jpg]]></img>
	
</gallery>
Затем во флешке в 1 фрайме:
Код:
// Import the transitions classes so you can add a fading effect when the images load to the Stage.
//import mx.transitions.*;
import mx.transitions.easing.*;
import mx.transitions.Tween;
// Set the starting X and Y positions for the gallery images.
_global.thisX = 30;
_global.thisY = 70;

/* Set static values for the Stage's width and height. 
   Using Stage.width and Stage.height within the code results in 
   strangely positioned full images when testing in the Flash environment 
   (but the problem doesn't exist when published to a SWF file). */
_global.stageWidth = 800;
_global.stageHeight = 600;

// Create and configure the XML instance which is used to load the list of gallery images on the fly.
var gallery_xml:XML = new XML();
gallery_xml.ignoreWhite = true;
gallery_xml.onLoad = function(success:Boolean) {
	try {
		/* if you are able to successfully load and parse the gallery from a remote XML file, 
		   parse out the image names and add them to an array. */
		if (success) {
			var images:Array = this.firstChild.childNodes;
			var gallery_array:Array = new Array();
			for (var i = 0; i<images.length; i++) {
				gallery_array.push({src:images[i].firstChild.nodeValue});
			}
			/* call the displayGallery function which handles loading in each 
			   of the gallery images and placing them on the Stage. */
			displayGallery(gallery_array);
		} else {
			throw new Error("Unable to parse XML");
		}
	} catch (e_err:Error) {
		trace(e_err.message);
	} finally {
		delete this;
	}
};

// load the gallery.xml file from the current directory.
gallery_xml.load("my_gallery.xml");

/* create a function which loops through the images in an array,
   and creates new movie clips on the Stage. */
function displayGallery(gallery_array:Array) {
	var galleryLength:Number = gallery_array.length;
	// loop through each of the images in the gallery_array.
	for (var i = 0; i<galleryLength; i++) {
		/* create a movie clip instance which holds the image. We'll also set a variable, 
		   thisMC, which is an alias to the movie clip instance. */
		var thisMC:MovieClip = this.createEmptyMovieClip("image"+i+"_mc", i);
		
		/* load the current image source into the new movie clip instance, 
		   using the MovieClipLoader class. */
		mcLoader_mcl.loadClip(gallery_array[i].src, thisMC);
		
		// attach the preloader symbol from the Library onto the Stage.
		preloaderMC = this.attachMovie("preloader_mc", "preloader"+i+"_mc", 5000+i);
		
		/* set the preloader's bar_mc's _xscale property to 0% 
		   and set a default value in the progress bars text field. */
		preloaderMC.bar_mc._xscale = 0;
		preloaderMC.progress_txt.text = "0%";
		
		// set the _x and _y coordinates of the new movie clip.
		thisMC._x = _global.thisX;
		thisMC._y = _global.thisY;
		
		// set the position of the image preloader.
		preloaderMC._x = _global.thisX;
		preloaderMC._y = _global.thisY+20;
		
		// if you've displayed 5 columns of images, start a new row.
		if ((i+1)%5 == 0) {
			// reset the X and Y positions
			_global.thisX = 40;
			_global.thisY += 150;
			
		} else {
			_global.thisX += 80+70;
			
		}
	}
}

// define the MovieClipLoader instance and MovieClipLoader listener Object.
var mcLoader_mcl:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mclListener.onLoadStart = function() {
};

// while the content is preloading, modify the width of the progress bar.
mclListener.onLoadProgress = function(target_mc, loadedBytes, totalBytes) {
	var pctLoaded:Number = Math.round(loadedBytes/totalBytes*100);
	// create a shortcut for the path to the preloader movie clip.
	var preloaderMC = target_mc._parent["preloader"+target_mc.getDepth()+"_mc"];
	preloaderMC.bar_mc._xscale = pctLoaded;
	preloaderMC.progress_txt.text = pctLoaded+"%";
};

// when the onLoadInit event is thrown, you're free to position the instances 
mclListener.onLoadInit = function(evt:MovieClip) {
	evt._parent["preloader"+evt.getDepth()+"_mc"].removeMovieClip();
	/* set local variables for the target movie clip's width and height,
	   and the desired settings for the image stroke and border. */
	var thisWidth:Number = evt._width;
	var thisHeight:Number = evt._height;
	var borderWidth:Number = 2;
	var marginWidth:Number = 8;
	evt.scale = 20;
	// draw a white rectangle with a black stroke around the images.
	evt.lineStyle(borderWidth, 0xEEEEEE, 100);
	evt.beginFill(0xFFFFFF, 100);
	evt.moveTo(-borderWidth-marginWidth, -borderWidth-marginWidth);
	evt.lineTo(thisWidth+borderWidth+marginWidth, -borderWidth-marginWidth);
	evt.lineTo(thisWidth+borderWidth+marginWidth, thisHeight+borderWidth+marginWidth);
	evt.lineTo(-borderWidth-marginWidth, thisHeight+borderWidth+marginWidth);
	evt.lineTo(-borderWidth-marginWidth, -borderWidth-marginWidth);
	evt.endFill();
	
	/* scale the target movie clip so it appears as a thumbnail. 
	   This allows users to quickly view a full image without downloading it every time, 
	   but unfortunaltey also causes a large initial download. */
	evt._xscale = evt.scale;
	evt._yscale = evt.scale;
	// rotate the current image (and borders) anywyhere from -5 degrees to +5 degrees.
	evt._rotation = Math.round(Math.random()*-10)+5;
	
	/* when the target_mc movie clip instance is pressed, begin to drag the current movie clip 
	   and set some temporary variables so once you are finished rescaling and positioning 
	   the full image, you can return the instance to its original position. */
	evt.onPress = function() {
		// start dragging the current clip.
		this.startDrag();
		/* set the _xscale and _yscale properties back to 100% so the image appears full sized. 
		   You're also storing the original X and Y coordinates so you can return the image where you found it. */
		//this._xscale = 100;
		//this._yscale = 100;
		this.varTween.stop();
		this.varTween = new Tween(this, "_xscale", Regular.easeOut, this._xscale, 100, 1.2, true);
		this.varTween1.stop();
		this.varTween1 = new Tween(this, "_yscale", Regular.easeOut, this._yscale, 100, 1.2, true);
		mx.transitions.TransitionManager.start(this, {type:mx.transitions.Fade, direction:0, duration:1.2, easing:mx.transitions.easing.Regular.easeOut, param1:empty, param2:empty});
		this.origX = this._x;
		this.origY = this._y;
		
		// find the depth of the current movie clip, and store it within the movie clip.
		this.origDepth = this.getDepth();
		/* :TRICKY: swap the depth of the current movie clip, with the next highest movie clip of the _parent. 
		   Effectively this makes the current movie clip the top of the "stack". */
		this.swapDepths(this._parent.getNextHighestDepth());
		// try and center the current movie clip on the Stage.
		//this._x = (_global.stageWidth-evt._width-300)/2;
		//this._y = (_global.stageHeight-evt._height-200)/2;
		this._x = _xmouse-80;
		this._y = _ymouse-80;
		// apply a transition to the movie clip which makes the movie clip flicker for a split second.
		//mx.transitions.TransitionManager.start(this, {type:mx.transitions.Photo, direction:0, duration:1, easing:mx.transitions.easing.Strong.easeOut, param1:empty, param2:empty});
	};
	/* when the movie clip instance is released, stop dragging the movie clip. 
	   Reset the _xscale and _yscale properties as well as the _x and _y coordinates. */
	evt.onRelease = function() {
		this.stopDrag();
		this.varTween.stop();
		this.varTween = new Tween(this, "_xscale", Regular.easeOut, this._xscale, 20, 0.8, true);
		this.varTween1.stop();
		this.varTween1 = new Tween(this, "_yscale", Regular.easeOut, this._yscale, 20, 0.8, true);
		//mx.transitions.TransitionManager.start(this, {type:mx.transitions.Rotate, direction:0, duration:0.8, easing:mx.transitions.easing.Regular.easeOut, param1:empty, param2:empty});
		//this._xscale = this.scale;
		//this._yscale = this.scale;
		this._x = this.origX;
		this._y = this.origY;
	};
	// if the mouse cursor was released outside of the movie clip, call the onRelease handler.
	evt.onReleaseOutside = evt.onRelease;
};

mcLoader_mcl.addListener(mclListener);
Пример взят из приложения Action Script который вместе с 8 Flash поставляется
Это пример без превьющек(я их не люблю).
Xml ,флешка и фотки лежат в одной директории

Старый 07.07.2008, 01:23
Wolsh вне форума Посмотреть профиль Отправить личное сообщение для Wolsh Найти все сообщения от Wolsh
  № 3  
Ответить с цитированием
Wolsh
Нуб нубам
 
Аватар для Wolsh

модератор форума
Регистрация: Jan 2006
Адрес: Бердск, НСО
Сообщений: 6,445
http://flasher.ru/forum/showthread.php?t=112985
__________________
Reality.getBounds(this);

Старый 08.07.2008, 01:29
M.™ вне форума Посмотреть профиль Отправить личное сообщение для M.™ Найти все сообщения от M.™
  № 4  
Ответить с цитированием
M.™
[+4 18.07.08]

Регистрация: Sep 2006
Сообщений: 39
to Wolsh, scarbo
спасибо огромное, а можно ли таким макаром загружать в флэшку другую флэшку.
Пример: у меня есть сайт, сделанный полностью во флэши, но в нем куча всяких примочек, которые делают её очень здоровой....что мешает ей быстрее загружать с интернета.....

Старый 08.07.2008, 01:41
scarbo вне форума Посмотреть профиль Отправить личное сообщение для scarbo Найти все сообщения от scarbo
  № 5  
Ответить с цитированием
scarbo
 
Аватар для scarbo

Регистрация: Jun 2008
Адрес: курский вокзал
Сообщений: 1,114
да конечно,без проблем.Самое простое так:
Код:
mcl:MovieClipLoader = new MovieClipLoader();
mcl.loadMovie("tvoi.swf", cont_mc);//где cont_mc-клип куда грузишь

Старый 08.07.2008, 01:56
M.™ вне форума Посмотреть профиль Отправить личное сообщение для M.™ Найти все сообщения от M.™
  № 6  
Ответить с цитированием
M.™
[+4 18.07.08]

Регистрация: Sep 2006
Сообщений: 39
ок спасибо...

Старый 08.07.2008, 13:17
olexandr вне форума Посмотреть профиль Отправить личное сообщение для olexandr Посетить домашнюю страницу olexandr Найти все сообщения от olexandr
  № 7  
Ответить с цитированием
olexandr
 
Аватар для olexandr

Регистрация: Aug 2007
Адрес: Ukraine, Kyiv
Сообщений: 643
Отправить сообщение для olexandr с помощью ICQ Отправить сообщение для olexandr с помощью MSN Отправить сообщение для olexandr с помощью Skype™
Цитата:
Сообщение от scarbo Посмотреть сообщение
да конечно,без проблем.Самое простое так:
Код:
mcl:MovieClipLoader = new MovieClipLoader();
mcl.loadMovie("tvoi.swf", cont_mc);//где cont_mc-клип куда грузишь
и что из этого получится? может, loadClip все таки?
__________________
сайт, vk

Создать новую тему Ответ Часовой пояс GMT +4, время: 09:31.
Быстрый переход
  « Предыдущая тема | Следующая тема »  

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

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


 


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


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