A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: help me get this MX code to Flash 5 ?

  1. #1
    Help Seeker
    Join Date
    Jun 2000
    Location
    NY
    Posts
    94

    help me get this MX code to Flash 5 ?

    I've got the gallery working according to this tutorial: here but it's for MX only (even though a Flash 5 FLA exists - it's got the same MX code).

    Can someone help me with converting this code into Flash 5 code ? I think it has something to do with addListener at the end (since I believe it's MX-only)... can someone help pls ?

    // variables ------------------------------------------
    // put the path to your pics here, include the slashes (ie. "pics/")
    // leave it blank if they're in the same directory
    this.pathToPics = "pics/";
    // fill this array with your pics
    this.pArray = ["01.jpg", "02.jpg", "03.jpg", "04.jpg", "05.jpg"];
    this.fadeSpeed = 20;
    this.pIndex = 0;
    // MovieClip methods ----------------------------------
    // d=direction; should 1 or -1 but can be any number
    //loads an image automatically when you run animation
    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;
    }
    };
    // Actions -----------------------------------------
    // these aren't necessary, just an example implementation
    this.onKeyDown = function() {
    if (Key.getCode() == Key.LEFT) {
    this.changePhoto(-1);
    } else if (Key.getCode() == Key.RIGHT) {
    this.changePhoto(1); //The MX buttons use on(release) --> _root.changephoto(1)
    }
    };
    Key.addListener(this);

    Thanks in advance!

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    this.onEnterFrame = loadMeter;
    this.onEnterFrame = null;

    that syntax (also the addListener) is MX. Put the actions controlled by the onEnterFrame on a controller clip with an enterFrame clip event.

    Also, to see loaded jpegs, you anyway need the flash6 player.. In flash5 you should use swfs containing the jpgs instead.
    gparis

  3. #3
    Help Seeker
    Join Date
    Jun 2000
    Location
    NY
    Posts
    94
    Thanks for that... I will have to try and figure that out... but only if I get tips on the addListener portion too.

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    you simply don't use listeners for key Events in F5.
    that's it.
    gparis

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