Article View: alt.pl.programy.flash-5
Article #34206Galeria, ktos wie?
From: M.jp
Date: Sat, 19 May 2007 16:04
Date: Sat, 19 May 2007 16:04
121 lines
4851 bytes
4851 bytes
Witam. Mam poniลผej skrypt kt wczytuje dynamicznie galerie.
Obecnie dziala to tak: galeria wczytuje miniatury, po kliknieciu w
ktoras z nich wczytuje sie 100% obrazka.
Problem w tym iz po kliknieciu w te 100% obrazek powinien sie schowac.
Na samym spodzie jest rozwiazanie tylko ze z onRelease... Jak
przelozyc to rozwiazanie na OnPress?
-------------------------------
import mx.transitions.*;
_global.thisX = 0;
_global.thisY = 0;
_global.stageWidth = 300;
_global.stageHeight = 100;
var gallery_xml:XML = new XML();
gallery_xml.ignoreWhite = true;
gallery_xml.onLoad = function(success:Boolean) {
try {
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});
}
} else {
throw new Error("Unable to parse XML");
}
} catch (e_err:Error) {
trace(e_err.message);
} finally {
delete this;
}
};
gallery_xml.load("galeria.xml");
function displayGallery(gallery_array:Array) {
var galleryLength:Number = gallery_array.length;
for (var i = 0; i<galleryLength; i++) {
var thisMC:MovieClip = this.createEmptyMovieClip("image"+i+"_mc",
i);
mcLoader_mcl.loadClip(gallery_array[i].src,thisMC);
preloaderMC = this.attachMovie("preloader_mc", "preloader"+i+"_mc",
5000+i);
preloaderMC.bar_mc._xscale = 0;
preloaderMC.progress_txt.text = "0%";
thisMC._x = _global.thisX;
thisMC._y = _global.thisY;
preloaderMC._x = _global.thisX;
preloaderMC._y = _global.thisY+5;
if ((i+1)%4 == 0) {
_global.thisX = 0;
_global.thisY += 80;
} else {
_global.thisX += 90+20;
}
}
}
var mcLoader_mcl:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mclListener.onLoadStart = function() {
};
mclListener.onLoadProgress = function(target_mc, loadedBytes,
totalBytes) {
var pctLoaded:Number = Math.round(loadedBytes/totalBytes*100);
var preloaderMC = target_mc._parent["preloader"+target_mc.getDepth()
+"_mc"];
preloaderMC.bar_mc._xscale = pctLoaded;
preloaderMC.progress_txt.text = pctLoaded+"%";
};
mclListener.onLoadInit = function(evt:MovieClip) {
evt._parent["preloader"+evt.getDepth()+"_mc"].removeMovieClip();
var thisWidth:Number = evt._width;
var thisHeight:Number = evt._height;
var borderWidth:Number = 2;
var marginWidth:Number = 7;
evt.scale = 14;
evt.lineStyle(borderWidth,0x000000,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();
evt._xscale = evt.scale;
evt._yscale = evt.scale;
evt.onPress = function() {
trace(this+" info");
this._xscale = 100;
this._yscale = 100;
this.origX = this._x;
this.origY = this._y;
this.origDepth = this.getDepth();
this.swapDepths(this._parent.getNextHighestDepth());
this._x = (_global.stageWidth-evt._width-50)/2;
this._y = (_global.stageHeight-evt._height-50)/2;
mx.transitions.TransitionManager.start(this,
{type:mx.transitions.Photo, direction:0, duration:1,
easing:mx.transitions.easing.Strong.easeOut, param1:empty,
param2:empty});
};
/* to jest funkcja kt robi dokladnie to o co pytam, jak przylozyc to
na powyzsze...?
evt.onRelease = function() {
this._xscale = this.scale;
this._yscale = this.scale;
this._x = this.origX;
this._y = this.origY;
};*/
};
mcLoader_mcl.addListener(mclListener);
Technical Details
Message-ID:
<1179590682.622506.241790@o5g2000hsb.googlegroups.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.glorb.com!postnews.google.com!o5g2000hsb.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.glorb.com!postnews.google.com!o5g2000hsb.googlegroups.com!not-for-mail From: "M.jp" <marcin.wla@gmail.com> Newsgroups: alt.pl.programy.flash-5 Subject: Galeria, ktos wie? Followup-To: alt.pl.programy.flash-5 Date: 19 May 2007 09:04:42 -0700 Organization: http://groups.google.com Lines: 122 Message-ID: <1179590682.622506.241790@o5g2000hsb.googlegroups.com> NNTP-Posting-Host: 83.11.16.128 Mime-Version: 1.0 X-Trace: posting.google.com 1179590691 5971 127.0.0.1 (19 May 2007 16:04:51 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 19 May 2007 16:04:51 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: o5g2000hsb.googlegroups.com; posting-host=83.11.16.128; posting-account=QeD9xA0AAACc3pcE7j1p_rasbG67xYNT Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit