4 Replies - 542 Views - Last Post: 21 June 2011 - 01:37 PM

#1 Autocrat  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 4
  • View blog
  • Posts: 307
  • Joined: 27-September 09

Use the if Function in AS for PHP variables

Posted 18 June 2011 - 04:03 AM

I want to create a website header (containing the navigation) in Flash. The rest of the website will be in HTML. Now I want to make the button for the page currently being displayed distinct from the others. For example, if the page "About Us" is being shown, the button for About us should be shown highlighted. The header SWF file has to be the same for all pages.

Now for this I need to import the information about the name of the page being displayed and make Flash act accordingly. I can make a separate keyframe for each page. For example, on frame number 1, the button for "Home" will be distinct. How do I tell Flash which page is being displayed and make it show the appropriate frame?

Can I make every page have a PHP variable whose value can be the page name? Then import this variable into AS and use its value to show the appropriate frame? How is this done?

Is This A Good Question/Topic? 0
  • +

Replies To: Use the if Function in AS for PHP variables

#2 chinchang  Icon User is offline

  • Indie Game Developer
  • member icon

Reputation: 192
  • View blog
  • Posts: 725
  • Joined: 22-December 08

Re: Use the if Function in AS for PHP variables

Posted 18 June 2011 - 04:16 AM

2 methods strike me at the moment.

Method 1:

Use flashvars to send variables from your page to flash. Read here.

Method 2:
Keep the flash navigation movie in a separate frame and the html content in another. Now your flash movie doesn't needs to be reloaded again and again, only the html content can be loaded as per the menu selected. Read about frames here.
Was This Post Helpful? 0
  • +
  • -

#3 Autocrat  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 4
  • View blog
  • Posts: 307
  • Joined: 27-September 09

Re: Use the if Function in AS for PHP variables

Posted 18 June 2011 - 07:24 AM

OK I am staying with the FlashVars method. Suppose Frame 1-5 are meant to be for the home button and frames 6-10 are for about us page. This is what I have in my actions layer throughout:

stop();

var keyStr:String;
var valueStr:String;

if ( valueStr == 'home' ) {
	gotoAndPlay(1);
}
if ( valueStr == 'aboutus' ) {
	gotoAndPlay(6);
}


and this is what I am passing into the object from the About us page:

<param name=FlashVars value="pageId=aboutus">


but it still does not seem to work. Upon loading, the frame 1 is displayed (which is meant for the home button).

Can you tell me where am I going wrong?

This post has been edited by Autocrat: 18 June 2011 - 07:26 AM

Was This Post Helpful? 0
  • +
  • -

#4 chinchang  Icon User is offline

  • Indie Game Developer
  • member icon

Reputation: 192
  • View blog
  • Posts: 725
  • Joined: 22-December 08

Re: Use the if Function in AS for PHP variables

Posted 19 June 2011 - 02:09 AM

You declare a variable here :
var valueStr:String;


And then you use it straight away :
if ( valueStr == 'home' ) {
    gotoAndPlay(1);
}



How do you think valueStr will get any value inside it ? You need to first fetch the flashvar into it.

var valueStr:String;
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
valueStr = String(paramObj["pageId"]);
// Now use the variable valueStr

This post has been edited by chinchang: 19 June 2011 - 02:11 AM

Was This Post Helpful? 0
  • +
  • -

#5 kiwi2  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 178
  • Joined: 16-September 08

Re: Use the if Function in AS for PHP variables

Posted 21 June 2011 - 01:37 PM

chinchang that guy is good.
my_lv = new LoadVars();

my_lv.onload = function(success) {
if (success) { 
var ims = my_lv.im;
var un = my_lv.unam; }  else {
Field.text ='Error loading/parsing LoadVars.';
}
};
my_lv.load('http://www.example.com/dd.txt'); }


dont like FLASHVARS myself
txt file

im=session&unam=juom
seems evey one has the same problem today.

This post has been edited by macosxnerd101: 21 June 2011 - 01:38 PM
Reason for edit:: Fixed code tags

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1