onEnterFrame problem

Hey - I have a bunch of thumbnails i’m getting from XML that have this code on them…


for (e = 0; e < total; e++) {
    _root.web_thumbs.thumb_button.duplicateMovieClip("button" + e, e + 12);
    _root.web_thumbs["button" + e].c = e;
    _root.web_thumbs["button" + e].onEnterFrame = function() {
     if (web_thumbs["thumb" + c]._width == _root.thumbw) {
      this.onPress = function() {
       container.loadMovie(fullimg[this.c]);
      }
      this.hitTest(_root._xmouse, _root._ymouse, false) ? (this._alpha > 0 ? this._alpha -= 10 : null) : ((this._alpha < 55 ? this._alpha += 10 : null) || (this._alpha > 65 ? this._alpha -= 10 : null));
     }
    }
    _root.web_thumbs["button" + e]._x = _root.web_thumbs["thumb" + e]._x;
    _root.web_thumbs["button" + e]._y = _root.web_thumbs["thumb" + e]._y;
   }

The code thats problematic is container.loadMovie(fullimg[this.c]);

It loads the XML variable fullimg into an empty movie clip on its own layer in the timeline.

The movieclip, “container”, is assigned this code, but the code isn’t on the movieclip, it’s on a frame designated for just actionscript.

This is the code


container.onEnterFrame = function() {
 this._x = int(content._x - (content._width / 2) + 30);
 this._y = int(content._y - (content._height / 2) + 30);
}

[SIZE=5][COLOR=red]The Problem Is…[/COLOR][/SIZE]
[COLOR=black][/COLOR]
When there is no image loaded into the movie clip, it works fine, and shifts around depending on the location of the other movie clip, “content”.

But, once there is an image loaded into “container”, it stops shifting around depending on the location of “content”, and just sits in its last location.

The only thing i can IMAGINE being problematic is, on another frame, where I have the XML being cut up and assigned to variables, at the end I have a remove _root.onEnterFrame, removing the onEnterFrame at the beginning of the XML to variables line of code, so that is stops running. But i //commented that out and I still have the same problem… Any Ideas???

Hi,

If you think about what that onEnterFrame is doing, I think it’s problematic. For all those thumbs that do have an image loaded in them, it’s constantly setting the onPress event over and over. What I would recommend replacing that with is using either the MovieClipLoader class, or just checking for the bytes loaded and then setting the onPress once.

Here’s a quick hack anyway that might work better for you.


_root.web_thumbs.thumb_button.duplicateMovieClip("button" + e, e + 12);
_root.web_thumbs["button" + e].this.onPress = function() {
       if (web_thumbs["thumb" + c]._width == _root.thumbw) {
container.loadMovie(fullimg[this.c]);
      }
}
    

Yeah I see the problem in that now… but the code you gave me doesn’t seem to work… I’ll keep hacking at it.