Jubba
March 11, 2004, 5:18am
1
This code isn’t working for me. I have written the same thing a bazillion times, but for some reason this isn’t working for me right now…:
this.createEmptyMovieClip("container", -1);
for (ii=0; ii<xml_obj.firstChild.childNodes.length; ii++) {
container.duplicateMovieClip("cp"+ii, ii);
ext = this["cp"+ii];
ext.onPress = function() {
trace("onPress called");
};
}
The MCs load into my scrollPane and everything fine, but they don’t respond to the onPress… Any idea why its not working?
system
March 11, 2004, 2:19pm
2
nope. If I do that the clips don’t even show up on the stage… Like I said, I have used this technique a million times in the past so I can’t understand why its not working right now…
system
March 11, 2004, 2:29pm
3
so you are assigning the onPress THEN loading something into that clip??
system
March 11, 2004, 2:30pm
4
No there was a bit more code in there. The loadMovie comes before the onPress:
this.createEmptyMovieClip("container", -1);
container._visible = 0;
for (ii=0; ii<xml_obj.firstChild.childNodes.length; ii++) {
container.duplicateMovieClip("cp"+ii, ii);
ext = this["cp"+ii];
ext.loadMovie("http://localhost/ddd/img_create_thumb.php?im_path="+xml_obj.firstChild.childNodes[ii].childNodes[0]);
ext._x = space_btn*(ii%num_wide);
ext._y = yS;
ext.onPress = function() {
trace("onPress called");
};
edit: The images loaded show up fine and in the correct places. But for some reason aren’t responding to the onPress…
system
March 11, 2004, 2:44pm
5
same difference. You have to make sure the loading is complete before you can assign the onPress. First rule of loadMovie for a movieclip: all properties and methods of the movieclip are cleared when the new content is loaded into the clip . This happens at the arrival of the new content, not the loadMovie call.
system
March 11, 2004, 2:45pm
6
ok i’ll give it a shot. thanks
So why isn’t this working?
[AS]root[“word”+i].loadMovie ("word " + arrayChoice* + “.jpg”);
_root[“word”+i].onEnterFrame = function() {
trace(this.getBytesLoaded() + " / " + this.getBytesTotal());
if(this.getBytesLoaded() >= this.getBytesTotal()) {
trace("*** load complete ***");
_root["word"+i].onPress = function () {
trace("pipo");
}
delete onEnterFrame;
}
}[/AS]
I’ve put the onPress after the load is done…
Im having similar problems, when loading a movieClip into an empty container, I can’t access the onRelease event. For example:
t1.onRelease = function() {
currentPic ='products/pro/mainImage.jpg';
cMC.loadPic(currentPic);
};
MovieClip.prototype.loadPic = function(pic) {
this.loadMovie(pic);
this.onRelease = function(){
this.unloadMovie(pic);
// delete this._parent.onRelease;
}
}
Thanks
Daniel
try
this.createEmptyMovieClip("container", -1);
for (ii=0; ii<xml_obj.firstChild.childNodes.length; ii++) {
var ext:MovieClip= container.duplicateMovieClip("cp"+ii, ii);
trace(ext)
ext.onPress = function() {
trace("onPress called");
};
}
i guess this won’t even help good thing someone bumped the thread now im looking at the dates lol…
I used a quick and dirty way to do it:
Create an empty MC inside it, like imageholder or so, and load your movie into that imageholder. But keep the onPress on you original MC…
Senocular: this.onPress, didn’t work… (-: