A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: Problem with AS in slideshow

  1. #1
    Senior Member gkbdave's Avatar
    Join Date
    Nov 2000
    Location
    Fort Bragg, NC
    Posts
    304

    Problem with AS in slideshow

    I was following a tutorial on Kirupa. The basic slideshow one. It works fine until I load the swf into a empty movie clip in another movie. It will only show the first picture, it doesn't even show the mask that I made either. Just the picture. If I open the slideshow swf it plays just fine. All the files and folder are in the same directory.

    Any ideas? Here is the code:

    this.pathToPics = "pics/";

    this.pArray = ["0.jpg", "1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg", "6.jpg", "7.jpg", "8.jpg", "9.jpg", "10.jpg", "11.jpg", "12.jpg", "13.jpg", "14.jpg", "15.jpg", "16.jpg", "17.jpg", "18.jpg", "19.jpg"];
    this.fadeSpeed = 20;
    this.pIndex = 0;

    loadMovie(this.pathToPics+this.pArray[0], _root.photo);
    MovieClip.prototype.changePhoto = function(d) {
    // make sure pIndex falls within pArray.length
    this.pIndex = (this.pIndex+d)%this.pArray.length;
    if (this.pIndex<0) {
    this.pIndex += this.pArray.length;
    }
    this.onEnterFrame = fadeOut;
    };
    MovieClip.prototype.fadeOut = function() {
    if (this.photo._alpha>this.fadeSpeed) {
    this.photo._alpha -= this.fadeSpeed;
    } else {
    this.loadPhoto();
    }
    };
    MovieClip.prototype.loadPhoto = function() {
    // specify the movieclip to load images into
    var p = _root.photo;
    //------------------------------------------
    p._alpha = 0;
    p.loadMovie(this.pathToPics+this.pArray[this.pIndex]);
    this.onEnterFrame = loadMeter;
    };
    MovieClip.prototype.loadMeter = function() {
    var i, l, t;
    l = this.photo.getBytesLoaded();
    t = this.photo.getBytesTotal();
    if (t>0 && t == l) {
    this.onEnterFrame = fadeIn;
    } else {
    trace(l/t);
    }
    };
    MovieClip.prototype.fadeIn = function() {
    if (this.photo._alpha<100-this.fadeSpeed) {
    this.photo._alpha += this.fadeSpeed;
    } else {
    this.photo._alpha = 100;
    this.onEnterFrame = null;
    }
    };

    this.onKeyDown = function() {
    if (Key.getCode() == Key.LEFT) {
    this.changePhoto(-1);
    } else if (Key.getCode() == Key.RIGHT) {
    this.changePhoto(1);
    }
    };
    Key.addListener(this);

  2. #2
    Registered User Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    Probably this reference to _root;

    loadMovie(this.pathToPics+this.pArray[0], _root.photo);

    It's no longer _root.photo when you load to an empty clip in another movie. You have to add the instance name of the empty clip;

    loadMovie(this.pathToPics+this.pArray[0], _root.mtClip.photo);

  3. #3
    Senior Member gkbdave's Avatar
    Join Date
    Nov 2000
    Location
    Fort Bragg, NC
    Posts
    304
    thanks IaskWhy..

    I tried what you said and now the slideshow swf doesn't work.

    It did load into the empty movie clip, however wouldn't let me change photos.

  4. #4
    Senior Member gkbdave's Avatar
    Join Date
    Nov 2000
    Location
    Fort Bragg, NC
    Posts
    304
    I am baffled.. i have tried everything.. I thought it may have to do with the coding on the buttons which is:

    on (release) {
    _root.changePhoto(1);
    }

    they don't do anything when loaded into the empty MC. Works fine when tested.

    Hope your still out there IaskWhy.. thanks for the help..

  5. #5
    Registered User Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    What version of Flash are you using?

  6. #6
    Senior Member gkbdave's Avatar
    Join Date
    Nov 2000
    Location
    Fort Bragg, NC
    Posts
    304
    I am using MX Pro 2004..

  7. #7
    Registered User Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    In the slideshow movie, go back to the original code. In frame 1 of the movie, add this line at the top of frame 1;

    this._lockroot = true;

    That should force the slideshow movie to use it's own root code and still work when loaded to another movie.

  8. #8
    Senior Member gkbdave's Avatar
    Join Date
    Nov 2000
    Location
    Fort Bragg, NC
    Posts
    304
    YES!!!! Thanks very much IaskWhy..

    Can I ask one more quick question.. I have a 4 buttons that load dynamic text into a textbox. They work fine.. just want to have the first one loaded already when the user gets to that screen. I am sure its just one little piece of code but can't seem to find it anywhere..
    here is what i have so far on each button, but want one to have the text already loaded..:

    on (release) {
    loadText = new LoadVars();
    loadText.load ("meetinfo.txt");
    loadText.onLoad = function (success)
    {
    if (success)
    {
    // trace(success);
    infoBox.html = true;
    infoBox.htmlText = this.info;
    }
    };
    }

  9. #9
    Registered User Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    Try typeing in what you want it to say when it loads. I mean in flash when your editing it. It should stay there till the code tells it to say something else.

  10. #10
    Senior Member gkbdave's Avatar
    Join Date
    Nov 2000
    Location
    Fort Bragg, NC
    Posts
    304
    Ok.. I understand what your saying.. but was hoping for it to load the first txt file.. Then as each button is clicked it will load them...

    Thanks again.. your a lifesaver

  11. #11
    Registered User Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    You can make it do that. Just take that code out of the button and put it in frame 1.

    loadText = new LoadVars();
    loadText.load ("meetinfo.txt");
    loadText.onLoad = function (success)
    {
    if (success)
    {
    // trace(success);
    infoBox.html = true;
    infoBox.htmlText = this.info;
    }
    };

  12. #12
    Senior Member gkbdave's Avatar
    Join Date
    Nov 2000
    Location
    Fort Bragg, NC
    Posts
    304
    Thanks I will try that at work tomorrow..
    Thanks again for the help...

  13. #13
    Senior Member gkbdave's Avatar
    Join Date
    Nov 2000
    Location
    Fort Bragg, NC
    Posts
    304
    You Rock IaskWhy......


    Thanks works great... I kinda figured I could use that same code.. but wasn't exactly sure.. thanks again for your help..

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