A Flash Developer Resource Site

Results 1 to 17 of 17

Thread: Questions with dynamic buttons in Flash & PHP/mySQL

  1. #1
    Member
    Join Date
    Oct 2004
    Posts
    70

    Questions with dynamic buttons in Flash & PHP/mySQL

    Hello everybody,
    I plan to evaluate Koolmoves and purchase if it satisfy my needs, but first I would like to know if this program would be able to do the following:

    I have a php script that generates a menu from a "categories" table of mySQL database. The script repeat the following instruction until there is no more categories to display for the menu and uses a css class (style sheet) for simple rollovers:

    <tr>
    <td width="187" bgcolor="transparent"><a href="<?=$fldcategory_name_URLLink?>?categy_no=<?= $fldcategory_name_categoy_no?>&" class="menu"><?=$fldcategory_name?></a>
    </td>
    </tr>

    I am not familiar with Flash. I got some nice flash buttons on the web (.fla and .swf) and I would like to create the site menu but with one of these flash buttons. I mean it would be a dynamic menu created with php using flash buttons with the corresponding data from a mySQL table for each button of the menu. It would be same button object on the above row, that my php script will repeat in each table row until there is no more categories, now my questions:

    1.- How can I use one single flash button that is able to have inside itself a function, script or whatever that use this PHP variable

    <?=$fldcategory_name?>

    for the TEXT of the button, and this other

    <?=$fldcategory_name_URLLink?>?category_no=<?=$fld category_name_category_no?>

    for the URL of the button?.

    2.- Will Koolmoves allow me to to enter these variables or a function with these variables inside the flash button code (in .swf format or .fla), and generate the flash button without the need of the Macromedia Flash program?.

    3.- From your point of view, is there any other thing to consider to be able to do this with Koolmoves?

    4.- If it is not possible with Koolmoves, does somebody knows a step by step example to do it with Flash?, please remember that I have never used Flash, totally new

    Thanks a lot
    joejac

  2. #2
    undead creature necromanthus's Avatar
    Join Date
    Feb 2002
    Location
    ROM
    Posts
    1,890
    Flash doesn't work with PHP variables.
    If you need to send/receive variables to/from PHP files,two things are needed:
    1) inside of the SWF file you have to declare and to send a message to the PHP file:
    myvar = "JoeJac";
    this.loadVariables("pagename.php?var1="+myvar, "POST");

    (you may use a button for this action).

    2) inside of the PHP file you have to declare and to "wait" for that variable:
    <?php
    $var1 = $_REQUEST["var1"];
    ...


    that's all.

  3. #3
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Actually you can do that.

    Assuming the flash swf has the a button with a text box. If you push the variable like this

    myflash.swf?button_text=HOME it will work.

    My brother and I were at one time offering buttons done like this and you can still play around with them at http://swsinternet.com/Button_chooser.php

    NOTE THIS PORTION OF THE SITE IS NO LONGER ACTIVE!
    Last edited by blanius; 10-27-2004 at 11:50 PM.

  4. #4
    undead creature necromanthus's Avatar
    Join Date
    Feb 2002
    Location
    ROM
    Posts
    1,890
    Originally posted by blanius
    Actually you can do that.
    You can do WHAT ?

    You have to send a message to the PHP file.
    myflash.swf?button_text=HOME it doesn't do anything !

  5. #5
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Sure it does! but not to send to the php, but as I believe what joejac is asking to do you can send variables toflash without PHP or even with it and have just one flash button on your server and using the PHP to add the proper info into the HTML of the page have a bunch of buttons with different text and url. Did you look at that page. We made buttons in both Flash MX and 3d Flash animator that simply had text boxes for the text and a variable assigned to the text box then you can push the variable via the HTML as shown.

    Here's another one I just did in KM
    http://bretlanius.com/tmp/btest.html

    by the way it says something different in Netscape and IE (just to show that you can do that as well)

    the text in the edit box is being set at runtime from the HTML tag.

  6. #6
    undead creature necromanthus's Avatar
    Join Date
    Feb 2002
    Location
    ROM
    Posts
    1,890
    Originally posted by blanius
    Sure it does!
    No,it doesn't !
    Bret, you're talking about something else.
    First of all, the name of this topic is "Questions with dynamic buttons in Flash & PHP/mySQL ".
    Now about "your" myflash.swf?button_text=HOME ...
    This is another method (I don't like it, btw) to DECLARE a flash variable inside of the "SWF holder" (the HTML page) and nothing more !
    Has nothing to do with a real exchange of messages (SWF with PHP,CGI,ASP,etc).
    HTML is a static page.You may extend its capabilities using JavaScript,but you can't get too much.
    For PHP/MySQL you need more than that ...
    cheers

  7. #7
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    "Questions with dynamic buttons in Flash & PHP/mySQL " is exactlly what I've described
    HTML is a static page
    PHP creates dynamic HTML

    That being said what I thought he was asking to do was exactly what I was demonstrating. Here's what I mean in detail.

    You make a flash button with dynamic text and in the action for the button you use a variable as the URL for the page to load (assuming that is what you want the buttons to do)

    You can then use this one button and via PHP pull the text and urls from a database and put them into the html tags in a loop and have a menu of buttons each with different text and action.

    PHP Code:
    myflash.swf?button_text=<?php echo $name;?>&url=<?php echo $url;?>
    This is a good way if you want an dynamic HTML page (really a php page) with just flash buttons.

    I agree If the goal is a Flash menu certainly the better way would be to have PHP send a list of variables to a flash menu and duplicate the buttons there within flash.

    I hope Joejac is not put off by this discussion and I was only trying to answer what I believe to be his question and to demonstrate a useful technique that in many ways is much easier to build than the whole dynamic menu thing and passing what amounts to an array of data since Flash doesn't seem (as far as I'm aware) able to retrieve an array via loadVariables. So to build a dynamic menu you first have the PHP code take the Recordset from MySql convert it into a long string or several strings using some sort of delimiting character then in the flash you have to reconstruct the arrays in some manner and create the buttons, which I've done before and it is somewhat complex.

    Joejac please let us know if any of this is helping and if not leads us to a better understanding of what you want to do with KM and I'm sure that we can help you achive it, Necromantis is a genius when i comes to KM and actionscripting and I have no doubt that you can do what you want with KM and PHP/MySql.

  8. #8
    undead creature necromanthus's Avatar
    Join Date
    Feb 2002
    Location
    ROM
    Posts
    1,890
    I can't give up ... LOL:
    1) to be more precise: PHP dynamically creates the static HTML pages
    2) The
    Code:
    myflash.swf?button_text=<?php echo $name;?>&url=<?php echo $url;?>
    is working for "SWF holders" only.
    If you need an exchange between a SWF file and a dynamic page ...
    3) sending the variables in a separate HTTP header is the best method
    4) Bret is a smart guy
    5) I'm going home now ...

  9. #9
    Member
    Join Date
    Oct 2004
    Posts
    70
    Thank you both necromanthus and blanius for your interesting brainstorm and your desire to help me, I appreciate this a lot.

    First the categories of my menu are stored in a mySQL table and they can change at any time, so the menu and the buttons. Now I use style sheets, very easy and do not overload the page. But my friend wants fancy flash buttons in the site and the challenge is interesting.

    I get the categories of mySQL in an array with PHP.

    From the array I can have:
    $row[1] for the Text of the button and $row[0] for the URL, in fact this is not enough I have to create the string for the URL: index.php?category_no.$row[0]. you know taking care of sintaxis.

    In brief: I need a button capable to receive
    $text and $URL for each instance of the button and with a "while" instruction I will pass these 2 variables to the button.

    Other alternative is that php pass a complete string with all texts and url in a line, properly formated, and the flash button takes care of creating the menu.

    Either way is fine for me, if I can pass Texts and URLs and the buttons are generated automatically.

    My menu is vertical so I can have any amount of categories/buttons.

    I do not know if I was able to explain myself, if there is some question please post them.

    Other question, Does Koolmoves is able to edit flash buttons in .SWF were I can tell the button what parameters to use in an easy way?, since I do not know anything of Flash and I do not have the Flash
    program. I would prefer to purchase a less expensive program if it solves this issue and it is easier to use.

    Thanks in advance for all your support
    joejac

  10. #10
    Member
    Join Date
    Oct 2004
    Posts
    70
    I like Mr. Lanius idea:

    myflash.swf?button_text=<?php echo $name;?>&url=<?php echo $url;?>
    I can do a "while" with PHP and echo the rows of the html table one by one with the HTML code for the flash button object as well as $name and $url variables all embedded inside the cell <td> tag, it is easy.

    With your permission Mr. Lanius, I downloaded 4 of your very nice buttons in order to make a test tonight. Since I respect the intellectual property of others I would appreciate a lot If you can provide me with links to tutorials. I would like to learn how to make customized flash buttons for this task.

    If Koolmoves allow me to create those nice buttons and prepare them to receive the name and url parameters it would be great, please give the link to the tutorial, I would like to learn that. I prefer to
    use simple and easy tools like I think Koolmoves is, than a complex and expensive one.

    Again I'm very grateful for the support of both Mr. Lanius and Mr. Necromanthus

    Best regards
    joejac

  11. #11
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    You cannot edit the SWF files.

    KoolMoves will make a swf but not edit ones made from other programs.

    You can do it either way you describe. And it's only a matter of preference and what you feel comfortable doing. They way I described above will work pretty easily but does make for a bit of a messy page source. There are advantages to the other way as well. Either way KM will work for you just fine.

  12. #12
    Member
    Join Date
    Oct 2004
    Posts
    70
    Hello Lanius, thanks a lot it worked!

    For the test I used your button buttonb4.swf, one last question:

    Is there a way to change Font, size and color of "label" as well as width and height of this button or it has to be created again in Koolmoves or Flash with the new requirement. I tried to change width and height at the object level but it did not work.

    Thanks
    regards
    joejac

  13. #13
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Yeah what you really need to do is create a new button in KM.

    if you have a button you like lets have a look maybe we can make one like it.

  14. #14
    Member
    Join Date
    Oct 2004
    Posts
    70
    Hello Mr. Lanius
    I got the evaluation version of Koolmoves and I was able to make a simple flash button from the library, to test Koolmoves, but I was unable to resize it. Now I think Koolmoves in Advanced mode is complex, for a novice.

    I was trying to figure out how to code the action script to have the "label" and "url" variables for the button but I was not succeed, I have no experience with Action Script. Would you wish to provide me with the action script code to do this, with an explanation of how to insert the action script with Koolmoves in the following button:

    http://www.businessbig.com/test/TestK.swf

    Thanks a lot for your help.
    joejac

  15. #15
    Member
    Join Date
    Oct 2004
    Posts
    70
    Hello any news on my last question?
    Your help is appreciated
    Thanks
    joejac

  16. #16
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    I don't know if you can do it with the clipart buttons.

  17. #17
    Member
    Join Date
    Oct 2004
    Posts
    70
    Ok, if I do a button all by myself, from the begining, not from library. How can I enter the "label" and "url" variables for the button. Would you wish to provide me with the action script code to do this, with an explanation of how to insert the action script using Koolmoves menues. Or you can provide a simple button.fun source with "label" and "url" variables and I will try to figure out the way studying the Koolmoves source of such button. In solving this issue I think I will have no more questions on this topic.

    Thanks and regards
    joejac

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center