A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Loading ranom image on slideshow

Threaded View

  1. #1
    Junior Member
    Join Date
    Feb 2008
    Posts
    23

    Loading ranom image on slideshow

    hii

    in this i need Random image in this Slideshow write now its coming in seqential order.
    can anybody help me in that,what will be the code for that ?
    for testing just paste this code on ur 1st frame & test it,


    2nd periority(low)
    can anybody help me to find out the issue which coming with PNG files on slideshow the fading in & OUT IS NOT SMOOTH. WITH JPG ITS WORKING FINE


    //AS-2 started
    // put the image name here
    photos = "1.png,2.png,3.png,4.png,5.png,6.png";

    interval = "6";
    _root.checkthisroot = true;
    if (checkthisroot) {
    Stage.scaleMode = "noScale";
    Stage.align = "TL";
    }
    if (defaultinterval == undefined) {
    defaultinterval = 6;
    } else {
    defaultinterval = Number(defaultinterval);
    }
    if (folder == undefined) {
    folder = "";
    }
    checkslash = function () {
    if (folder.length>0) {
    if (folder.charAt(folder.length-1) != "/") {
    folder += "/";
    }
    }
    };
    checkslash();
    if (datafile == undefined) {
    datafile = "inherit";
    }
    if (alphadelay == undefined) {
    alphadelay = 7;
    } else {
    alphadelay = Number(alphadelay);
    }
    if (loop == undefined) {
    loop = true;
    } else {
    if (loop == "true") {
    loop = true;
    } else {
    loop = false;
    }
    }
    if (clicktoreplay == undefined) {
    clicktoreplay = true;
    } else {
    if (clicktoreplay == "true") {
    clicktoreplay = true;
    } else {
    clicktoreplay = false;
    }
    }
    i = 0;
    photoindex = -1;
    showimage = true;
    nextimageloaded = false;
    waiting = false;
    checkvars = function () {
    if (photos == undefined) {
    getlist();
    } else {
    myphotos = photos.split(",");
    myinterval = interval.split(",");
    slide();
    }
    };
    getlist = function () {
    myvars = new LoadVars();
    myvars.onLoad = function(success) {
    if (success) {
    myphotos = this.photos.split(",");
    myinterval = this.interval.split(",");
    if (this.defaultinterval != undefined) {
    defaultinterval = Number(this.defaultinterval);
    }
    if (this.folder != undefined) {
    folder = this.folder;
    }
    checkslash();
    if (this.alphadelay != undefined) {
    alphadelay = Number(this.alphadelay);
    }
    if (this.loop != undefined) {
    if (this.loop == "true") {
    loop = true;
    } else {
    loop = false;
    }
    }
    if (this.clicktoreplay != undefined) {
    if (this.clicktoreplay == "true") {
    clicktoreplay = true;
    } else {
    clicktoreplay = false;
    }
    }
    slide();
    } else {
    trace("unsuccess");
    }
    };
    /*if (datafile == "inherit") {
    datafile = this._url.substr(0, _url.length-3)+"txt";
    }
    trace(datafile);
    myvars.load(datafile);*/
    };
    slide = function () {
    i++;
    photoindex++;
    if (photoindex == myphotos.length) {
    photoindex = 0;
    }
    var p = createEmptyMovieClip("photo"+i, i);
    p.createEmptyMovieClip("internal",1);
    loadMovie(folder+myphotos[photoindex], p.internal);
    p._alpha = 0;
    this.onEnterFrame = function() {
    var l = p.internal.getBytesLoaded();
    var t = p.internal.getBytesTotal();
    if (l == t) {
    preloader._visible = false;
    delete this.onEnterFrame;
    checkshow();
    }
    };
    };

    MovieClip.prototype.mfade = function() {
    this.a = this._alpha;
    this.onEnterFrame = function() {
    this.a += (100-this.a)/alphadelay*2;
    this._alpha = Math.round(this.a*1);
    if (100-this.a<2) {
    this.interval._alpha -= mytime;
    delete this.onEnterFrame;
    this.myinterval._alpha = 100;
    this._alpha = 100;//dikai dene ke baad alpha
    this._parent["photo"+(i-2)].mfadeOut.MovieClip();
    }
    };
    };
    //---------------------------------------
    MovieClip.prototype.mfadeOut = function() {
    this.b = this._alpha;
    this.onEnterFrame = function() {
    this.b += (0-this.b)/alphadelay;
    this._alpha = Math.round(this.b);
    if (0-this.b<2) {
    //delete this.FadeOut.onEnterFrame;
    this.myinterval._alpha = alphadelay;
    this._alpha = 0;//dikai dene ke baad alpha
    this._parent["photo"+(i-2)].removeMovieClip();
    }
    };
    };
    //------------------------------
    checkshow = function () {
    if (showimage || waiting) {
    showimage = false;
    waiting = false;
    this["photo"+i].mfade();
    if (myinterval[photoindex] != undefined) {
    mytime = Number(myinterval[photoindex])*1000;
    } else {
    mytime = Number(defaultinterval)*1000;
    }
    mycounter = setInterval(counter, mytime);
    if (photoindex<(myphotos.length-1) || loop) {
    slide();
    } else if (clicktoreplay) {
    this["photo"+i].onPress = function() {
    slide();
    };
    }
    } else {
    nextimageloaded = true;
    this["photo"+i].mfadeOut();
    }
    };

    counter = function () {
    clearInterval(mycounter);
    if (nextimageloaded) {
    nextimageloaded = false;
    showimage = true;
    checkshow();
    } else {
    waiting = false;
    }
    };
    checkvars();
    stop();

    //AS-2 ENDED


    thanks
    neeraj
    Attached Files Attached Files
    Last edited by neeraj8585; 07-03-2008 at 05:55 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center