Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

AderitoMachado

Galeria Flash com ActionScript e XML

Recommended Posts

Tenho uma galeria em Flash com Actionscript e as imagens são carregadas através de um ficheiro XML com o seguinte código

 

verticalMenu = false; //whether it's a vertical or horizontal menu

scrollerWidth = 600;

scrollerHeight = 180;

 

 

actualWidth = 130; //the width of tha actual jpeg's specified in the XML file

actualHeight = 130; //the height of tha actual jpeg's specified in the XML file

 

imageW = 100; //thumbs width

imageH = imageW*actualHeight/actualWidth; //thumbs height is automatically calcualted

 

menuX = 0; //menu's X position

menuY = 2; //menu's Y position

 

spacing = 2; //thumbs spacing

inColor = 25; //thumbs onRollOver color intensity

outColor = -45; //thumbs onRollOut color intensity

coloringSpeed = 7; //the speed on changing color between onRollOver and onRollOut states

useMaxColor = true; //whether to use max color intensity on roll over

maxColorValue = 170; //max color intensity value

 

minScrollSpeed = 2; //minimum scroll speed

maxScrollSpeed = 80; //maximum scroll speed

scrollEaseIn = 40; //scroll ease in

scrollEaseOut = 50; //scroll ease out

 

preloaderSize = 15;

 

loadSmoothed = true; //might increase a bit processor usage

 

showDescription = true; //whether to use the description text

descriptionY = 102; //y pos of the description

descriptionX = 0; //x pos of the description

 

useMirror = 2; //2 for true, 1 for false

if (verticalMenu) useMirror = 1; //if verticalMenu is true, useMirror it's automatically false

//IMPORTANT! in order to have a proper mirror effect, "inner" and "masker" and "mirr" symbols from the

//library must have the same width and height as the imageW and imageH variables

 

mirrorDistance=0; //the spacing between the thumbs and their reflection

 

Stage.scaleMode = "noScale";

 

//don't need to edit the code below

import flash.geom.ColorTransform;

import flash.geom.Transform;

import flash.display.*;

 

var xml:XML = new XML();

xml.ignoreWhite = true;

 

var images:Array = new Array();

var urls:Array = new Array();

var menu:Array = new Array();

var info:Array = new Array();

var tg:Array = new Array();

 

iC = inColor + Math.abs(outColor);

dist = 0;

 

loadXML = function () {

var photos:Array = this.firstChild.childNodes;

total = photos.length;

menu = createEmptyMovieClip("menu", 0);

menu._y = menuY;

menu._x = menuX;

for (var i=0;i<total;i++) {

images.push((_root.folderPath?_root.folderPath:"") + photos.attributes.image);

urls.push(photos.attributes.url);

info.push(photos.attributes.info);

tg.push(photos.attributes.target);

 

item = menu.createEmptyMovieClip("it"+i, i);

if(verticalMenu) {

item._y = dist;

dist += imageH + spacing;

}

else {

item._x = dist;

dist += imageW + spacing;

}

pr = item.attachMovie("preload","pr", 1);

pr._x = imageW/2; pr._y = imageH/2;

pr._width = pr._height = preloaderSize;

holder = item.createEmptyMovieClip("holder", 2);

loadBitmapSmoothed(images, holder, imageW, imageH);

 

if (useMirror==2) {

r = item.attachMovie("mirr","r", 3);

r._visible = false;

loadBitmapSmoothed(images,r.ref.inner,imageW, imageH);

r._y = 2*imageH+mirrorDistance;

r._yscale=-100;

}

 

holder.onEnterFrame = function () {

if (this.isLoaded) {

if (useMirror == 2) this._parent.r._visible = true;

removeMovieClip(this._parent.pr);

delete this.onEnterFrame;

}

}

item.onClick(i);

var trans:Transform = new Transform(item);

var colorTrans:ColorTransform = new ColorTransform();

colorTrans.blueOffset = colorTrans.greenOffset = colorTrans.redOffset=colorTrans.alphaOffset= outColor;

trans.colorTransform = colorTrans;

}

onEnterFrame = function () {

if (verticalMenu) {

if (mouseOverMenu) ypos = (scrollerHeight-2.5*imageH - menu._height)*_ymouse/(scrollerHeight-imageH) + 2.5*imageH;

if (ypos > 0) ypos = 0;

if (ypos < (scrollerHeight-menu._height)) ypos = scrollerHeight-menu._height;

difference = Math.abs(menu._y - ypos);

s = speed(difference);

if (difference < minScrollSpeed) menu._y = ypos;

else {

if (menu._y > ypos) menu._y -=s;

if (menu._y < ypos) menu._y +=s;

}

}

else {

if (mouseOverMenu) xpos = (scrollerWidth-2.5*imageW - menu._width)*_xmouse/(scrollerWidth-imageW) + 2.5*imageW;

if (xpos > 0) xpos = 0;

if (xpos < (scrollerWidth-menu._width)) xpos = scrollerWidth-menu._width;

difference = Math.abs(menu._x - xpos);

s = speed(difference);

if (difference < minScrollSpeed) menu._x = xpos;

else {

if (menu._x > xpos) menu._x -=s;

if (menu._x < xpos) menu._x +=s;

}

}

}

 

 

}

xml.onLoad = loadXML;

xml.load((_root.folderPath?_root.folderPath:"") + "images.xml");

 

MovieClip.prototype.onClick = function(i) {

this.onPress = function() {

getURL(urls, tg);

}

this.onRollOver = function() {

mouseOverMenu = true;

if (showDescription) {

if (verticalMenu) {

descript = attachMovie("description", "descript", 8888);

descript._y = menu["it"+i]._y +ypos + imageH/2;

descript.onEnterFrame = function() {

descript._y = menu["it"+i]._y +ypos + imageH/2+descriptionY;

descript._x = menu["it"+i]._x + imageW/2+descriptionX+menuX;

}

}

else {

descript = attachMovie("description", "descript", 8888);

descript._x = menu["it"+i]._x +xpos + imageW/2;

descript.onEnterFrame = function() {

descript._x = menu["it"+i]._x +xpos + imageW/2

}

}

 

descript._y = descriptionY+menuY;

descript.desc_inner.desc.text = info;

}

var trans:Transform = new Transform(this.holder);

var colorTrans:ColorTransform = new ColorTransform();

colorTrans.blueOffset = colorTrans.greenOffset = colorTrans.redOffset=colorTrans.alphaOffset=0;

if (useMaxColor) {

reachedPeak = false;

this.onEnterFrame = function () {

if (!reachedPeak) {

if (colorTrans.blueOffset < maxColorValue) {colorTrans.blueOffset = colorTrans.greenOffset = colorTrans.redOffset=colorTrans.alphaOffset+=coloringSpeed*10;

trans.colorTransform = colorTrans; }

else reachedPeak = true;

}

else

if (colorTrans.blueOffset > iC) {

colorTrans.blueOffset = colorTrans.greenOffset = colorTrans.redOffset=colorTrans.alphaOffset-=coloringSpeed*10;

trans.colorTransform = colorTrans;

}

}

}

else

this.onEnterFrame = function () {

if (colorTrans.blueOffset < iC) {

colorTrans.blueOffset = colorTrans.greenOffset = colorTrans.redOffset=colorTrans.alphaOffset+=coloringSpeed;

trans.colorTransform = colorTrans;

}

}

this.onRollOut = function() {

mouseOverMenu = false;

if (showDescription) {

removeMovieClip("descript");

}

var trans:Transform = new Transform(this.holder);

var colorTrans:ColorTransform = new ColorTransform();

colorTrans.blueOffset = colorTrans.greenOffset = colorTrans.redOffset=colorTrans.alphaOffset= iC;

this.onEnterFrame = function () {

if (colorTrans.blueOffset > 0) {

colorTrans.blueOffset = colorTrans.greenOffset = colorTrans.redOffset=colorTrans.alphaOffset -= coloringSpeed;

trans.colorTransform = colorTrans;

}

}

}

}

}

 

function loadBitmapSmoothed(url:String, target:MovieClip, wid, hei) {

var bmc:MovieClip = target.createEmptyMovieClip("bmc", target.getNextHighestDepth());

 

var listener:Object = new Object();

listener.tmc = target;

target.isLoaded = false;

listener.onLoadInit = function(mc:MovieClip) {

target._width = wid;

target._height = hei;

target.isLoaded = true;

if(loadSmoothed) {

mc._visible = false;

var bitmap:BitmapData = new BitmapData(mc._width, mc._height, true);

this.tmc.attachBitmap(bitmap, this.tmc.getNextHighestDepth(), "auto", true);

bitmap.draw(mc);

}

}

var loader:MovieClipLoader = new MovieClipLoader();

loader.addListener(listener);

loader.loadClip(url, bmc);

}

 

function easing(x,a,B) {

if(x<a) return x*b/a;

else return b+(100-B)/(100-a)*(x-a);

}

 

function speed(diff) {

z = maxScrollSpeed-minScrollSpeed;

x = minScrollSpeed + diff*z/(verticalMenu?menu._height:menu._width-scrollerWidth);

y = easing(x, scrollEaseIn*z/100 , scrollEaseOut*z/100);

return y;

}

 

Gostaria de conseguir alterar o seguinte:

Quando se passa com o rato por cima a imagem vai mexendo e a ideia seria as imagens estarem sempre a rodar horizontalmente e ao passar com o rato por cima parava e o funcionamento ficava exactamente como está.

 

Agradeço a vossa ajuda

 

Obrigado

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.