Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-02-2008, 10:05 AM   PM User | #1
Zube
New to the CF scene

 
Join Date: Dec 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Zube is an unknown quantity at this point
Flash/XML Navigation question

Ok, I'll try to make this the easiest description I can give

I'm working on the following code for a Flash/XML Navigation bar:


<?xml version="1.0" encoding="ISO-8859-1" ?>
<xml>

<mainmenu>
<title><![CDATA[NEWS]]></title>
<content>news.swf</content>
</mainmenu>

</xml>


What I am tryring to do is add a link to a "spotlight on" forum, using the code above, but I don't know how to make the code above call and open a new window to an external link.

I tried this, but it didn't work:


<?xml version="1.0" encoding="ISO-8859-1" ?>
<xml>

<mainmenu>
<title><![CDATA[NEWS]]></title>
<content>news.swf</content>
</mainmenu>

<mainmenu>
<a target="_blank" href="http://www.someurl.com">SOMEURL</a>
</mainmenu>

</xml>

Any idea how I can call for new page to an external link from within the XML?

Thanks and hope someone can help,
Zube
Zube is offline   Reply With Quote
Old 12-02-2008, 11:07 AM   PM User | #2
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
You have to also look at the Actionscript associated with this, can you post the relevant code? They have to work together, and I don't think this can be done with just XML, unless the Actionscript already has a method setup.

Also, do you have a link so we can see what you mean?
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Old 12-02-2008, 12:32 PM   PM User | #3
Zube
New to the CF scene

 
Join Date: Dec 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Zube is an unknown quantity at this point
Well, I'm new to all the Flash/XML stuff (mostly have done only html for the past few years.) Not really sure the exact place the Actionscript is located. I mean, I have a bunch of AS in the Flash file as well as a bunch of mosesSupposes Fuse files.

I bought this template: http://www.flashden.net/item/elite-xml-website/14773

The only problem is the maker of the template doesn't offer any support, and all the people on that websites forum want to charge an arm and a leg just to tell me how to add a link. I mean, I'd pay the money for an entire site redesign, but to pay the same money for the alteration just to add a link?

Anyway, I'll post what I can and maybe it will make sence:

The link to the myFunctions.as is here: http://zube.us/myFunctions.as

The link to the Fuse.as is here: http://zube.us/com/mosesSupposes/fuse/Fuse.as

And here's the config info from the Flash file:

Code:
System.useCodepage = true;
//Start Load Config function
loadConfig ();

var logoSmall;//Logo Small - Transparent PNG max size 160x75px
var websiteColor;//Hexadecinal 
var fullScreenActive;//true/false
var BackgroundActive;//true/false
var BackgroundMenuActive;//true/false
var BackgroundDefault;//file.swf String

//Fullscreen button visible start state
nav_menu.btn_fullscreen._visible = false;

loaderBackground._visible = true;

//LOAD CONFIG FILE -----------------------------------------------------------------------------------
function loadConfig () {

	var config:XML = new XML ();
	config.ignoreWhite = true;
	config.onLoad = function (success) {

		if (success) {
			var root:XMLNode = this.firstChild;

			//Set config variables
			logoSmall = root.childNodes[0].childNodes[0].nodeValue;// Logo Small
			websiteColor = root.childNodes[1].childNodes[0].nodeValue;// Website Color
			fullScreenActive = root.childNodes[2].childNodes[0].nodeValue;// Fullscreen Button Active
			BackgroundActive = root.childNodes[3].childNodes[0].nodeValue;// Backgrounds Active
			BackgroundMenuActive = root.childNodes[4].childNodes[0].nodeValue;// Background Menu Active
			BackgroundDefault = root.childNodes[5].childNodes[0].nodeValue;// Background Default SWF
			audioConsoleVisible = root.childNodes[6].childNodes[0].nodeValue;
			defaultHomepage = root.childNodes[7].childNodes[0].nodeValue;

			loader.percentTxt._tint = websiteColor
			balloonClose.txt._tint = websiteColor
			audioPlaylist.playlist._tint = websiteColor
			nav_menu.audioConsole.openPlaylist.balloon.closeLabel.closeTxt._tint = websiteColor;
			nav_menu.audioConsole.openPlaylist.balloon.openLabel.openTxt._tint = websiteColor;
			nav_menu.audioConsole.volumeDragger.line._tint = websiteColor;

			//Set fullscreen button active if configured in the config file -----
			if (fullScreenActive == "true") {
				nav_menu.btn_fullscreen._visible = true;
			}
			//------------------------------------------------------------------- 
			//Load Small logo in the stage
			loadLogo (logoSmall,nav_menu.logo_small,"ini");
			//-------------------------------------------------------------------
			//Load Background If Active
			if (BackgroundActive == "true") {
				//Set default background, send default parameter
				setEliteBackground (BackgroundDefault);

				//Check if backgrounds menu is active
				if (BackgroundMenuActive == "true") {
					//Build backgrounds menu
					loadBackgroundsMenu ();
				}
			}
			//
			if(audioConsoleVisible == "true"){
				nav_menu.audioConsole.startAudioConsole();
			}
			else{
				nav_menu.audioConsole._visible = false;
			}
			loadMovieClip (defaultHomepage,content_container);
		}
	};
	//Path to the config file
	config.load ("xml/elite_website_config.xml");
}

//Function to set the background swf
function setEliteBackground (bkg:String) {
	ZigoEngine.doTween (bkg_container,'_alpha',0,1,"easeOutExpo",0,function(){
		loadBackgroundClip (bkg,bkg_container,"ini");
	});
}

//LOAD AND PLACE BACKGROUND CONFIGURATION MENU -----------------------------------------------------------------------
function loadBackgroundsMenu () {

	var backgroundsMenu:XML = new XML ();
	backgroundsMenu.ignoreWhite = true;

	backgroundsMenu.onLoad = function (success) {

		if (success) {

			var root:XMLNode = this.firstChild;
			//Cicle through all backgounds available in the XML file
			for (i = 0; i < root.childNodes.length; i++) {
				var bkgThumbnail:String = root.childNodes[i].attributes.tmb;
				var bkgSwf:String = root.childNodes[i].childNodes[0].nodeValue;

				//Attach background thumbnail
				nav_menu.bkg_container_1.attachMovie ("bgk_menu_container","bgk_menu_container" + i,i);
				//Set the right position for each background in XML
				nav_menu.bkg_container_1["bgk_menu_container" + i]._x = -i * 20;

				//Add images to the backgrounds thumbnails
				loadMovie ("backgrounds/" + bkgThumbnail, nav_menu.bkg_container_1["bgk_menu_container" + i].bgk_thumbnail);

				//Create new instance of the button
				nav_menu.bkg_container_1["bgk_menu_container" + i].btn.newInstance = bkgSwf;

				//Add the event on release to the button
				nav_menu.bkg_container_1["bgk_menu_container" + i].btn.onRelease = function () {

					//Load bavkground stored in the button instance
					setEliteBackground (this.newInstance);

				};
			}
		}
	};
	backgroundsMenu.load ("xml/elite_backgrounds.xml");
}


//LOAD AND PLACE SMALL LOGO ------------------------------------------------------------------------------------------
//The small logo is configured on the XML config file.
//NOTE: The big logo on the homepage is a external SWF file.
function loadLogo (externalTarget:String, targetRoot:MovieClip, action:String) {

	var mcLoader:MovieClipLoader = new MovieClipLoader ();
	var listenerLoad:Object = new Object ();

	listenerLoad.onLoadStart = function (target:MovieClip) {
		targetRoot._alpha = 0;
		isLoading = true;
	};
	//On Load Complete
	listenerLoad.onLoadInit = function (target:MovieClip):Void  {

		if (action == "ini") {
			ZigoEngine.doTween (targetRoot,'_alpha',100,3,"easeOutExpo");
		}
		target.onRelease = function(){
			ZigoEngine.doTween (content_container,'_alpha',0,0.5,"easeOutExpo",0,function () {
				loadMovieClip (defaultHomepage,content_container);
				clearMainMenu ();
			});
		}
		//Center position of the small logo considering an area of 160x75px 
		target._x = 160 / 2 - target._width / 2;
		target._y = 75 / 2 - target._height / 2 - 100;
		
		isLoading = false;
	};
	mcLoader.addListener (listenerLoad);
	mcLoader.loadClip (externalTarget,targetRoot);
}
//--------------------------------------------------------------------------------------

//Function used to load external SWF Background files and call the loaderBackground MC -------------------------------------------
function loadBackgroundClip (externalTarget:String, targetRoot:MovieClip) {

	var mcLoader:MovieClipLoader = new MovieClipLoader ();
	var listenerLoad:Object = new Object ();

	listenerLoad.onLoadStart = function (target:MovieClip) {
		loaderBackground._width = 0;
		loaderBackground._visible = true;
		bkg_container._alpha = 0
	};
	//Loading Progress
	listenerLoad.onLoadProgress = function (target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void  {
		sizeBar = Math.round (bytesLoaded / bytesTotal * Stage.width);
		loaderBackground._width = sizeBar
	};
	//On Load Complete
	listenerLoad.onLoadComplete = function (target:MovieClip):Void  {
		loaderBackground._visible = false;
		bkg_container._alpha = 0
		ZigoEngine.doTween (bkg_container,'_alpha',100,1,"easeOutExpo");
	};

	mcLoader.addListener (listenerLoad);
	mcLoader.loadClip (externalTarget,targetRoot);
}
//--------------------------------------------------------------------------------------
Zube is offline   Reply With Quote
Old 12-02-2008, 12:33 PM   PM User | #4
Zube
New to the CF scene

 
Join Date: Dec 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Zube is an unknown quantity at this point
Oops, forgot to the the functions info from the Flash file:

Code:
nav_menu.audioConsole.volumeDragger.dragger.volumePercent._visible = false;
//
content_blocker._visible = true;
content_container._alpha = 0;
//
nav_menu.backMenu_left._alpha = 0;
nav_menu.backMenu_center._alpha = 0;
nav_menu.backMenu_right._alpha = 0;
//
loadMainMenu ();
//
var mouseListener:Object = new Object ();
mouseListener.onMouseMove = function () {
	//
	balloonClose._x = Math.floor (_xmouse);
	balloonClose._y = Math.floor (_ymouse);
	//
};
Mouse.addListener (mouseListener);
//
function clearMainMenu () {

	for (a = 0; a < xmlTotalItems; a++) {
		nav_menu.attachMainMenu["mainMenuItem" + a].menuTitle._tint = 0x707070;
		nav_menu.attachMainMenu["mainMenuItem" + a].bt.enabled = true;
	}
	thisNav = undefined;

	if (subMenuOpened == true) {
		ZigoEngine.doTween (nav_menu,'_y',Stage.height + 25,0.5,"easeOutExpo");
		closeAudioPlaylist._height = Stage.height - 95;
		subMenuOpened = false;
		content_container.myListenerload.onResize ();
	}
}
//
function loadMainMenu () {

	var mainMenu:XML = new XML ();
	mainMenu.ignoreWhite = true;

	mainMenu.onLoad = function (success) {
		if (success) {
			var xml:XMLNode = this.firstChild;
			xmlTotalItems = xml.childNodes.length;
			for (i = 0; i < xml.childNodes.length; i++) {
				var itemTitle:String = xml.childNodes[i].childNodes[0].childNodes[0].nodeValue;
				var itemContent:String = xml.childNodes[i].childNodes[1].childNodes[0].nodeValue;

				nav_menu.attachMainMenu.attachMovie ("mainMenuItem","mainMenuItem" + i,i);

				nav_menu.attachMainMenu["mainMenuItem" + i].menuTitle.txt.htmlText = itemTitle;
				nav_menu.attachMainMenu["mainMenuItem" + i].menuTitle.txt.autoSize = true;

				if (i == 0) {
					nav_menu.attachMainMenu["mainMenuItem" + i]._x = i;
					nav_menu.attachMainMenu["mainMenuItem" + i].tabs._x = nav_menu.attachMainMenu["mainMenuItem" + i].menuTitle._width + 15;
					nav_menu.attachMainMenu["mainMenuItem" + i].bt._width = nav_menu.attachMainMenu["mainMenuItem" + i].menuTitle._width;
				}
				else {
					nav_menu.attachMainMenu["mainMenuItem" + i]._x = nav_menu.attachMainMenu["mainMenuItem" + (i - 1)]._x + nav_menu.attachMainMenu["mainMenuItem" + (i - 1)]._width + 15;
					nav_menu.attachMainMenu["mainMenuItem" + i].bt._width = nav_menu.attachMainMenu["mainMenuItem" + i]._width;
					if (i == xmlTotalItems - 1) {
						nav_menu.attachMainMenu["mainMenuItem" + i].tabs._visible = false;
					}
					else {
						nav_menu.attachMainMenu["mainMenuItem" + i].tabs._x = nav_menu.attachMainMenu["mainMenuItem" + i].menuTitle._width + 15;
					}
				}
				nav_menu.backMenu_center._x = nav_menu.backMenu_left._x;
				nav_menu.backMenu_center._width = nav_menu.attachMainMenu._width;
				nav_menu.backMenu_right._x = nav_menu.attachMainMenu._x + nav_menu.attachMainMenu._width;

				nav_menu.backMenu_left._alpha = 35;
				nav_menu.backMenu_center._alpha = 35;
				nav_menu.backMenu_right._alpha = 35;

				nav_menu.attachMainMenu["mainMenuItem" + i].bt.instance = i;
				nav_menu.attachMainMenu["mainMenuItem" + i].bt.instanceText = itemContent;

				nav_menu.attachMainMenu["mainMenuItem" + i].bt.onRollOver = nav_menu.attachMainMenu["mainMenuItem" + i].bt.onDragOver = function () {
					ZigoEngine.doTween (this._parent.menuTitle,'_tint',websiteColor,0.5,"easeOutExpo");
				};
				nav_menu.attachMainMenu["mainMenuItem" + i].bt.onRollOut = nav_menu.attachMainMenu["mainMenuItem" + i].bt.onDragOut = function () {
					ZigoEngine.doTween (this._parent.menuTitle,'_tint',0x707070,0.5,"easeOutExpo");
				};
				nav_menu.attachMainMenu["mainMenuItem" + i].bt.onRelease = function () {

					lastSubNav = undefined;
					thisSubNav = undefined;

					lastNav = thisNav;
					thisNav = this.instance;

					ZigoEngine.doTween (this._parent.menuTitle,'_tint',websiteColor,0.5,"easeOutExpo");
					ZigoEngine.doTween (nav_menu.attachMainMenu["mainMenuItem" + lastNav].menuTitle,'_tint',0x707070,0.5,"easeOutExpo");

					nav_menu.attachMainMenu["mainMenuItem" + lastNav].bt.enabled = true;

					this.enabled = false;

					if (this.instanceText == "submenu") {
						ZigoEngine.doTween (nav_menu,'_y',Stage.height,0.5,"easeOutExpo");
						if (subMenuOpened == true) {
							ZigoEngine.doTween (nav_menu,'_y',Stage.height + 25,0.5,"easeOutExpo",0,function () {
							ZigoEngine.doTween (nav_menu,'_y',Stage.height,0.5,"easeOutExpo");
							subMenuOpened = true;
							loadSubMenu ();
							});
						}
						else {
							subMenuOpened = true;
							loadSubMenu ();
						}
					}
					else {
						subMenuOpened = false;
						ZigoEngine.doTween (nav_menu,'_y',Stage.height + 25,0.5,"easeOutExpo");
						closeAudioPlaylist._height = Stage.height - 95;
						swfToOpen = this.instanceText;
						content_blocker._visible = true;
						ZigoEngine.doTween (content_container,'_alpha',0,0.5,"easeOutExpo",0,function () {
						loadMovieClip (swfToOpen,content_container);
						});
					}
				};
			}
		}
	};
	mainMenu.load ("xml/elite_website_contents.xml");
}
//
function loadSubMenu () {

	for (a = 0; a < xmlSubMenuTotalItems; a++) {
		removeMovieClip (nav_menu.attachSubMenu["subMenuItem" + a]);
	}
	var subMenu:XML = new XML ();
	subMenu.ignoreWhite = true;
	subMenu.onLoad = function (success) {
		if (success) {
			var xml:XMLNode = this.firstChild.childNodes[thisNav].childNodes[2];
			xmlSubMenuTotalItems = xml.childNodes.length;
			for (i = 0; i < xml.childNodes.length; i++) {
				var subMenuTitle:String = xml.childNodes[i].childNodes[0].childNodes[0].nodeValue;
				var subMenuContent:String = xml.childNodes[i].childNodes[1].childNodes[0].nodeValue;

				nav_menu.attachSubMenu.attachMovie ("subMenuItem","subMenuItem" + i,i);

				nav_menu.attachSubMenu["subMenuItem" + i].subMenuTitle.txt.htmlText = subMenuTitle;
				nav_menu.attachSubMenu["subMenuItem" + i].subMenuTitle.txt.autoSize = true;

				if (i == 0) {
					nav_menu.attachSubMenu["subMenuItem" + i]._x = i;
					nav_menu.attachSubMenu["subMenuItem" + i].back._tint = websiteColor;
					nav_menu.attachSubMenu["subMenuItem" + i].back._width = nav_menu.attachSubMenu["subMenuItem" + i].subMenuTitle._width + 10;
					nav_menu.attachSubMenu["subMenuItem" + i].tabs._x = nav_menu.attachSubMenu["subMenuItem" + i].back._width;
					nav_menu.attachSubMenu["subMenuItem" + i].bt._width = nav_menu.attachSubMenu["subMenuItem" + i].back._width;
				}
				else {
					nav_menu.attachSubMenu["subMenuItem" + i]._x = nav_menu.attachSubMenu["subMenuItem" + (i - 1)]._x + nav_menu.attachSubMenu["subMenuItem" + (i - 1)].back._width;
					nav_menu.attachSubMenu["subMenuItem" + i].back._tint = websiteColor;
					nav_menu.attachSubMenu["subMenuItem" + i].back._width = nav_menu.attachSubMenu["subMenuItem" + i].subMenuTitle._width + 10;
					nav_menu.attachSubMenu["subMenuItem" + i].bt._width = nav_menu.attachSubMenu["subMenuItem" + i].back._width;
					if (i == xmlSubMenuTotalItems - 1) {
						nav_menu.attachSubMenu["subMenuItem" + i].tabs._visible = false;
					}
					else {
						nav_menu.attachSubMenu["subMenuItem" + i].tabs._x = nav_menu.attachSubMenu["subMenuItem" + i].back._width;
					}
				}
				//
				thisSubNav = 0;

				nav_menu.attachSubMenu["subMenuItem" + 0].bt.enabled = false;
				nav_menu.attachSubMenu["subMenuItem" + 0].back._alpha = 100;

				swfSubToOpen = xml.childNodes[0].childNodes[1].childNodes[0].nodeValue;

				content_blocker._visible = true;
				ZigoEngine.doTween (content_container,'_alpha',0,0.5,"easeOutExpo",0,function () {
					loadMovieClip (swfSubToOpen,content_container);
				});
				//
				nav_menu.attachSubMenu["subMenuItem" + i].bt.instanceSub = i;
				nav_menu.attachSubMenu["subMenuItem" + i].bt.instanceSubText = subMenuContent;

				nav_menu.attachSubMenu["subMenuItem" + i].bt.onRelease = function () {
					lastSubNav = thisSubNav;
					thisSubNav = this.instanceSub;

					this.enabled = false;
					this._parent.back._alpha = 100;

					ZigoEngine.doTween (nav_menu.attachSubMenu["subMenuItem" + lastSubNav].back,'_alpha',0,0.5,"easeOutExpo");
					nav_menu.attachSubMenu["subMenuItem" + lastSubNav].bt.enabled = true;

					swfSubToOpen = this.instanceSubText;

					content_blocker._visible = true;
					ZigoEngine.doTween (content_container,'_alpha',0,0.5,"easeOutExpo",0,function () {
					loadMovieClip (swfSubToOpen,content_container);
					});
				};
			}
		}
	};
	subMenu.load ("xml/elite_website_contents.xml");
}

//Function used to load external SWF files and call the loader MC -------------------------------------------
function loadMovieClip (externalTarget:String, targetRoot:MovieClip) {

	var mcLoader:MovieClipLoader = new MovieClipLoader ();
	var listenerLoad:Object = new Object ();

	listenerLoad.onLoadStart = function (target:MovieClip) {
		loader._visible = true;
		ZigoEngine.doTween (loader,'_alpha',100,0.5,"easeOutExpo");

	};
	//Loading Progress
	listenerLoad.onLoadProgress = function (target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void  {
		percent = Math.round (bytesLoaded / bytesTotal * 100);
		loader.percentTxt.text = percent + "%";
	};
	//On Load Complete
	listenerLoad.onLoadComplete = function (target:MovieClip):Void  {
		ZigoEngine.doTween (loader,'_alpha',0,0.5,"easeOutExpo",0,function () {
		loader._visible = false;
		});
		ZigoEngine.doTween (content_container,'_alpha',100,0.5,"easeOutExpo",0,function () {
		content_blocker._visible = false;
		});
	};

	mcLoader.addListener (listenerLoad);
	mcLoader.loadClip (externalTarget,targetRoot);
}
//--------------------------------------------------------------------------------------
Zube is offline   Reply With Quote
Old 12-02-2008, 12:54 PM   PM User | #5
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
The file is not designed to handle just a normal link at the bottom. Strange I know, but it was not part of the designers concept.

So it would take me a little while to write the code and figure it out (with the FLA) so it would take some time. However, you could also make a new SWF to be loaded in that slot, which inside the FLA there is a link to the page. I know its an extra click, but I think that is the easiest way without really tackling the code.
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Old 12-02-2008, 07:09 PM   PM User | #6
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
this thread belong to flash forum, not xml,

best regards
oesxyl is offline   Reply With Quote
Old 12-03-2008, 03:38 PM   PM User | #7
Alex Vincent
Moderator


 
Join Date: May 2002
Location: Hayward, CA
Posts: 1,427
Thanks: 1
Thanked 19 Times in 17 Posts
Alex Vincent is on a distinguished road
Here you go.
__________________
"The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
June 30, 2001
author, Verbosio prototype XML Editor
author, JavaScript Developer's Dictionary
https://alexvincent.us/blog
Alex Vincent is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:01 PM.


Advertisement
Log in to turn off these ads.