Groups | Blog | Home
all groups > flash actionscript > december 2006 >

flash actionscript : Object oriented onRollOver



Brenton07
12/9/2006 7:44:05 PM
I'm working on my first XML project, and am looking to get a little deeper into
it. My next step is I want to replace the image that is loaded through XML to a
different image, but only on roll over and I need it to switch back when I
rollOut. I think I should just make another XML that refers to a different set
that corresponds to the first set of images, but am still a little foggy on how
to properly program it. THANKS!

var home:MovieClip = this;
theText._alpha = 0;


var tooltip:MovieClip = this.attachMovie("tooltip","tooltip",10000);
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[i].attributes.tooltip;
t.icon.inner.loadMovie(nodes[i].attributes.image);
t.r.inner.loadMovie(nodes[i].attributes.image);
t.icon.onRollOver = over;
t.icon.onRollOut = out;
t.icon.onRelease = released;
}
}

function over()
{

home.tooltip.tipText.text = this._parent.toolText;
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()
{
delete home.tooltip.onEnterFrame;
home.tooltip._alpha = 0;
}
cinemaguy
12/10/2006 12:10:31 AM
I would put the over function and the out function inside the xml.onLoad
function and load your images into an array and then you can just switch them
out by calling them from the array. I have a tutorial on my site on an easy way
to load xml into array
http://www.explorinlauren.com/repository/flash/actionscript/load-xml-into-array.
html

I hope that made some sense. If not I can answer any questions that you have.
Brenton07
12/11/2006 1:26:50 AM
AddThis Social Bookmark Button