Hi there, and thanks for stopping by this post. I hope you can help me in the right direction with this one. I am loading 12 images in a row dynamically on to the stage. The images will form a menu and when I move my mouse over one image( a picture of a person), it will scale up so it kind of reminds me of a fish eye effect. I am trying to load the images into empty movie clips with a for-loop, and that works fine thanks to devonair who helped me out there.
My problem is that I don’t really understand what I’m doing wrong in the code that follows. I have tested the script without loading anything dynamically, with everything on the stage, and that works just fine.
Do I target the wrong instance of every movieClip? Should I target the MovieClip itself insted of the instance name? Do I overwrite someting in the for loop perhaps? Do I use onEnterFrame in a wrong way? The scale script works fine as it is, but I can’t get it to work on more than one movieClip at a time.
var imageLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
var pngPath:String = "images/people/";
listener.onLoadInit = function(target:MovieClip) {
// target refers to inner_mc
target._x -= target._width/2;
target._y -= target._height;
// movie clip is now registered at center bottom relative to outer_mc
// add rollovers, etc to outer_mc (or target._parent)
};
imageLoader.addListener(listener);
for (var i:Number = 0; i<12; i++) {
var outer_mc:MovieClip = this.createEmptyMovieClip("mcImgHolder"+i, this.getNextHighestDepth());
var inner_mc:MovieClip = outer_mc.createEmptyMovieClip("mcImage"+i,
outer_mc.getNextHighestDepth());
//place images in a row.
outer_mc._x = 60*i;
//loads image "0.png" to "12.png" to instance "mcImgHolder0" to "mcImgHolder12"
imageLoader.loadClip(pngPath + i + ".png", "mcImgHolder"+i+".mcImage"+i);
}
//And here is the script that I put on all the 12 images/movieClips,
//that scale the image up when I move my mouse over each image/mc on the stage.
mcImgHolder0.onEnterFrame = function ()
{
dist = int(Math.abs(_x - _xmouse));
if (dist < 70)
{
if (_root.zone == "yes") // enable scale if mouse pointer is inside
{ // a certain scope on the Y-axis.
arrive = 300 - dist;
}
else
{
arrive = 100;
xarrive = startX;
} // end else if
}
else
{
arrive = 100;
xarrive = startX;
} // end else if
speed = (arrive - _yscale) * 2.000000E-001;
setProperty("mcImgHolder0", _xscale, _xscale + speed);
setProperty("mcImgHolder0", _yscale, _yscale + speed);
}
What then follows is:
mcImgHolder1.onEnterFrame = function (){
//same code
mcImgHolder2.onEnterFrame = function (){
//same code
…and exactly the same code as above for all 12 mc instances.
I have been trying to figue this out for a week now, but without any success.
Please have a look, mainly in the for loop I guess and see if you see anything that is apparently wrong. Thanks!