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 06-30-2012, 02:27 PM   PM User | #1
maxwell5
New to the CF scene

 
Join Date: Jun 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
maxwell5 is an unknown quantity at this point
Problem calling function via flashVars

I have a working flash banner with three buttons leading to other web pages.
I would like to have the same banner on more of my web pages.

I am trying to use flashVars to send a variable to the banner letting is know which fucntion to run.
The banner has multiple function blocks each relating to a particular web page.
The web pages will each have a flashVars variable, that will call its related function block.

I have added the banner to one of the web pages however the buttons are
unresponsive when tested.

Please see following code -

Example of flashVars variable on banner web pages

Code:
 <param name=FlashVars value="myFlashVar=testFlashVar" />
Code contained within flash banner

Code:
import flash.events.MouseEvent;
import flash.net.URLLoader;


// set a variable to hold the value of our first flashvar
var myFlashVar:String = "testFlashVar"; 

// set a variable to hold the value of our second flashvar 

var myFlashVar2:String = "secondtest"; 

// set a variable to hold the value of our third flashvar 

var myFlashVar3:String = "anothertest"; 

// set an object to hold all of the parameters (flashvars) passed in from the html 

var paramObj:Object=LoaderInfo(this.root.loaderInfo).parameters; 

function checkForFlashVars():void { 

   // check to see if myFlashVar has a new value passed in from the html; if it does, use this value instead 

   if (paramObj.xmlpath) { 

      myFlashVar = String(paramObj.myFlashVar); 

	  computers_comp();
    }
 
   if (paramObj.myFlashVar2) { 

      myFlashVar2 = String(paramObj.myFlashVar2); 

 	  computers_publicaccess();
 
   }
   
    if (paramObj.myFlashVar3) { 

      myFlashVar3 = String(paramObj.myFlashVar3); 

	  computers_staff();
 
   }
}
 
// call the function
 
checkForFlashVars();


function computers_comp():void{

	var fileName:String = "../../public/computers/computers.php";
	
	var post:URLVariables = new URLVariables();
	logOutBtn.addEventListener(MouseEvent.CLICK, onClick);
	
	function onClick(event:MouseEvent):void
	{
		post.logout = "laksfslvs";
		var ureq:URLRequest = new URLRequest(fileName);
		ureq.data = post;
		ureq.method = URLRequestMethod.POST;
		navigateToURL( ureq, "_self");
	}
	
	homeBtn.addEventListener(MouseEvent.CLICK, onClick2);
	function onClick2(event:MouseEvent):void
	{
	   var request:URLRequest = new URLRequest("../../index.php");
	   navigateToURL(request, "_self");
	}
	
	prevBtn.addEventListener(MouseEvent.CLICK, onClick3);
	function onClick3(event:MouseEvent):void
	{
	   var request:URLRequest = new URLRequest("../../index.php");
	   navigateToURL(request, "_self");
	}

}

function computers_publicaccess():void{

	var fileName:String = "../../public/computers/computers_publicaccess.php";
	
	var post:URLVariables = new URLVariables();
	logOutBtn.addEventListener(MouseEvent.CLICK, onClick);
	
	function onClick(event:MouseEvent):void
	{
		post.logout = "laksfslvs";
		var ureq:URLRequest = new URLRequest(fileName);
		ureq.data = post;
		ureq.method = URLRequestMethod.POST;
		navigateToURL( ureq, "_self");
	}
	
	homeBtn.addEventListener(MouseEvent.CLICK, onClick2);
	function onClick2(event:MouseEvent):void
	{
	   var request:URLRequest = new URLRequest("../../index.php");
	   navigateToURL(request, "_self");
	}
	
	prevBtn.addEventListener(MouseEvent.CLICK, onClick3);
	function onClick3(event:MouseEvent):void
	{
	   var request:URLRequest = new URLRequest("computers.php");
	   navigateToURL(request, "_self");
	}

}

function computers_staff():void{

	var fileName:String = "../../public/computers/computers_staff.php";
	
	var post:URLVariables = new URLVariables();
	logOutBtn.addEventListener(MouseEvent.CLICK, onClick);
	
	function onClick(event:MouseEvent):void
	{
		post.logout = "laksfslvs";
		var ureq:URLRequest = new URLRequest(fileName);
		ureq.data = post;
		ureq.method = URLRequestMethod.POST;
		navigateToURL( ureq, "_self");
	}
	
	homeBtn.addEventListener(MouseEvent.CLICK, onClick2);
	function onClick2(event:MouseEvent):void
	{
	   var request:URLRequest = new URLRequest("../../index.php");
	   navigateToURL(request, "_self");
	}
	
	prevBtn.addEventListener(MouseEvent.CLICK, onClick3);
	function onClick3(event:MouseEvent):void
	{
	   var request:URLRequest = new URLRequest("computers.php");
	   navigateToURL(request, "_self");
	}

}
maxwell5 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 04:36 AM.


Advertisement
Log in to turn off these ads.