dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [F8] on enterFrame problem!! please help

  1. #1
    Junior Member
    Join Date
    Apr 2008
    Posts
    22

    [F8] on enterFrame problem!! please help

    hello.

    I have buttons on the stage that when pressed resize a border to fit the dimensions of a photograph. this works fine.

    What i want is when the I test the movie in flash is for one of these images to already be visible on the stage. I know there is a simple solution to this.
    but i am stumped!!
    here is my code so far.

    space = 10;
    photo_mc._alpha = 0;

    MovieClip.prototype.loadPhoto = function(photo){
    photo_mc._alpha = 0;
    this.loadMovie(photo);
    _level0.onEnterFrame = function(){
    var total = Math.round(photo_mc.getBytesTotal()/100);
    var loaded = Math.round(photo_mc.getBytesLoaded()/100);

    // Principally the percentage was the problem
    var percentage:Number = Math.round((100/total)*loaded);
    percentDisplay.text = int(percentage) + "%";
    if (total != 0 && loaded>=total){
    var w = photo_mc._width + space;
    var h = photo_mc._height + space;
    border.resize(w, h);
    _level0.onEnterFrame =null;
    }
    }
    };
    MovieClip.prototype.resize = function(w, h){
    var speed = 4;
    this.onEnterFrame = function(){
    this._width += (w - this._width)/speed;
    this._height += (h - this._height)/speed;
    if(Math.abs(this._width-w)<1 && Math.abs(this._height-h)<1){
    this._width = w;
    this._height = h;
    photo_mc._x = this._x - this._width/2 + space/2;
    photo_mc._y = this._y - this._height/2 + space/2;
    photo_mc._alpha = 100;
    this.onEnterFrame=null;
    }
    }
    };

    btn1.onRelease = function() {
    photo_mc.loadPhoto("p.jpg");
    };
    btn2.onRelease = function() {
    photo_mc.loadPhoto("p2.jpg");
    };

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    to load p1.jpg (without button interaction) add to bottom line of your code -

    photo_mc.loadPhoto("p1.jpg");

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