4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 menu with memory (flash actionscript / php)
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
domuk
WebHelper
WebHelper


Joined: 15 Jan 2004
Posts: 91

PostPosted: Sat Jan 29, 2005 6:27 pm (12 years, 8 months ago) Reply with QuoteBack to Top

Hi all,

I am trying to produce a flash menu that identifies what url you have entered on and highlights the corresponding menu option (in this case _alpha, "50")

The menu is built up using multiple buttons (gallery and home).
Both the home page and the gallery page have the same swf file as their menu.
I would like the menu to recognise what url it is on and alter the colour of the button (to signify to the user that they are on that page).

I am new to actionscript and have managed to display the location in a textbox but not change the colour of the buttons.

The menu swf reloads with each html page.

Hope you can help,

Dominic


FRAME 1 actionscript

Code:
stop();

function change_colour(x)
   {
   if (x = home)
      {
      setProperty("home", _alpha, "50");
                                }

   else if (x = gallery)             
                               {
      setProperty("gallery", _alpha, "50");
      }
   
   }


//=================================
//      
//   FLASH TO PHP
//=================================

gallery.onRelease = function() //gallery button

   {
   lvOut.flash_to_php = "gallery";      
   lvOut.sendAndLoad(path + "menu_location_1.php", lvIn, "POST");
   };


home.onRelease = function() //home button
  {
  lvOut.flash_to_php = "home";
  lvOut.sendAndLoad(path + "menu_location_1.php", lvIn, "POST");
  };


//=================================
//      PHP to FLASH
//=================================

path = "../php/"; // declare path to php files

lvOut = new LoadVars(); //create lvout object
lvIn = new LoadVars();  //create lvin object

lvIn.onLoad = function (success)
    {   
           if(success)
 {
 output_text.text = lvIn.returnVal;
 // there was a text box (for testing) but I have removed it from the stage
 change_colour(lvIn.returnVal);   
 }

 else
 {
  output_text.text = "fail";
  }


}


PHP FILE menu_location_1.php
Code:
<?
$menu_location_php= $_POST['flash_to_php'];
echo "&returnVal=$menu_location_php";
?>
OfflineView User's ProfileFind all posts by domukSend Personal Message
Darren
Team Member



Joined: 05 Feb 2002
Posts: 549
Location: London

PostPosted: Sun Jan 30, 2005 3:17 pm (12 years, 8 months ago) Reply with QuoteBack to Top

A sightly different method than you used would be to tell the flash movie where it is by means of a query string appended to the filename in the 2 html pages, i.e. (not it appears twice, for different browsers)

HTML for Homepage
Code:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="300" height="200">
  <param name="movie" value="my_movie.swf?x=home" />
  <param name="quality" value="high" />
  <embed src="my_movie.swf?x=home" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="300" height="200"></embed>
</object>


HTML for Gallery
Code:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="300" height="200">
  <param name="movie" value="my_movie.swf?x=gallery" />
  <param name="quality" value="high" />
  <embed src="my_movie.swf?x=gallery" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="300" height="200"></embed>
</object>


You should then have access to the x variable from within the flash

ActionScript
Code:
if (x == "home")
{
   home._alpha = 50; † †† †
}
else if (x == "gallery") † †† †† †† †
{
† †gallery._alpha = 50;
}


The is slighlty different to you method too, SetProperty is a little outdated nowadays. But either way...

In your if statement, firstly you had only used a single equals sign so rather than comparing x to the string you were setting the value of x to the string.

And secondly you had not enclosed the string in quotes so it would actually be trying to compare x with a variable called home and gallery

I've assumed that the buttons are on the root level. If they were both embedded in another movie clip then you would write

Code:
menu.gallery._alpha = 50


where 'menu' is the instance name of the container movieclip

I hope that helps,
Darren
OfflineView User's ProfileFind all posts by DarrenSend Personal MessageVisit Poster's Website
domuk
WebHelper
WebHelper


Joined: 15 Jan 2004
Posts: 91

PostPosted: Mon Jan 31, 2005 10:58 am (12 years, 8 months ago) Reply with QuoteBack to Top

Quote:
In your if statement, firstly you had only used a single equals sign so rather than comparing x to the string you were setting the value of x to the string.

And secondly you had not enclosed the string in quotes so it would actually be trying to compare x with a variable called home and gallery



Thankyou, i feel such a fool Embarassed

I shall give that a try,

Dom.
OfflineView User's ProfileFind all posts by domukSend Personal Message
domuk
WebHelper
WebHelper


Joined: 15 Jan 2004
Posts: 91

PostPosted: Tue Feb 01, 2005 6:59 pm (12 years, 8 months ago) Reply with QuoteBack to Top

Thanks Darren,

1) I have got it working by defaulting all the alpha values (of all the buttons in actionscript) to 50 and when on the page (say home.html) the corresponding buttons alpha changes to 100.

I didnít originally want to change the alpha values and just worked with it until I could sort the rest of the code out. I wanted to change the background colour of each button when on that page.I need help again, with changing the button properties; is this possible?

2) I will continue with your method, however I wondered if it would be possible to have a central log (using the server $GLOBALS variables array) that you could send a code to (via actionscript) and it would log this code. Each time the menu loads actionscript checks the $GLOBALS array and changes the flash button colour.

3) So in short what I need is:

a) a method to change the background colour of a button using actionscript.

b) input and output method using flash and actionscript (accessing a single location on the servers variable array)

Thanks in advance,

Hope you understand.

Dom
OfflineView User's ProfileFind all posts by domukSend Personal Message
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.062536 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme