PDA

View Full Version : [php] Using getURL to load a webpage based on it's "PageName"


333944
05-31-2005, 02:51 PM
Hey Y'all,
My issue has to do with a communication error between my Flash movie, and a PHP script that's being called by it.
The Rundown: Shopping cart login, that has to work regardless of which page the user is viewing/logging in from.... currently it only works when you hard code the page name into the call i.e.

cmdLoginReal.onRelease = function(){
getURL ("index.php", "_self", "POST");
}

The php file has a variable called "PageName", which coincidentally enough changes each time the user visits a new page. I am passing this variable back to the flash movie through the object tag on the php page every time the swf loads, and now would like to incorporate it into the code above???? I've tried this...

cmdLoginReal.onRelease = function(){
getURL (PageName, "_self", "POST");
}

But it comes back as undefined???? Can someone please help? I guess I could test what page the user is on with some if statements, but I'd like to avoid the hard code if at all possible...
Keep on contact, Romeo
Thank-You

mmm..pi..3.14..
05-31-2005, 05:17 PM
You talking about FlashVars? Is that how your setting the pagename in flash? If so, grab it in the first frame of the main timeline and make it global, like this:

_global.PageName = this.PageName

Eric :)

333944
05-31-2005, 08:34 PM
Hey Eric,
The PageName is being initialized on the php side of things...
(it's in the object tag)
<embedsrc="brand_search.swf?osCid=&UserFirstName=&NumCartItems=0+
items+in+cart&CartTotalCost=%240.00+in+total+sales&PageName=index.php&cPath="....

As you can see that was taken from the object tag of "index.php" because teh PageName says so... but that name changes depending on the page that you're on...

I want to capture that variable and use it as the URL in the getUrl call????
Is this possible?
Keep on contact, Romeo

mmm..pi..3.14..
05-31-2005, 08:39 PM
That's right, once you have that, you just load the variables by their name, like I posted before.

_global.PageName = this.PageName

333944
05-31-2005, 09:09 PM
Eric,
You're the man.... it made sense after I posted the last reply, and now works just fine :)
Thanks-so much for your prompt response...
Keep on contact, Romeo

333944
06-02-2005, 07:39 PM
Hey Eric,
I have a question with regards to the same file...
Every time the page refreshes a variable called "IsLogged" is passed to my Flash movie 1 = logged in, 0 = not logged in.

There are two scenes in my movie one scene has a log in button that call's a tellTarget displaying your input boxes allowing you to submit, and the other is a logged in screen that has a logout button and a hello: username message... this logout screen should only display if you have just logged in (refreshing the page and testing to see if logged in = 1)

I have this code on scene1 of my movie (the please login scene)

if (_root.logScript.text != "0"){
gotoAndPlay("scene2", "one");
}else{
gotoAndPlay("scene1", "two");
}

logScript is the instance name I've given the "IsLogged" variable....

The problem is the file doesn't always work sometimes it loads up fine, sometimes only half my movie loads up??? Like just some graphics but all my buttons are missing??? It’s very bizarre.... also when it does work it takes a very long time to load...

I mean it logs you in ok, but just has a problem displaying the movie... it almost seems like it gets stuck somewhere????

These problems only started happening when I added the second scene (logout)

Can you please shed some light on the subject... if you care to take a look at the URL it's in its staging environments and can be found here...
http://www.golfdimples.com/catalog/
user: rcrugnale@dconx.com
pass: password

If you can shed some light on this issue it'd be greatly appreciated....
Thanks-a-million
Romeo

mmm..pi..3.14..
06-02-2005, 09:37 PM
sounds like a cache issue. Try adding a random number onto a variable at the end of your swf when you embed it, like this:

<embedsrc="brand_search.swf?UniqueID=" . rand() . "blablablablabla....>"

That should prevent the browser from loading the same swf twice and therefore force the swf to refresh all the variables. That should make it check the new logged in variable.

Eric :)

333944
06-03-2005, 04:10 PM
Hey Eric,
A million-thanks for your ongoing help... after adding the variable "NoCache" $NoCache=md5(date('mdYHis')); ... generating a random value based on the date, the swf seemed to be ok... then it started acting up after trying it on another machine...
What's happening now is that the log in screen comes up every time, but when you log in three of the variables are not being shown;
UserFirstName, NumCartItems, CartTotalCost... until you again refresh the page, and only sometimes will it display all or any... why wouldn't those variables be displaying??? If you look at the bottom of the page Ernie (the same php guy that added the random generator has added some listeners, showing that a value is provided for those variables it's just that flash is not displaying them????)
Man this stuff is really stressful; thank-god communities like actionscript.org have been set-up...
Ps. I'm a designer by trade and therefore am not as proficient in coding as someone like yourself...

Thanks-again Romeo

mmm..pi..3.14..
06-03-2005, 05:26 PM
try not passing the FlashVars through the embed tag, but instead through the object tag and see if that makes a difference.

Find the section that looks like this:


<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="191" height="151" id="brand_search" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="brand_search.swf?osCid=652eccbf2645442dccf5cb58964 429a7&UserFirstName=Romeo&NumCartItems=0+items+in+cart&CartTotalCost=%240.00+in+total+sales&PageName=index.php?action=process&cPath=23&IsLogged=1&NoCache=11da0b97098946735262c656d0e7b4d6" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
<param name="bgcolor" value="#ffffff" />


Modify it to look like this:


<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="191" height="151" id="brand_search" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="brand_search.swf?osCid=652eccbf2645442dccf5cb58964 429a7&PageName=index.php?action=process&cPath=23&IsLogged=1&NoCache=11da0b97098946735262c656d0e7b4d6" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
<param name="bgcolor" value="#ffffff" />
<param name="UserFirstName" value="Romeo" />
<param name="NumCartItems" value="0+items+in+cart" />
<param name="NumCartItems" value="0+items+in+cart" />
<param name="CartTotalCost" value="%240.00+in+total+sales" />


You can add as many as you want.

Eric :)