CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Flash & ActionScript (http://www.codingforums.com/forumdisplay.php?f=52)
-   -   Problem calling function via flashVars (http://www.codingforums.com/showthread.php?t=266741)

maxwell5 06-30-2012 02:27 PM

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");
        }

}



All times are GMT +1. The time now is 02:16 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.