I located the following Actionscript 3.0 Class which performs the task of horizontally scrolling a picture in a continuous loop. Once it reaches the end of the picture, it then immediately starts over from the beginning of the picture. I am interested in making it so the picture fades in, scroll horizontally and then when it reachs the end of the picture, it fades out… It would then fade back in after a period of time and begin the process again of scrolling horizontally… Continuous loop. Can you please help me with adding those features to this Actionscript 3.0 Class? I would greatly appreciate it if you could directly augment the following code to in order to achieve this objective. I thank you very, very much.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CORE FUNCTIONS
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public function init():void {
panorama.graphics.beginFill(0x000000); // you can set background color per example if you work with transparent png or swf
panorama.graphics.drawRect(0, 0, 600, 500); // you set the width and height of the final panorama clip, the height should be the same as your image, and the width should be < than your full image
panorama.graphics.endFill(); // we're done with creating our panorama mc holder
panoramask.graphics.beginFill(0x000000); // we create a mask so that our panorama won't scroll outside of the screen
panoramask.graphics.drawRect(0, 0, panorama.width, panorama.height); // we give it the same dimensions than our panorama MC
panoramask.graphics.endFill(); // and we're done too
addChild(panorama); // we display the panorama image container
addChild(panoramask); // and above it, we display the mask
panorama.mask = panoramask; // we apply our mask to the panorama MC
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PANORAMA ELEMENTS LOADING
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public function createPanorama():void {
var url:String = "images/panoramic_img.jpg"; // here you set the path of the panorama img or swf you want to load
var urlReq:URLRequest = new URLRequest(url);
ldr1.x = -295;
ldr1.y = -150;
ldr1.load(urlReq); // we load our panorama file in the first loader
ldr2.load(urlReq); // we load it again in another one to create the infinite loop effect
ldr2.x = ldr1.width; // we set our second loader (ldr2) at the right of our first loader (ldr1)
ldr2.y = ldr1.y; // and we align it at the same y position
panorama.addChild(ldr1); // we add them one after one in our panorama MC
panorama.addChild(ldr2);
addEventListener(Event.ENTER_FRAME, scrolling); // we call the enterframe function depending on the frameRate defined in .fla
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ENTER FRAME SCROLLING FUNCTION
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public function scrolling(ev:Event):void {
ldr1.x -= speed; // as the scroll is automatic at a constant speed, simply increase the speed var above in the script it to fasten the scroll.
// this function will be executed x times per second depending on the frameRate of your project
if (ldr1.x > panoramask.x) { //if ldr1 start to scroll from left to right, we must add our ldr2 at the left of ldr1 to give an endless look
ldr2.x = ldr1.x-ldr2.width; // so we stick it to the ldr1.x position minus it's own size, otherwise they would be one over another
}
else {
ldr2.x = ldr1.x+ldr2.width; // otherwise the ldr2 can stay at the right of our ldr1 panorama loader
}
if (ldr1.x < panoramask.x-ldr1.width) { // if ldr1 is too far at left to be seen in our panorama mask zone, then
ldr1.x = ldr2.x+ldr1.width; // it's time to add it at the right of our ldr2
}
if (ldr1.x > panoramask.width) { // if ldr1 reached the end of our mask's width, then we stick it again at the left of our ldr2 that is currently seen
ldr1.x = ldr2.x-ldr1.width;
}
}
}
}