Jump to content


Photo

[Actionscript 2.0] Creatign a clickable link from a php variable


  • Please log in to reply
No replies to this topic

#1 ReZTeR

ReZTeR

    Young Padawan

  • Members
  • Pip
  • 9 posts

Posted 07 December 2010 - 02:00 AM

Hey there, first of all I'd like to make it clear that I don't know ANYTHING about actionscript so please don't mock my stupidity ahaha. Alright, well.. I've got a gallery that I created from a tutorial/download and it's basically a full code that I put on a frame and then it does all the work. It loads the images, puts them side by side, makes them scroll from right to left continuously. What I want is to basically jsut have the whole canvas clickable that will go to a link.

I can't create anything above this so that rules out the option of creating a button on top. However the images themselves (which cover the entire canvas) do have the kind of 'click/thumb' cursor when you hover over them but do nothing when you click. So I assume if you could somehow stick a 'on click... blah blah blah' code in here somewhere it should work, right? Like I said I don't know anything about this so I'm really relying on your support.

The URL I want to use is a variable that I have set in a PHP file. I'd like to keep it dynamic. I know it makes things more difficult but it just makes sense.

Anyway here's the code I have:

#include "mc_tween_lite.as"

var home:MovieClip = this;
var imgArray:Array = ["images/lookbook/1.jpg", "images/lookbook/2.jpg", "images/lookbook/3.jpg", "images/lookbook/4.jpg", "images/lookbook/5.jpg"];
var seqArray:Array = new Array;
var maxWidth:Number = 0;
var maxHeight:Number = 0;
var padding:Number = 0;
var imgCount:Number = 0;
var imgMCL:MovieClipLoader = new MovieClipLoader;
var mclListen:Object = new Object;

imgMCL.addListener(mclListen);
loadImage(imgCount);

function loadImage(num:Number) {
	t = home.createEmptyMovieClip("item"+seqArray.length, home.getNextHighestDepth());
	t._alpha = 0;
	t.createEmptyMovieClip("img", t.getNextHighestDepth());
	imgMCL.loadClip(imgArray[num], t.img);
	seqArray.push(t);
}

mclListen.onLoadInit = function(target:MovieClip) {
	target._x = -target._width/2;
	target._y = -target._height/2;
	if (target._width > maxWidth) {
		maxWidth = target._width;
	}
	if (target._height > maxHeight) {
		maxHeight = target._height;
	}
	if (imgCount < (imgArray.length-1)) {
		imgCount++;
		loadImage(imgCount);
	}else {
		spaceIt();
	}
}

function spaceIt() {
	seqArray[0]._x =  (seqArray[0]._width/2) + padding;
	seqArray[0]._y = (maxHeight/2);
	for (a:Number=1;a<seqArray.length;a++) {
		seqArray[a]._y = (maxHeight/2);
		seqArray[a]._x = seqArray[a-1]._x + (seqArray[a-1]._width/2) + (seqArray[a]._width/2) + padding;
	}
	if ((seqArray[seqArray.length-1]._x - (seqArray[seqArray.length-1]._width/2)) < (Stage.width+maxWidth+padding))  {
		imgCount = 0;
		loadImage(imgCount);
	} else {
		for (c:Number=0;c<seqArray.length;c++) {
			seqArray[c].alphaTo(100, 1);
			seqArray[c].onRollOver = over;
			seqArray[c].onRollOut = seqArray[c].onReleaseOutside = out;
		}
		home.onEnterFrame = moveEm;
	}
}
function moveEm() {
	seqArray[0]._x -=(Number=1.6);
	for (b:Number=1; b<seqArray.length; b++) {
		seqArray[b]._x = seqArray[b-1]._x + (seqArray[b-1]._width/2) + (seqArray[b]._width/2) + padding;
	}
	if (seqArray[0]._x <= -seqArray[0]._width/2) {
		z = seqArray.shift();
		z._x = seqArray[seqArray.length-1]._x + (seqArray[seqArray.length-1]._width/2) + (z._width/2) + padding;
		seqArray.push(z);
	}
}

Thanks in advance!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users