A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Loading ranom image on slideshow

  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.

  2. #2
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,930
    Add this function into your script:

    Code:
    Array.prototype.randomizeArray = function() {
    	return this.sort(function (a, b) {
    	return (Math.floor(Math.random()*2) == 0) ? 1 : -1;
    	});
    };
    and then, after your array is loaded and when it's reset, call the function:
    Code:
    myphotos.randomizeArray();
    The png files seem to transition smoothly for me...Might be a processor issue since they have the extra alpha channel vs. the jpg images. You may want to preload them offstage before starting the slideshow...

    Hope that helps!
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

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

    Post

    this is my .fla can u tell me where i hav to put the code

    and see the transition is not smooth with only PNG due to transparency,
    can we transition luke crossfading effect which will look smooth.

    thanks
    Attached Files Attached Files

  4. #4
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,930
    here u go...
    Last edited by flashpipe1; 04-30-2009 at 10:42 AM.
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

  5. #5
    Junior Member
    Join Date
    Feb 2008
    Posts
    23
    thanks a lot dude
    thanku very much

    great

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

    show hide photgallery left right navigation btn

    hi,

    i lhav lil problem when i navigating through buttons, hiding showing of buttons work perfectly
    but when navigating by only clicking top images that showing hiding of buttons not taking place.

    and without clickin below left right button first click on leftmost image then click below left btn & then and without clickin right button click on right most then click on below right btn then both the buttons r hided.

    hope u understand what i saying

    is there any solution for this buddy

    thanks
    Attached Files Attached Files

  7. #7
    Junior Member
    Join Date
    Feb 2008
    Posts
    23
    Quote Originally Posted by flashpipe1
    here u go...
    in which i need one liitle addition from yourside

    suppose i have total 20 images,in which i want to show only any 10 images randomly in slideshow,

    can u tell me what will be the script for that.

    thanks

  8. #8
    Junior Member
    Join Date
    Feb 2008
    Posts
    23
    Quote Originally Posted by flashpipe1
    here u go...
    i got a error there in server after some time ur code in server only showing one image at a time.

    did u not one thing the fadein fadeout is not properonly the top image is going 100 to 0,the behind image is comming suddenly.
    for more clarification use bigger png transparent files.

    for this where i hav to change buddy

    thanks

  9. #9
    supervillain gerbick's Avatar
    Join Date
    Jul 2000
    Location
    undecided.
    Posts
    18,979
    neeraj... I think you're asking a lot of questions that if you were a client, I'd put you on ignore until you:
    [1] made up your mind and stated clearly what you need
    [2] stop changing your requirements
    [3] commit to one set of questions
    The main reason I state this isn't to be "mean", but you're asking a person to go from helping/assisting you - which these forums are made for - to asking somebody fully to do your work without pay and/or clarity.

    Think about what you want, what you have - in terms of images, materials, technology, ability, etc. - and what you're truly wanting.

    Make sure that you stick with one set of expectations, and that will help you out greatly at completing what originally started as a very simple question but has now blown into a full-on project.

    Best of luck; clarity is your friend. And right now, it's not clear what you want... your last three posts definitely don't seem to be even in the same request type.


    [ Hello ] | [ gerbick ] | [ Ω ]

  10. #10
    Junior Member
    Join Date
    Feb 2008
    Posts
    23
    dont take it in a wrong way.
    i'll be take care next time,sorry for ur inconvinience
    Regards

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