I’m trying to translate AS2 into AS3. I’m building an image gallery for my website.
Now here’s the AS2 code that I have
//create images and mask
this.createEmptyMovieClip("images", 100);
this.createEmptyMovieClip("names", 98);
this.attachMovie("mask", "mask", 101);
mask._y = 361;
images._y = 320;
names._y = 674;
mask._x = target = 382;
images.setMask(mask);
images._x = names._x = 1000;
speed = 5;
for (var i = 0; i<6; i++)
{
var img = images.attachMovie("image"+i, "image"+i, i);
img._x = 625*i;
}
for (var i = 0; i<4; i++)
{
var nam = names.attachMovie("name"+i, "name"+i, i);
nam._x = 625*i;
}
//buttons
leftButton.onRelease = function()
{
//trace(target)
target += 625 ;
if (target > 300)
{
target = 382;
}
}
rightButton.onRelease = function()
{
//trace(target)
target -= 625;
if (target < -1500)
{
target = -1493;
}
}
//speed of movement
this.onEnterFrame = function()
{
images._x += (target-images._x)/speed;
names._x += (target-names._x)/speed;
};
and you can see the result on this page - http://dexvision.org/mina.html
Now, I’m redesigning my site and decided to work in AS3 for the sake of learning new things and this is what I have so far
import flash.events.Event
import flash.display.MovieClip;
//create images
var imageList:Array = [image0,image1,image2,image3];
var images:MovieClip = new MovieClip();
for (var i:uint=0; i<imageList.length; i++) {
images = new imageList*();
images.x = 390.95;
images.y = (550 * i) + 24.05 + 550;
addChild(images);
}
var target:Number = 14.05;
addEventListener(Event.ENTER_FRAME, speed);
//
function speed(Event){
images.y += (target-images.y)/5;
}
What happens is AS creates the 4 images on the stage but only the one that’s last in the array is active - can be moved with the buttons (for which I haven’t written the code yet). The other 3 images are static on the stage.
Any idea why this happens or any other way I can make this work?
Thank you,
Dex