![]() |
|
||||||||||
|
|||||||
|
|
« Предыдущая тема | Следующая тема » |
| Опции темы | Опции просмотра |
|
![]() |
![]() |
|
|||||
|
[+1.3 29.09.06]
Регистрация: Jun 2005
Адрес: the middle of nowhere...
Сообщений: 92
|
www.skip1.nm.ru/album.rar
вот исходник, никак не получается скролл превьюшек картинок который справа, беда в том что это все дело не упаковано в отдельный мувик а генерится прямо на рут, помогите если не влом, хотябы запихнуть превьюшки в отдельный мувик... пожаааалста!! =)
__________________
things I do for love... |
|
|||||
|
А зачем ты в архив запихал файл тумбс,
который весит 900к? |
|
|||||
|
Modus ponens
|
эта... там разбираться - очень долго и скучно, и не интересно....
Вот нарыл из своих старых экспериментов, в принципе все работало без глюков даже вроде... К сожалению там в коде будет немного лишнего и почти никаких каментов, ну так сложилось, если будешь пользовать - спрашивай тут. класс для загрузки ХМЛя и частичной разборки /**
* This class loads XML.
* It has these methods:
* get_length() - returns the number of the childnodes in the root node.
* get_anyVal() - returns a value of the attribute at the specified node
* get_node() - returns an XML produced by parsing specific childnode of the loaded XML.
*/
class XMLLoader extends XML {
var watchedNode:XML;
function XMLLoader(_str:String) {
this.ignoreWhite = true;
watchedNode = this;
this.onLoad = function(ok:Boolean) {
if (ok) {
overLoad();
}
};
this.load(_str);
}
public function overLoad(){};
public function get_val(_str:String, nd:Number):String {
return watchedNode.childNodes[0].childNodes[nd].attributes[_str];
}
public function get_length():Number {
return watchedNode.childNodes[0].childNodes.length;
}
public function get_node(n:Number):XML {
var tmp_xml:XML = new XML();
var found:Boolean = false;
tmp_xml.parseXML(watchedNode.toString());
for (var i = 0; i<tmp_xml.childNodes[0].childNodes.length; i++) {
if (tmp_xml.childNodes[0].childNodes[i].attributes.name == n.toString()) {
tmp_xml.parseXML(tmp_xml.childNodes[0].childNodes[i]);
found = true;
break;
}
}
if (!found) {
tmp_xml = null;
}
return tmp_xml;
}
public function get_anyVal(_str:String, _arr:Array):String {
var tmp_xml:XML = new XML(this.watchedNode.childNodes[0].toString());
var tmp_nd:XMLNode = tmp_xml;
var tmp_str:String = "";
for (var i:Number = 0; i<_arr.length; i++) {
if (tmp_nd.childNodes[_arr[i]] != null) {
tmp_nd = tmp_nd.childNodes[_arr[i]];
}
}
tmp_str = tmp_nd.attributes[_str];
return tmp_str;
}
}
Этот класс загружает картинки /**
* This class loads pictures.
*/
import mx.events.EventDispatcher;
class PicLoader extends MovieClipLoader {
var l_obj:Object = {};
function PicLoader(mc:MovieClip, _str:String, dim:Object) {
var tgt:MovieClip = mc;
var w:Number = mc._width;
var h:Number = mc._height;
var d:Object = dim;
this.l_obj = {tgt:this};
EventDispatcher.initialize(this.l_obj);
this.l_obj.onLoadComplete = function(mc:MovieClip) {
var dd:Object = d;
var lo:Object = this;
mc._done = false;
mc.onEnterFrame = function() {
mc._height = dd.h;
mc._width = dd.w;
if (mc._height != 0 && mc._width == dd.w) {
mc._done = true;
}
if (mc._done) {
this._parent.onResized();
this.dispatchEvent({type:this.event});
delete this.onEnterFrame;
}
};
};
l_obj.onDone = this.onDone;
this.addListener(this.l_obj);
this.loadClip(_str, tgt);
}
function onDone() {
}
}
_root._gp._ug - путь к объекту галлереи, знаю, что криво, но уж как получилось =) /**
* This class is a part of the slideshow (pictures gallery)
* it creates a bar with prewievs
* It has the following methods:
* slide() - moves the previews to the left/right
* freez() - stops moving previews
* onSliderLoad() - returns an array of the properties of the first loaded preview
*/
class USlider extends MovieClip {
var Ubody:MovieClip;
var Umask:MovieClip;
var Uholder:MovieClip;
var x_loader:XMLLoader;
var p_loader:PicLoader;
var finished:Boolean = false;
var fstNode:Number = -1;
function USlider(mc:MovieClip, coord:Object, nd:Number) {
this.Ubody = mc.attachMovie("rect", "Ubody", mc.getNextHighestDepth());
this.Ubody._width = coord.W;
this.Ubody._height = coord.H;
this.Ubody._alpha = 0;
this.Uholder = mc.createEmptyMovieClip("Uholder", mc.getNextHighestDepth());
with (this.Uholder) {
beginFill(0xffffff, 1);
moveTo(0, 0);
lineTo(coord.W, 0);
lineTo(coord.W, coord.H);
lineTo(0, coord.H);
lineTo(0, 0);
endFill();
}
this.Umask = mc.createEmptyMovieClip("Umask", mc.getNextHighestDepth());
with (this.Umask) {
beginFill(0xffffff, 1);
moveTo(0, 0);
lineTo(coord.W, 0);
lineTo(coord.W, coord.H);
lineTo(0, coord.H);
lineTo(0, 0);
endFill();
}
this.Uholder.setMask(this.Umask);
x_loader = new XMLLoader("xmldata/en_image.xml");
var tgt:MovieClip = this.Uholder;
tgt.fn = this.fstNode;
tgt._hd = "$";
tgt._ds = "$";
tgt.fd = this.finished;
var n:Number = nd;
x_loader.overLoad = function() {
var _xml:XML = this.get_node(n);
var ld:Number = 0;
var i:Number = 1;
var vn:XMLLoader = this;
tgt.onEnterFrame = function() {
if (ld<i) {
var w_xml:XMLNode = _xml.childNodes[0].childNodes[ld];
var nm:String = w_xml.attributes["name"];
var hd:String = w_xml.attributes["heading"];
var ds:String = w_xml.attributes["des"];
var preview:MovieClip = tgt.attachMovie("rect", "rect"+i, tgt.getNextHighestDepth(), {_x:ld*75+2.5, _y:2.5});
preview._width = 70;
preview._height = 70;
var p_loader = new PicLoader(preview, "album/"+nd+"/small/"+nm+".jpg", {h:preview._height, w:preview._width});
ld++;
}
p_loader.onLoadComplete = function(mc:MovieClip) {
(tgt._width);
mc._parent.fn == -1 ? mc._parent.fn=Number(nm) : "";
mc._parent._hd == "$" ? mc._parent._hd=hd : "";
mc._parent._ds == "$" ? mc._parent._ds=ds : "";
mc._nm = nm;
mc._hd = hd;
mc._ds = ds;
mc._n = n;
_root._gp._ug.updPreText(i, _xml.childNodes[0].childNodes.length);
i++;
mc.onRelease = function() {
_root._gp._ug.changePict(this._nm, this._n, [this._hd, this._ds]);
};
};
if (ld>=_xml.childNodes[0].childNodes.length) {
this.fd = true;
delete this.onEnterFrame;
}
};
};
}
function slide(dir:Boolean):Void {
var step = 6;
if (dir) {
this.Uholder.onEnterFrame = function() {
this._x += step;
if (this._x>0) {
this._x = 0;
delete this.onEnterFrame;
}
};
} else {
this.Uholder.onEnterFrame = function() {
this._x -= step;
if (this._x+this._width<this._parent.Umask._width-2.5) {
this._x = this._parent.Umask._width-this._width-2.5;
delete this.onEnterFrame;
}
};
}
}
function freez():Void {
delete this.Uholder.onEnterFrame;
}
function onSliderLoad():Array {
if (this.Uholder.fd) {
return [this.Uholder.fn, this.Uholder._hd, this.Uholder._ds];
} else {
return [-1, "$", "$"];
}
}
}
__________________
Hell is the possibility of sanity |
|
|||||
|
Modus ponens
|
Непосредственно класс галлереи
/**
* Slideshow/picture gallery class, a part of the inner page cunstruction classes.
* Constructs a slideshow (gallery).
* It has the changePict() method. Which changes the currently dysplayed picture.
*/
class UGallery extends MovieClip {
var u_slider:USlider;
var Ubody:MovieClip;
var u_pic:MovieClip;
var slid_holder:MovieClip;
var nex_arr:MovieClip;
var pre_arr:MovieClip;
var ct:Number = -1;
var desc:TextField;
var _eye:MovieClip;
var _cam:MovieClip;
var prl_txt:TextField;
function UGallery(mc:MovieClip, cat:Number) {
var ct = cat;
this.Ubody = mc.attachMovie("rect", "Ubody", mc.getNextHighestDepth());
with (this.Ubody) {
_width = 780;
_height = 370;
_alpha = 0;
}
this.u_pic = mc.attachMovie("rect", "u_pic", mc.getNextHighestDepth());
with (this.u_pic) {
_x = Stage.width/2;
_y = 110;
_alpha = 0;
}
this.desc = mc.createTextField("desc", mc.getNextHighestDepth(), 550, 130, 170, 190);
with (this.desc) {
html = true;
multiline = true;
wordWrap = true;
styleSheet = SuperString._css();
}
this.u_pic.holder = this.u_pic.attachMovie("rect", "holder", this.u_pic.getNextHighestDepth());
this.u_pic.holder._height = 190;
this.u_pic.holder._width = 190;
this.u_pic.onEnterFrame = function() {
var _arr:Array = slid.onSliderLoad();
var _str:String = _arr[0];
if (_str>-1) {
this._hd = _arr[1];
this._ds = _arr[2];
this._parent.desc.htmlText = "<p>"+_arr[1]+"</p><p>"+_arr[2]+"</p>";
var p_loader = new PicLoader(this.holder, "album/"+ct+"/"+_str+".jpg", {h:this.holder._height, w:this.holder._width});
p_loader.onDone = function() {
};
delete this.onEnterFrame;
}
};
this.u_pic.onResized = function() {
this.holder._xscale = this.holder._yscale;
this._x = Stage.width/2-this._width/2;
this._alpha = 100;
};
this.slid_holder = mc.createEmptyMovieClip("slid_holder", mc.getNextHighestDepth());
with (this.slid_holder) {
_x = 177;
_y = 320;
}
this.u_slider = new USlider(this.slid_holder, {W:440, H:74}, cat);
var slid:USlider = this.u_slider;
this.nex_arr = mc.attachMovie("slider_arr", "nex_arr", mc.getNextHighestDepth());
with (nex_arr) {
_y = 345;
_x = Stage.width-150;
}
this.nex_arr.onPress = function() {
slid.slide(false);
};
this.nex_arr.enabled = false;
this.pre_arr.enabled = false;
this.nex_arr.onRelease = function() {
slid.freez();
};
this.pre_arr = mc.attachMovie("slider_arr", "pre_arr", mc.getNextHighestDepth());
with (pre_arr) {
_y = 345+_height;
_x = 150+_width;
_rotation = 180;
}
this.pre_arr.onPress = function() {
slid.slide(true);
};
this.pre_arr.onRelease = function() {
slid.freez();
};
this._eye = mc.attachMovie("eye_b", "_eye", mc.getNextHighestDepth());
with (this._eye) {
_x = 180;
_y = 280;
}
this._cam = mc.attachMovie("camera_b", "_eye", mc.getNextHighestDepth());
with (this._cam) {
_x = 210;
_y = 280;
}
this.prl_txt = mc.createTextField("prl_txt", mc.getNextHighestDepth(), 185, 300, 410, 20);
with (this.prl_txt) {
html = true;
multiline = true;
wordWrap = true;
styleSheet = SuperString._css();
}
}
function changePict(_str:String, n:Number, _arr:Array) {
this.desc.htmlText = "<p>"+_arr[0]+"</p><p>"+_arr[1]+"</p>";
var p_loader = new PicLoader(this.u_pic.holder, "album/"+n+"/"+_str+".jpg", {h:this.u_pic.holder._height, w:this.u_pic.holder._width});
}
function updPreText(_n:Number, _n1:Number):Void {
this.prl_txt.htmlText = "<p class='ctr'>Pictures "+_n.toString()+" of "+_n1.toString()+" loaded";
if (_n == _n1) {
this.nex_arr.enabled = true;
this.pre_arr.enabled = true;
this.prl_txt.htmlText = "";
}
}
}
Для того, чтобы создать галлерею в библиотеке должны быть мувики с линкеджем "rect", "slider_arr", там еще были какие-то eye_b, camera_b - это мусор какой-то, они не нужны... Там еще по ходу могут попадаться ссылки на класс SuperString типа SuperString._css(); - просто поубивать, или заменить на что-то свое =) ХМЛ лежит в папке xmldata на уровень ниже самой флешки, кроме этого, так же на уровень ниже флешки нужна папка album, в нем папки: имя папки = название категории в ХМЛе, в каждой папке есть еще одна папка для превьюх (превьюхи и большие картинки соответственно называются одинаково) Ну и наконец пример ХМЛя (не бейте, я тут вообще ни при чем, мне такой дали %) Этот описыват картинки <images> <cat name="1"> <img name="375" heading="heading#1" des="Picture description" /> <img name="376" heading="heading#2" des="Picture description" /> <img name="377" heading="heading#3" des="Picture description" /> <img name="378" heading="heading#4" des="Picture description" /> <img name="379" heading="heading#5" des="Picture description" /> <img name="380" heading="heading#6" des="Picture description" /> <img name="381" heading="heading#7" des="Picture description" /> <img name="382" heading="heading#8" des="Picture description" /> <img name="383" heading="heading#9" des="Picture description" /> <img name="385" heading="heading#10" des="Picture description" /> <img name="386" heading="heading#11" des="Picture description" /> <img name="387" heading="heading#12" des="Picture description" /> <img name="388" heading="heading#13" des="Picture description" /> </cat> </images> (в случае, если интерфейс позволяет добавлять\создавать дополнительные категории) Эта ситуаци я в коде выше никак не освещена, и так много писанины, но если надо, то и такая возможность имеется =)
__________________
Hell is the possibility of sanity |
|
|||||
|
[+1.3 29.09.06]
Регистрация: Jun 2005
Адрес: the middle of nowhere...
Сообщений: 92
|
мдя я пока не очень продвинутый кодер для таких обьемов, но попробую разобраться... спасибо
__________________
things I do for love... |
![]() |
![]() |
Часовой пояс GMT +4, время: 13:15. |
|
|
« Предыдущая тема | Следующая тема » |
| Опции темы | |
| Опции просмотра | |
|
|