Ir para conteúdo

POWERED BY:

Arquivado

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

rmaster

Url com xml em galeira de imagens

Recommended Posts

Pessoal não estou conseguindo colocar um link que vem do xml dentro do flash para uma galeria de imagens.

segue o código.

 

AS 2.0

 

//#include "Carousel.as"

import mx.utils.Delegate;

 

var numOfItems:Number;

var radiusX:Number = 250;

var radiusY:Number = 40;

var centerX:Number = 350;

var centerY:Number = 275;

var speed:Number = 0.01;

var perspective:Number = 5;

var home:MovieClip = this;

 

 

var tooltip:MovieClip = this.attachMovie("tooltip", "tooltip", 30000);

tooltip._alpha = 0;

 

var xml:XML = new XML();

xml.ignoreWhite = true;

xml.onLoad = function()

{

var nodes = this.firstChild.childNodes;

numOfItems = nodes.length;

for( var i = 0; i < numOfItems; i++ )

{

var t = home.attachMovie( "item", "item" + i, i+1 );

t.angle = i * ((Math.PI*2) / numOfItems);

t.onEnterFrame = mover;

t.toolText = nodes.attributes.tooltip;

t.icon.inner.loadMovie(nodes.attributes.image);

t.ref.inner.loadMovie(nodes.attributes.image);

t.icon.onRollOver = over;

t.icon.onRollOut = out;

t.icon.onRelease = down;

}

}

 

function down(){

 

url = this.childNodes[0].childNodes[0].childNodes[2].childNodes[0]; //Aqui é definido a url puxando do arquivo xml

icon.onRelease = function() { // Aqui será atribuido a qual botao será dado o comando

getURL(url, "_blank");

};

}

 

function over() {

//this._parent._width = this._parent._width + 50;

//this._parent._height = this._parent._height + 50;

//this._parent._x -= 25;

//this._parent._y -= 25;

home.tooltip.tipText.text = this._parent.toolText;

var tmp:String = this._parent.toolText;

home.tooltip._width = tmp.length * 11;

home.tooltip._x = this._parent._x;

home.tooltip._y = this._parent._y - this._parent._height / 2;

home.tooltip.onEnterFrame = Delegate.create(this, moveTip);

home.tooltip._alpha = 100;

}

function out() {

//this._parent._width = this._parent._width - 50;

//this._parent._height = this._parent._height - 50;

//this._parent._x += 25;

//this._parent._y += 25;

delete home.tooptip.onEnterFrame;

home.tooltip.tipText.text = "";

home.tooltip._alpha = 100;

}

function moveTip(){

home.tooltip._x = this._parent._x;

home.tooltip._y = this._parent._y - this._parent._height / 2;

}

xml.load("icons.xml");

 

 

//Foundation ActionScript Animation

function mover()

{

this._x = Math.cos(this.angle) * radiusX + centerX;

this._y = Math.sin(this.angle) * radiusY + centerY;

var s:Number = (this._y - perspective) / (centerY + radiusY - perspective);

this._xscale = this._yscale = s * 300;

if(this.mouseOver)

trace(this.mouseOver + "bullshit");

this.angle +=this._parent.speed;

this.swapDepths(Math.round(this._xscale) + 300);

}

 

this.onMouseMove = function()

{

speed = (this._xmouse - centerX) / 10000;

if(this.mouseOver)

trace(this.mouseOver + "bullshit");

}

 

XML

 

<icons>

<icon image="images/1.png" tooltip="Novo Uno " url="www.www.com.br" />

<icon image="images/2.png" tooltip="Mille " url="www.www.com.br" />

<icon image="images/3.png" tooltip="Palio " url="www.www.com.br" />

<icon image=images/4.png" tooltip="Siena " url="www.www.com.br" />

<icon image="images/5.png" tooltip="Palio Weekend" url="www.www.com.br" />

<icon image="images/6.png" tooltip="Punto " url="www.www.com.br" />

<icon image="images/7.png" tooltip="Doblo " url="www.www.com.br" />

 

</icons>

 

 

desde já muito obrigado.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Adorei o seu trace com o "bullshit", tente isso no seu for:

 

for( var i = 0; i < numOfItems; i++ )
{
var t = home.attachMovie( "item", "item" + i, i+1 );
t.angle = i * ((Math.PI*2) / numOfItems);
t.onEnterFrame = mover;
t.toolText = nodes[i].attributes.tooltip;
t.icon.inner.loadMovie(nodes[i].attributes.image);
t.icon.Link = nodes[i].attributes.url
t.ref.inner.loadMovie(nodes[i].attributes.image);
t.icon.onRollOver = over;
t.icon.onRollOut = out;
t.icon.onRelease = function(){
 getURL(this.Link, "_blank");
}
}
}

 

e remova essa função

 

function down(){

url = this.childNodes[0].childNodes[0].childNodes[2].childNodes[0]; //Aqui é definido a url puxando do arquivo xml
icon.onRelease = function() { // Aqui será atribuido a qual botao será dado o comando
getURL(url, "_blank");
};
}

Compartilhar este post


Link para o post
Compartilhar em outros sites

Nossssaa!

Perfeito cara!

Muito obrigado mesmo!

 

Adorei o seu trace com o "bullshit", tente isso no seu for:

 

for( var i = 0; i < numOfItems; i++ )
{
var t = home.attachMovie( "item", "item" + i, i+1 );
t.angle = i * ((Math.PI*2) / numOfItems);
t.onEnterFrame = mover;
t.toolText = nodes[i].attributes.tooltip;
t.icon.inner.loadMovie(nodes[i].attributes.image);
t.icon.Link = nodes[i].attributes.url
t.ref.inner.loadMovie(nodes[i].attributes.image);
t.icon.onRollOver = over;
t.icon.onRollOut = out;
t.icon.onRelease = function(){
 getURL(this.Link, "_blank");
}
}
}

 

e remova essa função

 

function down(){

url = this.childNodes[0].childNodes[0].childNodes[2].childNodes[0]; //Aqui é definido a url puxando do arquivo xml
icon.onRelease = function() { // Aqui será atribuido a qual botao será dado o comando
getURL(url, "_blank");
};
}

Compartilhar este post


Link para o post
Compartilhar em outros sites

Agora estou fazendo um outro e to com o seguinte problema.

nas imagens que carrego, ela ficam com fundo branco, o que era pra ficar com fundo transparente pois são PNG.

 

Segue o código.

 

carouselWidth = 673;

carouselHeight = 278;

 

verticalCarousel = false; //the carousel is horizontal oriented by default

 

actualWidth = 250; //The actual images' width

actualHeight = 200; //and height (the images which are going to be loaded through the XML file)

Ratio = actualWidth/actualHeight;

 

imageSize = 100; //images size

RadiusX = 240; //images X radius

RadiusY = 300; //images Y radius

focus = 800; //images focus

Yspan = 90; //images span - negative values for opposite expanding dirrection

imagesX = -40; //increase or decrese imagesX and imagesY to adjust the carousel position

imagesY = -50; //if Yspan is negative you should significantly increase imagesX and imagesY

rotatingSpeed = 15; //recommended value between 1-30

initialRotate = 5; //set it to 0 for no initial image spin; set it negative to spin backwards

alwaysRotate = true; //whether the carousel should rotate with the intialRotate while rolling out

stoppingSpeed = 10; //the carousel stops rotating with a certain speed while rolling out

inColor = 20; //images onRollOver color intensity

outColor = 0; //images onRollOut color intensity

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

 

verticalCarousel = false; //the carousel is horizontal oriented by default

 

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

descriptionY = 0; //y pos of the description

 

useMirror = false; //set it to true if you want to use images mirror effect

//IMPORTANT! in order to have a proper mirror effect, the inner symbol must have the

//same width and height as the actual images' width and height (same with actualWidth and actualHeight)

//see the ScreenShot.jpg in the package

mirrorDistance = -0.5; //the distance between the image and its reflection

 

useBlur = true; //whether to use blur for the images which loose focus

blurIntensity = 2; //1-10 recommended values

blurQuality = 1; //1-3 recommended values

 

 

target = "_self"; //"_self" for opening URLs in the same window, "_blank" for opening them in a new window

 

//don't need to edit the code below

 

import flash.geom.Transform;

import flash.display.*;

import flash.filters.BlurFilter;

item._alpha = 0;

 

Stage.scaleMode = "noScale";

var xml:XML = new XML();

xml.ignoreWhite = true;

 

var images:Array = new Array();

var urls:Array = new Array();

var info:Array = new Array();

var pictures:Array = new Array();

var tg:Array = new Array();

overThumbs = false;

sp = 0;

_quality = "HIGH";

 

 

loadXML = function () {

var photos:Array = this.firstChild.childNodes;

total = photos.length ;

for (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);

}

createEmptyMovieClip("thumbs", 0);

if (verticalCarousel) {

thumbs._x = imagesX;

thumbs._y = imagesY+carouselHeight/2-carouselHeight/15;

}

else {

thumbs._x = imagesX+carouselWidth/2+carouselWidth/15;

thumbs._y = imagesY;

}

isLoading = true;

iC = inColor + Math.abs;

 

 

speed = 0; slow=0; stp = true;

a = 2*Math.PI/total;

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

thumb = thumbs.createEmptyMovieClip("th"+i, i);

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

pr._x = pr._y = imageSize/2;

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

loadBitmapSmoothed(images,holder);

holder._visible = false;

if (useMirror) {

r = thumb.attachMovie("item","hold", 3);

loadBitmapSmoothed(images,r.ref.inner);

r.ref.inner.loadMovie(images);

r.ref.inner._width = r.ref.inner._height = imageSize;

r._y = 2*imageSize+mirrorDistance;

r._yscale=-100;

}

thumb.angle = a*i;

thumb.show = panel;

thumb.onClick(i);

thumb.notLoaded = true;

pictures.push(thumb);

thumb.y = Yspan;

var trans:Transform = new Transform(thumb);

 

}

thumbs.onEnterFrame = function () {

speed -= initialRotate*0.001;

curX = this._xmouse-imageSize/2 ;

curY = this._ymouse-imageSize;

if (overThumbs) {

if (sp < rotatingSpeed) sp++;

if(verticalCarousel) {

slow = curY*sp*0.00001;

speed -= slow;

}

else {

slow = curX*sp*0.00001;

speed -= slow;

}

stp =false;

if (!alwaysRotate) initialRotate = 0;

}

else if (!stp) {

if (sp > 0) sp-- ;

speed -=slow;

if(slow>0) slow -= stoppingSpeed*0.0001;

else slow += stoppingSpeed*0.0001;

if ((slow<0.001)&&(slow>-0.001)) stp = true;

}

for (var i = 0; i<pictures.length; i++) {

pictures.show();

}

}

onEnterFrame = function() {

allLoaded = true;

for (i=0; i<photos.length; i++) {

myMc = thumbs["th"+i].holder;

if(!myMc.isLoaded) allLoaded = false;

if ((myMc.isLoaded) && (thumbs["th"+i].notLoaded)) {

if (myMc._width>=myMc._height) {

myMc._yscale = myMc._xscale=(100*(1-(myMc._width-imageSize)/(myMc._width)));

myMc._y = (imageSize-myMc._height);

}

if (myMc._width<=myMc._height) {

myMc._yscale = myMc._xscale=(100*(1-(myMc._height-imageSize)/(myMc._height)));

myMc._x = (imageSize-myMc._width)/2;

}

if (myMc._width == myMc._height) {

myMc._yscale = myMc._xscale=(100*(1-(myMc._width-imageSize)/(myMc._width)));

myMc._x = myMc._y=0;

}

myMc._visible = true;

thumbs["th"+i].notLoaded = false;

removeMovieClip(thumbs["th"+i].pr);

allLoaded = false;

 

}

}

if (allLoaded) delete onEnterFrame;

}

}

 

xml.onLoad = loadXML;

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

 

panel = function () {

var angle = this.angle+speed;

var x = Math.cos(angle)*RadiusX;

var z = Math.sin(angle)*RadiusY;

var y = this.y;

var ratio = focus/(focus+z);

if (verticalCarousel) {

this._y = x*ratio;

this._x = y*ratio;

}

else {

this._y = y*ratio;

this._x = x*ratio;

}

this._yscale=100*ratio;

this._xscale =this._yscale;

this._x -= this._xscale/2;

this.swapDepths(Math.round(-z));

if (useBlur)

if(this._xscale <100) {

blurX = -(this._xscale-100)*blurIntensity/10;

blurY = -(this._yscale-100)*blurIntensity/10;

var filter:BlurFilter = new BlurFilter(blurX, blurY, blurQuality);

var filterArray:Array = new Array();

filterArray.push(filter);

this.filters = filterArray;

}

else this.filters = NULL;

 

}

 

MovieClip.prototype.onClick = function(i) {

this.onPress = function() {

getURL(urls, tg);

};

this.onRollOver = function() {

if (showDescription) {

descript = this.attachMovie("description", "descript", 4);

descript._x += imageSize/2;

descript._y = descriptionY;

descript._xscale = descript._yscale = imageSize;

descript.desc_inner.desc.text = info;

 

}

};

this.onRollOut = function() {

if(showDescription) removeMovieClip(descript);

overThumbs = true;

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

 

 

}

}

 

MovieClip.prototype.drawFrame = function(w,h,fT,fC,fA) {

this.lineStyle(fT, fC,fA,false,"none","round", "round");

this.lineTo(w, 0);

this.lineTo(w, h);

this.lineTo(0, h);

this.lineTo(0, 0);

}

 

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

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.isLoaded = true;

mc._visible = true;

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

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

png.draw(mc);

};

var loader:MovieClipLoader = new MovieClipLoader();

loader.addListener(listener);

loader.loadClip(url, bmc);

}

 

Adorei o seu trace com o "bullshit", tente isso no seu for:

 

for( var i = 0; i < numOfItems; i++ )
{
var t = home.attachMovie( "item", "item" + i, i+1 );
t.angle = i * ((Math.PI*2) / numOfItems);
t.onEnterFrame = mover;
t.toolText = nodes[i].attributes.tooltip;
t.icon.inner.loadMovie(nodes[i].attributes.image);
t.icon.Link = nodes[i].attributes.url
t.ref.inner.loadMovie(nodes[i].attributes.image);
t.icon.onRollOver = over;
t.icon.onRollOut = out;
t.icon.onRelease = function(){
 getURL(this.Link, "_blank");
}
}
}

 

e remova essa função

 

function down(){

url = this.childNodes[0].childNodes[0].childNodes[2].childNodes[0]; //Aqui é definido a url puxando do arquivo xml
icon.onRelease = function() { // Aqui será atribuido a qual botao será dado o comando
getURL(url, "_blank");
};
}

Compartilhar este post


Link para o post
Compartilhar em outros sites

Na linha de BitmapData, você precisa setar o transparente pra true e colocar o preenchimento de fundo com transparencia tb. de uma pesquisada aqui no fórum que ja tem vários tópicos bem explicados sobre isso.

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.