PHP variable passing to FlashMX to specify getURL directory?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
phpFriend
Forum Newbie
Posts: 1
Joined: Wed Aug 06, 2003 12:37 am

PHP variable passing to FlashMX to specify getURL directory?

Post by phpFriend »

Howdy, all! For my first post . . . a PHP/Flash question. :D

Quick, quick background before jumping in . . . I've been receiving PHP tutoring since January, allowing me to implement a number of time-saving PHP-based systems for my company's websites.

A big, fat redesign is coming for our main site soon, and I've been building it with much more PHP than the last design (100% HTML).

The pages now call an include file to display the interface, and the code goes below it.

To solve the problem of the include file being called from both the root and subdirectories, I've included this variable -- $info_array[dir_level] -- to specify if there needs to be a ../ or not.

Due to an over-abundance of content, we're using a Flash navigation bar as part of the interface, also in the include.

Problem is, I can't seem to pass $info_array[dir_level] through to the Flash file so it can call the pages properly from subdirectories.

In my PHP file, prior to calling the include, I have this line:
  • $info_array[dir_level] = "../";
(which, of course, I have as a variable so I can make it "" if the include is called from a page in the root)

This is the Action in my Flash file:
  • on (release) {
    getURL("$info_array[dir_level]?q=contests", "_top");
    }
I'd like that to mean that, when called from, say:
. . . that the resulting URL would be:
Unfortunately, it ends up being:
Any ideas how to make the variable work properly in Flash MX?

I've tried six ways to sundown with various adjustments in Flash, including sending the variables with GET and POST, I've tried it without the info_array[], and I've done countless searches to find a solution and make this work.

Thanks ever so kindly in advance, and my apologies in advance if I've over-written. I look forward to any thoughts that can be offered, and, now that I'm here, offering anything my six months of PHP-ness can help with.
User avatar
PhilHawks
Forum Newbie
Posts: 2
Joined: Sat Dec 06, 2003 7:58 pm

PHP variable passing to FlashMX to specify getURL directory?

Post by PhilHawks »

Hi all..!

I just thought i'd say that I am having EXACTLY the same problem. :cry:

I cant get PHP to pick up the URLs sent from my flashMX navigation menu. I have the menu parsing an XML file for the structure and actions (URL calling).

In flash I use a
getURL(butAction, "_self")
(where butAction is specified in my XML file. eg ../forum)

phpFriend, I would be really interested in a bit more detail on how you have your VARs set up for working out if you need a ../ or not. I'm a real newbie at all this PHP and couldn't work it out.
Chambrln
Forum Commoner
Posts: 43
Joined: Tue Dec 02, 2003 10:45 am
Location: Oregon

Post by Chambrln »

$info_array[dir_level] is not a flash variable I'm assuming. Before you can pass the $info_array[dir_level] you need to know what it is. Just putting that in the URL is not going to tell PHP what to do. $info_array[dir_level] is a variable and needs to be set. I know there is a function in Flash that allows you to execute a script and then use the returned variables in flash. You would need to write some sort of script that would return your dir_level to flash. Flash would then write the correct path to your getURL function.

The variables need to be returned to Flash in the following manner:
variable1=sometext&variable2=sometext&variable3=sometext

I'm pretty sure you don't need the dollar signs in from of the variable names when passing it back to flash, but I could be wrong.
User avatar
PhilHawks
Forum Newbie
Posts: 2
Joined: Sat Dec 06, 2003 7:58 pm

Post by PhilHawks »

I think the action you might be looking for to get the VAR values to flash is loadVariables. You can find the syntax in the help files in Flash. :idea:

So... because i'm sending the VAR butAction to PHP. I have to tell PHP what it is before it will use it. :?

I meen by the time I send the butAction to PHP it SHOULD be a URL. SHould I then be telling PHP what to do with that URL? or does PHP understand a getURL just like HTML does.?

I had all this menu working under HTML. But since I changed to calling the menu from PHP the browser doesnt seem to be recieving the URL calls I send it.

Thanks for all your help eveyone!

Phil
User avatar
igoy
Forum Contributor
Posts: 203
Joined: Fri May 02, 2003 11:57 pm
Location: India
Contact:

Post by igoy »

using LoadVar action you can run a function in PHP i use an output returned by PHP as variable...

in your PHP you can define function

Code: Select all

<?php

if (isset($HTTP_POST_VARS['action']))
{
	switch($HTTP_POST_VARS['action'])
	{
		case "getUrlName":
			$result = getUrlName($_POST['link']);
			print $result;
			break;
	}
}


function getUrlName($link) {

	// process you scrript which will output URL name;
	return "&urlValue=".$URLname;
}
?>
and in Flash your actions will be something like this...
(this will button "on (release)" action)

Code: Select all

on(release) { 
	obj = new LoadVars(); 
	obj.action = "getUrlName"; 
	obj.link = "1"; 
	obj.sendAndLoad("program.php", obj, "POST"); 
	obj.onLoad = function() { 
		urlValue = obj.urlValue; 
		getURL(urlValue+"?q=contests", "_top"); 
	};                
}
flash can read the variable urlValue then, and use it as link.


I am sorry for not going step-by-step details in it but you should be able to understand this, it's fairly simple...
also you can make few changes in Flash AS, and PHP to create an array in Flash so that you can user loadVars just once (instead of initializing it on each button)

and sorry about any spelling mistakes... please adjust, I seem to mess up letters here n there in the process of thoughts
Post Reply