Sure this will be a simple fix, and I’m just not seeing the wood for the trees. I have a movie with a movieclip called scroller_mov. Inside it are 15 movieclips named pic1 thru pic15.
My code is on one frame, on the same level as scroller_mov. Just want to dynamically assign a click action to the pic1 – pic15 movieclips! have tried hardcoded links and dynamic, but no joy! Everything else works fine. Thanks if you can help!
stop();
lv_obj = new LoadVars();
lv_obj.load("flash_carou_data2.php");
lv_obj.onLoad = function(success):Void{
product_mod.product_model = this.product_models;
var products_data:Array = product_mod.product_model.split(",");
scroller_mov.prodmod1 = products_data[0];
for (i=0;i<15;i++){
products_data[i] = products_data[i].split("&");
scroller_mov["prodmod" + (i+1)] = products_data[i][0];
scroller_mov["prodprice" + (i+1)] = products_data[i][3];
scroller_mov["pic" + (i+1)].loadMovie(products_data[i][2]);
scroller_mov["pic" + (i+1)].onRelease = function () {
getURL("http://www.mysite.com");
//getURL(products_data[i][1]);
}
};
};
You can do it just the way you do it in your code – but you have to wait for the
loadMovie()to finish. When you load a MovieClip, all its properties are erased upon successful completion.Set an interval to check for your MovieClip’s
getBytesLoaded()andgetBytesTotal()methods, then assign the onRelease function when the clip is fully loaded. Here’s a quick example, you can just copy and use the samecheckLoadedfunction:You can assign the interval to any variable, it doesn’t need to belong to
_root. Make sure the first parameter ofsetIntervalis the object where thecheckLoadedmethod is contained, and the last parameter is the MovieClip you are loading into.