1. создаём папку img в неё кидаем те jpg которые тебе нужны...
2. воздаём файл data.txt, в нём пишем
Код:
img0=flower&img1=liliya&img2=rouse&img3=tulpan&img4=vetochka
причём flower, liliya это названия файлов без разширения.
3. создаём flash->file->new и впервом фрейве пишем
Код:
System.useCodepage = 1;
var _url_ = "data.txt",
n = 5,
t,
image_path;
//ImageViewer = function (target,depth, x, y, w, h, borderThickness, borderColor) {
var img_ = new ImageViewer(this, 3, 60, 20, 150, 30, 2, 0x000000);
_root.createEmptyMovieClip('temp', 1);
with (_root.temp) {_x = 50;_y = 20;}
data_ = new LoadVars();
data_.load(_url_);
data_.onLoad = function(success) {
if (success) {
with (_root.data_) {
t = random(n);
image_path="img/"+eval("img"+t)+".jpg";
}
trace(image_path+"\r"+t);
img_.loadImage(image_path);
}
};
MovieClip.prototype.drawRect = function (x, y, w, h, RGB, alpha) {
this.moveTo(x, y);
this.beginFill(RGB, alpha);
this.lineTo(x+w, y);
this.lineTo(x+w, y+h);
this.lineTo(x, y+h);
this.lineTo(x, y);
this.endFill;
};
_global.ImageViewer = function (target, depth, x, y, w, h, borderThickness, borderColor){
this.borderThickness = borderThickness;
this.borderColor = borderColor;
this.target_mc = target;
var imgViewer = this;
this.target_mc.createEmptyMovieClip("container_mc" + depth, depth);
this.container = this.target_mc["container_mc" + depth];
with(this.container){
_x = x;
_y = y;
createEmptyMovieClip("imageHolder_mc", 0);
imageHolder_mc._visible = false;
createEmptyMovieClip("border_mc", 1);
border_mc.lineStyle(borderThickness, borderColor);
border_mc.drawRect(0, 0, w, h);
createEmptyMovieClip("mask_mc", 2);
mask_mc.drawRect(0, 0, w, h, 0x0000FF, 100);
mask_mc._visible = false;
}
}
_global.ImageViewer.prototype.loadImage = function (URL) {
if (typeof this.container.imageHolder_mc.image_mc != "movieclip") {
this.container.imageHolder_mc.image_mc.removeMovieClip();
}
this.container.imageHolder_mc.createEmptyMovieClip("image_mc", 1);
var imgViewer = this;
var image = this.container.imageHolder_mc.image_mc;
var loadCheckID;
image.loadMovie(URL);
loadCheckID = setInterval(preloadImage, 100, getTimer());
this.container.createTextField("loadStatus_txt", 3, 0, 0, 0, 0);
with(this.container.loadStatus_txt){
background = true;
border = true;
setNewTextFormat(new TextFormat("Arial, Helvetica, _sans", 10, imgViewer.borderColor, false, false, false, null, null, "right"));
autoSize = "left";
text = "LOADING";
_y = 3;
_x = 3;
}
function preloadImage (startLoadTime) {
var largestBorderDimension;
var imageScaleFactor;
if (image.getBytesTotal() > 4) {
imgViewer.container.loadStatus_txt.text = "LOADING: "
+ Math.floor(image.getBytesLoaded() / 1024)
+ "/" + Math.floor(image.getBytesTotal() / 1024) + " KB";
}
if (image.getBytesTotal() > 4 && image.getBytesLoaded() == image.getBytesTotal()) {
clearInterval(loadCheckID);
with(imgViewer.container){
loadStatus_txt.removeTextField();
border_mc.clear();
border_mc.lineStyle(imgViewer.borderThickness, imgViewer.borderColor);
border_mc.drawRect(0, 0, image._width, image._height);
mask_mc.drawRect(0, 0, image._width, image._height, 0xFFFFFF, 100);
imageHolder_mc.setMask(imgViewer.container.mask_mc);
imageHolder_mc._visible = true;
}
} else if ((image.getBytesTotal() < 4)
&& (getTimer() - startLoadTime > 7000)) {
imgViewer.container.loadStatus_txt.text = "ERROR LOADING IMAGE";
clearInterval(loadCheckID);
}
}
}
|