...

View Full Version : Fading in Objects Problems



SantosJ
06-06-2006, 08:10 PM
The problem I'm currently having is within the Fade.In() and Fade.Out() methods where the setTimeout() is not accepting the this.setOpacity() method. I have tried a closure but since I have to use 'i' as the parameter, it isn't liking it.

It could be something else.

Fade Class:

function GameholeFade(id, speed)
{
this.opacity = id.style;

this.speed = speed || 100;
}

GameholeFade.prototype.setOpacity = function(value)
{
this.opacity.opacity = (value / 100);
this.opacity.MozOpacity = (value / 100);
this.opacity.KhtmlOpacity = (value / 100);
this.opacity.filter = "alpha(opacity=" + value + ")";
}

GameholeFade.prototype.In = function()
{
var speed = Math.round(this.speed/100);
var timer = 0;

var _this = this;
var fade = function () { }
for(i = 0; i <= 100; i++)
{
this.setOpacity(i);
}
}

GameholeFade.prototype.Out = function()
{
var speed = Math.round(this.speed/100);
var timer = 0;

var _this = this;
var fade = function () { }
for(i = 100; i >= 0; i--)
{
setTimeout(fade, (timer * speed));
this.setOpacity(i);
timer++;
}
}

Table Class:

function GameholeTable()
{
this.FlashContent = document.getElementById('FlashLogoContent');

this.Fade = null;

this.Started = false;
}

GameholeTable.prototype.Write = function(data)
{
this.Fade = new GameholeFade(document.getElementById('opacityKey'));
this.Fade.setOpacity(0);

if(this.Started == true)
{
this.Fade.Out();
}

// Assign Image values
var image = document.getElementById('flashgameimage');
image.setAttribute('src', data.image);
image.setAttribute('alt', data.title);
image.setAttribute('title', data.title);

var name = document.getElementById('flashgamename');
var title = document.createTextNode(data.title);
if(name.hasChildNodes() == true)
{
name.replaceChild(title, name.firstChild);
}
else
{
name.appendChild(title);
}

var description = document.getElementById('flashgamedescription');
description.innerHTML = data.description;

var gameplays = document.getElementById('flashgameplays');
var plays = document.createTextNode('Game Plays: ' + data.gameplays);

if(gameplays.hasChildNodes() == true)
{
gameplays.replaceChild(plays, gameplays.firstChild);
}
else
{
gameplays.appendChild(plays);
}

var id = document.getElementById('flashgamelink');
id.setAttribute('href', "play.php?id="+data.id);

// Fade In
this.Fade.In();

if(this.Started == false) this.Started = true;
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum