קוד המצגת בדף הבית - AS3

את המצגת בדף הבית עשינו עם המורה בג'ון ברייס.
היא נכתבה באקשנסקריפט 2.0

המצגת מורכבת מפריים אחד, שיש בו שלושה קליפים - שני כפתורים וסרט אחד ארוך, שנע ימינה ושמאלה כשלוחצים על הכפתורים.

הסרט הנע זז 567 פיקסלים ימינה או שמאלה בכל פעם, מה שכמובן אפשר לשנות ולהתאים לגודל החלון שלכם ומספר התמונות שרוצים.

כדי להתאים את המצגת לעולמנו המודרני, שיניתי את הסינטקס לכדי כתיב של אקשנסקריפט 3.0.

מי שרוצה מוזמן לקחת את המצגת, כל מה שצריך לעשות הוא לעצב את הכפתורים והתמונות, ולתת להם את אותו שם המופע כמו בקוד.




var pic:uint = 1; // Current picture

next_button.addEventListener(MouseEvent.CLICK, moveRight);

function moveRight(event:MouseEvent):void
{
if(pic <>
{
pictures.addEventListener(Event.ENTER_FRAME, nextPicture);

function nextPicture(event:Event):void
{
pictures.x = Math.round(((pictures.x - 576 * pic) / 2) - 1); // Motion with easing
//pictures._x = pictures._x - 16; // Motion without easing
if(pictures.x == -576 * pic)
{
pictures.removeEventListener(Event.ENTER_FRAME, nextPicture); // Stop Slide motion
pic++; // Set new slide number
}
}
}
}

prev_button.addEventListener(MouseEvent.CLICK, moveLeft);

function moveLeft(event:MouseEvent):void
{
if(pic > 1)
{
pictures.addEventListener(Event.ENTER_FRAME, prevPicture);

function prevPicture(event:Event):void
{
pictures.x = Math.round(((pictures.x - 576 * (pic - 2)) / 2) + 1); // Motion with easing
//pictures._x = pictures._x + 16; // Motion without easing
if(pictures.x == -576 * (pic - 2) )
{
pictures.removeEventListener(Event.ENTER_FRAME, prevPicture); // Stop Slide motion
pic--; // Set new slide number
}
}
}
}






תגובות

פוסטים פופולריים מהבלוג הזה

Thoughts on HTML5, a Flash Developers hopeless rant

Pseudo 3d Isometric view

Veroni Noise