-
Making Images links in XML
I'm making a carasoul type navigation for a friends website, but have ran into a problem, I don't know how make the images links.
If someone could give me a push in the right direction, it'd be great.
I have no experience with XML.
XML File
Code:
<icons>
<icon image="dir.png" tooltip="Directory" />
<icon image="goo.png" tooltip="Open Goo" />
<icon image="vnc.png" tooltip="VNC" />
<icon image="com.png" tooltip="Comment Box" />
<icon image="swf.png" tooltip="Flash Stuff"/>
<icon image="php.png" tooltip="PhpMyAdmin" />
<icon image="otb.png" tooltip="OTB Site" />
</icons>
Actionscript
Code:
import mx.utils.Delegate;
var numOfItems:Number;
var radiusX:Number = 300;
var radiusY:Number = 75;
var centerX:Number = Stage.width / 2;
var centerY:Number = Stage.height / 2;
var speed:Number = 0.05;
var perspective:Number = 130;
var home:MovieClip = this;
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;
}
function released()
{
trace(this._parent.toolText);
}
function moveTip()
{
home.tooltip._x = this._parent._x;
home.tooltip._y = this._parent._y - this._parent._height/2;
}
xml.load("icons.xml");
function mover()
{
this._x = Math.cos(this.angle) * radiusX + centerX;
this._y = Math.sin(this.angle) * radiusY + centerY;
var s = (this._y - perspective) /(centerY+radiusY-perspective);
this._xscale = this._yscale = s*100;
this.angle += this._parent.speed;
this.swapDepths(Math.round(this._xscale) + 100);
}
this.onMouseMove = function()
{
speed = (this._xmouse-centerX)/2500;
}
I can post the complete files if there needed.
Thanks in advance
Last edited by dmillerw; 01-22-2009 at 02:51 AM.
-
FK'n_dog
add the link attribute to the xml -
PHP Code:
<icon image="dir.png" tooltip="Directory" link="dir.html" />
reference each link attribute to its movieclip in Flash -
PHP Code:
..........
t.link = nodes[i].attributes.link;
t.toolText = nodes[i].attributes.tooltip;
...........
show and open each link on the release event -
PHP Code:
function released(){
trace(this._parent.link);
// use getURL or externalInterface class to open the link - test online
}
hth
-
I'm sorry, but I don't quite get where to put everything?
-
FK'n_dog
the first set of code is the addition to the xml file
2nd and 3rd code goes in the Flash file
-
Oh.....I feel stupid now, thanks.
-
One thing however, what do I put for the getURL code
-
FK'n_dog
PHP Code:
function released(){
trace(this._parent.link); // is the output correct ?
getURL(this._parent.link, "_blank"); // opens a new browser window
}
hth
-
Oh........now I feel REALLY stupid, thanks for your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|