Access Data from an Item

You can access data from an item by accessing the data object directly inside the movie clip of the item. For example, if you would like to go to the URL specified in the link property when clicking on an item, you would do the following:

Edit the movie clip of the item and enter the following ActionScript code on the timeline of the movie clip of the item:

this.onRelease = function() {

getURL(data.link, "_blank");

}

You can specify anything in the link property of an item - for example, a frame number or a movie to load. For example, if you specify a frame number, your code would look something like this:

this.onRelease = function() {

gotoAndPlay(data.link);

}

 

Accessing data from an image item defined in an XML file

You can apply events to image items that are loaded through an XML file. For example, your XML file may look like this:

<?xml version="1.0" encoding="UTF-8"?>
<items>

<item linkageId="3DMenu_imgLoader" id="item1">

<position x="0" y="0" z="0" />
<link>images/about.jpg</link>
<name>About</name>

<url>about.html</url>

</item>

</items>

In order to open the URL when clicking on this image, you would enter the following ActionScript code on the main timeline of your movie:

//image event
menu.addEventListener("onReleaseImage",this);

function onReleaseImage(evt:Object){

getURL(evt.item.url, "_blank");

}

Note: The sample code above assumes that your 3DMenu has an instance name of menu.

 

Accessing data from an item defined through ActionScript or XML

If you initialize items using ActionScript or XML, you can retrieve the data assigned to the item by accessing the data object that you use to create the item. For example:

var item={linkageId:"item",id:"item1",x:100,y:0,z:0,link:"home.html"};

var lis={};
lis.onInit=function(){

menu.addItem(item);

trace(menu.getObject("item1").link);

trace(menu.getObject("item2").link);

trace(menu.getObject("item2").author);

}

menu.addEventListener("onInit",lis);

 

Note: The sample code above assumes that your 3DMenu has an instance name of menu. In this example, item1 is set from AS, item2 is set from XML.