en un flash tengo el menu, y el as2 esta a parte, y jalo el as por un
Código ActionScript :
#include "vertical_menu.as"
pero ya que todo lo demás lo estoy haciendo con as3, el menú no me funciona, asi que espero me puedan ayudar a convertir este as. encontré una pag donde convierte el codigo de as2 a as3, pero ya no puedo importarlo con el #include si es que lo convierto, les pongo ambos codigos a ver si alguien puede ayudarme.
as2
Código ActionScript :
// menu item bottom space. default value is 16;
// You can change this if sometimes needed.
var item_bottom_space:Number = 16;
function CreateMenu(menu_xml) {
var items = menu_xml.firstChild.firstChild.childNodes;
var color_on = menu_xml.childNodes[1].firstChild.attributes.menu_on;
var color_off = menu_xml.childNodes[1].firstChild.attributes.menu_off;
var linecolor = menu_xml.childNodes[1].firstChild.attributes.lines;
var lines_on = menu_xml.childNodes[1].childNodes[1].attributes.visible;
var menu_width:Number = menu_xml.childNodes[1].childNodes[2].attributes.width;
var item_count:Number = 0;
for (var i = 0; i<items.length; i++) {
var item_mc = menu_mc.attachMovie("menu_item", "item"+item_count, item_count);
item_mc.onRollOver = function() {
letsdoOn(this);
};
item_mc.onRollOut = function() {
letsdoOff(this);
};
item_mc.mylink = menu_xml.firstChild.childNodes[0].childNodes[i].attributes.destination;
item_mc.mytarget = menu_xml.firstChild.childNodes[0].childNodes[i].attributes.urltarget;
item_mc.mytype = menu_xml.firstChild.childNodes[0].childNodes[i].attributes.type;
item_mc.onRelease = function() {
letsdoClick(this.mylink, this.mytarget, this.mytype, this);
};
item_mc._x = item_count*(item_mc.m_item.menu_txt.textHeight+item_bottom_space);
item_mc.edge._height = item_mc.m_item.menu_txt.textHeight+item_bottom_space;
item_mc.mask._height = item_mc.m_item.menu_txt.textHeight+item_bottom_space;
item_mc.line._width = item_mc.edge._width=item_mc.mask._width=menu_width;
if (lines_on != "yes") {
item_mc.line._visible = false;
} else {
var line_color:Color = new Color(item_mc.line);
line_color.setRGB(linecolor);
}
item_count++;
var menu_mcArray = new Array(menu_mc.item0,menu_mc.item1,menu_mc.item2,menu_mc.item3,menu_mc.item4);
// menuCurrent = "0";
currButton = menu_mcArray[menuCurrent-1];
currButton.gotoAndPlay("on_stopped");
item_mc.m_item.menu_txt.text = item_mc.m_item2.menu_txt.text=items[i].firstChild.nodeValue;
item_mc.m_item.menu_txt.textColor = color_off;
item_mc.m_item2.menu_txt.textColor = color_on;
item_mc.m_item.menu_txt.autoSize = item_mc.m_item2.menu_txt.autoSize="left";
if (i == (items.length-1)) {
var item_mc2 = menu_mc.attachMovie("line", "item"+item_count, item_count);
if (lines_on != "no") {
item_mc2._visible = false;
} else {
var line_color2:Color = new Color(item_mc2);
line_color2.setRGB(linecolor);
}
item_mc2._x = item_count*(item_mc.m_item.menu_txt.textHeight+item_bottom_space);
item_mc2._width = item_mc.edge._width=item_mc.mask._width=menu_width;
}
}
}
function letsdoOn(thisButton) {
if (thisButton != currButton) {
thisButton.gotoAndPlay("on");
}
}
function letsdoOff(thisButton) {
if (thisButton != currButton) {
thisButton.gotoAndPlay("off");
}
}
function letsdoClick(what, whatTarget, whatType, thisButton) {
if (whatType != "url") {
// if menu link isn't defined in XML as external link (url),
// tells movieclip named "contents" navigate to corresponding frame;
// "what" variable is taken from XML node <item> under attribute "destination";
// XMl code: <item destination="label4">Menu</item>
contents.gotoAndPlay(what); // you can modify this line to run your own function with "what" variable parsed from XML file.
if (thisButton != currButton) {
currButton.gotoAndPlay("off");
currButton = thisButton;
}
}
else {
// if menu link is defined in XML as external link (url)
// "what" variable is taken from XML node <item> under attribute "destination";
// "whatTarget" variable is taken from XML node <item> under attribute "urltarget";
// XMl code: <item destination="http://www.url.com/" urltarget="_blank">Menu</item>
getURL(what, whatTarget);
}
}
// XML file parsing
var menu_xml = new XML();
menu_xml.ignoreWhite = true;
menu_xml.onLoad = function(success) {
if (success) {
CreateMenu(this);
} else {
trace("XML file not loaded...");
}
};
menu_xml.load("vertical_menu.xml");
menu_mc.menu_item_template._visible = false; // hide menu_mc.menu_item_template
as3 con la conversion de la pagina , pero como no se mucho aun, no se si es correcta
les pongo el link de la pag, por si a alguien le interesa, si es que la conversion es buena "http://www.5etdemi.com/convert/index.php"
Código ActionScript :
package {
// contextMenu item bottom space. default value is 16;
import flash.xml.XMLDocument;
import flash.net.navigateToURL;
import flash.net.URLRequest;
// You can change this if sometimes needed.
var item_bottom_space:Number = 16;
function CreateMenu(menu_xml) {
public var items = menu_xml.firstChild.firstChild.childNodes;
public var color_on = menu_xml.childNodes[1].firstChild.attributes.menu_on;
public var color_off = menu_xml.childNodes[1].firstChild.attributes.menu_off;
public var linecolor = menu_xml.childNodes[1].firstChild.attributes.lines;
public var lines_on = menu_xml.childNodes[1].childNodes[1].attributes.visible;
public var menu_width:Number = menu_xml.childNodes[1].childNodes[2].attributes.width;
public var item_count:Number = 0;
for (public var i = 0; i<items.length; i++) {
public var item_mc = menu_mc.attachMovie("menu_item", "item"+item_count, item_count);
item_mc.onRollOver = function() {
letsdoOn(this);
};
item_mc.onRollOut = function() {
letsdoOff(this);
};
item_mc.mylink = menu_xml.firstChild.childNodes[0].childNodes[i].attributes.destination;
item_mc.mytarget = menu_xml.firstChild.childNodes[0].childNodes[i].attributes.urltarget;
item_mc.mytype = menu_xml.firstChild.childNodes[0].childNodes[i].attributes.type;
item_mc.onRelease = function() {
letsdoClick(this.mylink, this.mytarget, this.mytype, this);
};
item_mc.x = item_count*(item_mc.m_item.menu_txt.textHeight+item_bottom_space);
item_mc.edge.height = item_mc.m_item.menu_txt.textHeight+item_bottom_space;
item_mc.mask.height = item_mc.m_item.menu_txt.textHeight+item_bottom_space;
item_mc.line.width = item_mc.edge.width=item_mc.mask.width=menu_width;
if (lines_on != "yes") {
item_mc.line.visible = false;
} else {
public var line_color:Color = new Color(item_mc.line);
line_color.setRGB(linecolor);
}
item_count++;
var menu_mcArray = new Array(menu_mc.item0,menu_mc.item1,menu_mc.item2,menu_mc.item3,menu_mc.item4);
// menuCurrent = "0";
currButton = menu_mcArray[menuCurrent-1];
currButton.gotoAndPlay("on_stopped");
item_mc.m_item.menu_txt.text = item_mc.m_item2.menu_txt.text=items[i].firstChild.nodeValue;
item_mc.m_item.menu_txt.textColor = color_off;
item_mc.m_item2.menu_txt.textColor = color_on;
item_mc.m_item.menu_txt.autoSize = item_mc.m_item2.menu_txt.autoSize="left";
if (i == (items.length-1)) {
public var item_mc2 = menu_mc.attachMovie("line", "item"+item_count, item_count);
if (lines_on != "no") {
item_mc2.visible = false;
} else {
var line_color2:Color = new Color(item_mc2);
line_color2.setRGB(linecolor);
}
item_mc2.x = item_count*(item_mc.m_item.menu_txt.textHeight+item_bottom_space);
item_mc2.width = item_mc.edge.width=item_mc.mask.width=menu_width;
}
}
}
function letsdoOn(thisButton) {
if (thisButton != currButton) {
thisButton.gotoAndPlay("on");
}
}
function letsdoOff(thisButton) {
if (thisButton != currButton) {
thisButton.gotoAndPlay("off");
}
}
function letsdoClick(what, whatTarget, whatType, thisButton) {
if (whatType != "url") {
// if contextMenu link isn't defined in XMLDocument as external link (url),
// tells movieclip named "contents" navigate to corresponding frame;
// "what" variable is taken from XMLDocument node <item> under attribute "destination";
// XMl code: <item destination="label4">Menu</item>
contents.gotoAndPlay(what); // you can modify this line to run your own function with "what" variable parsed from XMLDocument file.
if (thisButton != currButton) {
currButton.gotoAndPlay("off");
currButton = thisButton;
}
}
else {
// if contextMenu link is defined in XMLDocument as external link (url)
// "what" variable is taken from XMLDocument node <item> under attribute "destination";
// "whatTarget" variable is taken from XMLDocument node <item> under attribute "urltarget";
// XMl code: <item destination="http://www.url.com/" urltarget="_blank">Menu</item>
var request:URLRequest = new URLRequest(what);
navigateToURL(request, whatTarget);
}
}
// XMLDocument file parsing
var menu_xml = new XMLDocument();
menu_xml.ignoreWhite = true;
menu_xml.onLoad = function(success) {
if (success) {
CreateMenu(this);
} else {
trace("XMLDocument file not loaded...");
}
};
menu_xml.load("vertical_menu.xml");
menu_mc.menu_item_template.visible = false; // hide menu_mc.menu_item_template
}gracias
