Go Back   CodingForums.com > :: Client side development > XML

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-02-2009, 11:26 PM   PM User | #1
Ctje
New to the CF scene

 
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Ctje is an unknown quantity at this point
Need help with XML for personal site

I found this great Polaroid flash that I would like to use on my main page as the menu.
http://www.valvdb.com/polaroid/test.html
I’m completely new at XML and I just can’t figure out how to add a link to every Polaroid (on click go to a new webpage)
Anybody out there willing to help me out?


Many thanks in advance as this has giving me a huge headache for the last couple of days!
Val


http://www.valvdb.com/polaroid/main.xml
and this is the action code in my Flash:

Code:
////////////////////////////////
// <imports>
import flash.filters.*;
import flash.display.BitmapData;
// </imports>
////////////////////////////////

////////////////////////////////
// <vars>
var photoHolder = new Array();
var skalerTempo = 3;
var thumbStr = 30;
var stageHeight = Stage.height;
var stageWidth = Stage.width;

// </vars>
////////////////////////////////

////////////////////////////////
// <init>
_root.createEmptyMovieClip("bakgrunsHolder",_root.getNextHighestDepth());
_root.createEmptyMovieClip("sideGlow", _root.getNextHighestDepth());
// </init>
////////////////////////////////

////////////////////////////////
// <generer fotovariabler>
flickrTAGS = (flickrTAGS) ? flickrTAGS:"";
xmlURL = (xmlURL) ? xmlURL:"main.xml";
xmlURL = (flickrID) ? "http://api.flickr.com/services/feeds/photos_public.gne?id="+flickrID+"&tags="+flickrTAGS+"&tagmode=any&format=rss_200":xmlURL;
////
// Flickr feed
////
var loadet_xml:XML = new XML();
loadet_xml.ignoreWhite = true;
loadet_xml.onLoad = function (success){
	var loop = (flickrID) ? loadet_xml.firstChild.firstChild.childNodes:loadet_xml.firstChild.childNodes;
	var num = 0;		
	if (flickrID) {
		for (var i = 0;i < loop.length;i++) {
			if (loop[i].nodeName == "item") {
				var loop2 = loop[i].childNodes;
				photoHolder[num] = new Array();
				for (var i2 = 0;i2 < loop2.length;i2++) {
					if (loop2[i2].nodeName == "media:content") {
						photoHolder[num].url = loop2[i2].attributes.url;
					}
					else if (loop2[i2].nodeName == "title") {
						photoHolder[num].desc = loop2[i2].firstChild;
					}
				}
				num++;
			}
		}
	}
	else {
		for (i=0;i < loop.length;i++) {
			photoHolder[i] = loop[i].attributes;
		}
	}
	delete loadet_xml;
	byggBilder();
}
loadet_xml.load(xmlURL);
// </generer fotovariabler>
////////////////////////////////

////////////////////////////////
// <bygg polaroids>
function byggBilder() {
	for (i=0;i < photoHolder.length;i++) {
		mc = _root.attachMovie("fotoHolder","fotoHolder"+i,_root.getNextHighestDepth(),{_xscale:thumbStr, _yscale:thumbStr,_rotation:30 - 60*Math.random()});
		mc.txt.text = photoHolder[i].desc;
		if (Math.round(Math.random()*1) == 1) {
			// tilfeldig y akse
			mc._y = (Stage.height*Math.random())+(mc._height*2);
			if (Math.round(Math.random()*1) == 1) mc._x = Stage.width+(mc._width*2);
			else mc._x = -(mc._width*2);
		}
		else {
			// tilfeldig x akse
			mc._x = (Stage.width*Math.random())+(mc._width*2);
			if (Math.round(Math.random()*1) == 1) mc._y = Stage.height+(mc._height*2);
			else mc._y = -(mc._height*2);
		}
		mc.newX = Math.round((mc._width/2) + (Stage.width-mc._width)*Math.random());
		mc.newY = Math.round((mc._height/2) + (Stage.height-mc._height)*Math.random());
		mc.oldRotation = mc._rotation;
		mc.oldX = mc.newX;
		mc.oldY = mc.newY;
		mc.startX = mc._x;
		mc.startY = mc._y;
		mc.oldHeight = mc._yscale;
		mc.oldWidth = mc._xscale;
		mc.id = i;
		mc.onEnterFrame = fotoAnimer;
		mc.filters = [fotoSkygge];
		mc.dragPol.onPress = drag;
		mc.dragPol.onReleaseOutside = mc.dragPol.onRelease = stopdrag;
		photoHolder[i].mc = mc;
		lastBilde(mc,photoHolder[i].url);
		delete mc;
	}
	antallBilder = i;
}
function lastBilde(mc, url) {
	mc.createEmptyMovieClip("tmp",mc.getNextHighestDepth());
	lastBildeH.loadClip(url, (flickrID) ? mc.bildeHolder:mc.tmp);
}
var lastBildeH:MovieClipLoader = new MovieClipLoader();
var lastBildeHL:Object = new Object();
lastBildeHL.onLoadStart = function(mc:MovieClip):Void {
	mc._parent.attachMovie('preLoader','preloader',mc._parent.getNextHighestDepth());
	loaderFarge = new Color(mc._parent.preloader);
	mc._parent.preloader.loadtxt.text = "";
	loaderFarge.setRGB(0xFFFFFF);
	mc._parent.preloader._y = -10;
	mc._visible = false;
}
lastBildeHL.onLoadProgress = function(mc:MovieClip, numBytesLoaded:Number, numBytesTotal:Number):Void {
    var numPercentLoaded:Number = numBytesLoaded / numBytesTotal * 100;
	mc._parent.preloader.percent._width = numPercentLoaded;
}
lastBildeHL.onLoadInit = function(mc:MovieClip) {
	mc._parent.preloader.removeMovieClip();
	var mc2 = mc._parent.bildeHolder;
	if (!flickrID) {
		var myBitmap = new BitmapData(mc._width, mc._height,true,0xFFFFFF);
		myBitmap.draw(mc);
    	mc._parent.bildeHolder.attachBitmap(myBitmap, mc._parent.bildeHolder.getNextHighestDepth(), "auto", true);
		mc.removeMovieClip();
		}
	
	/////
	// scale and place image
	////

	var wP = 468/mc2._width;
	var hP = 450/mc2._height;
	mc2._width *= (wP < hP) ? hP:wP;
	mc2._height *= (wP < hP) ? hP:wP;
	mc2._x += -((mc2._width-468)/2);
	mc2._y += -((mc2._height-450)/2);
	mc2._visible = true;
}
lastBildeH.addListener(lastBildeHL);
// </bygg polaroids>
////////////////////////////////

////////////////////////////////
// <hjelpeboks>
_root.attachMovie("help","help",_root.getNextHighestDepth());
help._x = 42;
help._y = 48;
help.filters = [fotoSkygge];
// </hjelpeboks>
////////////////////////////////

function rensFilm() {
	for (i=0;i<antallBilder;i++) {
		mc = eval("fotoHolder"+i);
		mc.oldY = mc.startY;
		mc.oldX = mc.startX;
		mc.onEnterFrame = fotoAnimerTilbake;
		removeMovieClip(navigering);
	}
}
function fotoAnimer() {
	this._y += (this.newY-this._y)/skalerTempo;
	this._x += (this.newX-this._x)/skalerTempo;
	if (Math.round(this._y) == this.newY) delete this.onEnterFrame;
}
function fotoAnimerTilbake() {
	this._y += (this.oldY-this._y)/skalerTempo;
	this._x += (this.oldX-this._x)/skalerTempo;
	this._xscale += (this.oldWidth-this._xscale)/skalerTempo;
	this._yscale += (this.oldHeight-this._yscale)/skalerTempo;
	this._rotation += (this.oldRotation-this._rotation)/skalerTempo;
	this.nesteKnapp._alpha += (0-this.nesteKnapp._alpha)/skalerTempo;
	this.forrigeKnapp._alpha += (0-this.forrigeKnapp._alpha)/skalerTempo;
	if ((Math.round(this._y) == this.oldY) && (Math.round(this._x) == this.oldX)) {
		delete this.nesteKnapp.onRelease;
		delete this.forrigeKnapp.onRelease;
		delete this.onEnterFrame;
	}
}
function fotoSkaler() {
	this._xscale += (100-this._xscale)/skalerTempo;
	this._yscale += (100-this._yscale)/skalerTempo;
	this._rotation += (this.newRotation-this._rotation)/skalerTempo;
	this._x += ((Stage.width/2)-this._x)/skalerTempo;
	this._y += ((Stage.height/2)-this._y)/skalerTempo;
	this.nesteKnapp._alpha += (60-this.nesteKnapp._alpha)/skalerTempo;
	this.forrigeKnapp._alpha += (60-this.forrigeKnapp._alpha)/skalerTempo;
	if (Math.round(this._width) == this.newWidth) {
		delete this.onEnterFrame;
	}
}
function drag() {
	if ((fotoSomBlirVist != this._parent) && (!this._parent.onEnterFrame)) this._parent.startDrag();
	if (!this.click) {
		this.click = true;
		this.timer = getTimer()/1000;
	}
	else {
		this.timer2 = getTimer()/1000;
		if ((this.timer2-this.timer)<.25) {
			visFoto(this._parent);
		}
		else {
			this.timer = getTimer()/1000;
			this.click = true;
		}
	}
	this._parent.swapDepths(_root.getNextHighestDepth());
	if (fotoSomBlirVist) fotoSomBlirVist.swapDepths(_root.getNextHighestDepth());
}
function stopdrag() {
	mc = this._parent;
	mc.stopDrag();
	if ((fotoSomBlirVist != mc) && (!mc.onEnterFrame)) {
		mc.oldX = Math.round(mc._x);
		mc.oldY = Math.round(mc._y);
	}
}
function visFoto() {



	if (fotoSomBlirVist) fotoSomBlirVist.swapDepths(_root.getNextHighestDepth());
}

var stageL:Object = new Object();
stageL.onResize = function() {
	for (i=0;i<antallBilder;i++) {
		mc = eval("fotoHolder"+i);
		if (mc != fotoSomBlirVist) {
			mc._x = Math.round(Stage.width * (mc._x/stageWidth));
			mc._y = Math.round(Stage.height * (mc._y/stageHeight));
		}
		else {
			fotoSomBlirVist._x = Stage.width/2;
			fotoSomBlirVist._y = Stage.height/2;
		}
		mc.oldX = Math.round(Stage.width * (mc.oldX/stageWidth));
		mc.oldY = Math.round(Stage.height * (mc.oldY/stageHeight));
		mc.newX = Math.round(Stage.width * (mc.newX/stageWidth));
		mc.newY = Math.round(Stage.height * (mc.newY/stageHeight));
		mc.startX = Math.round(Stage.width * (mc.startX/stageWidth));
		mc.startY = Math.round(Stage.height * (mc.startY/stageHeight));
	}
	stageWidth = Stage.width;
	stageHeight = Stage.height;
	fillBG();
	fyllGlow();
}
Stage.addListener(stageL);

////////////////////////////////

Last edited by Alex Vincent; 07-03-2009 at 07:57 PM.. Reason: Add
Ctje is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:16 PM.


Advertisement
Log in to turn off these ads.