|
-
Flash, Swish, PHP, MySQL, and HTML
I'm totally lost
see the problem is that i have these flash site (some made in swishmax) but i have the cotent in SQL databases, so i was wondering how do i load sql querry and php/html formated text into say a flash scroll box in Flash MX or Swishmax?
how doi actionscript that?
also is it posible to load a basic image into flash seei have this dynamic php images that i was to load into flash.
any thoughts?
-
first question:
basically all you need is a php script that does the SQL query and echos/prints the field names into variables.
example:
PHP Code:
$connect = mysql_connect("localhost");
mysql_select_db("vinyl_einkauf", $connect);
$query = mysql_query ("SELECT * FROM Einkauf_Allgemein ORDER BY ekdatum DESC");
$rowcount = mysql_num_rows($query);
if ($rowcount > 0)
{
while ($row=mysql_fetch_array($query))
{
echo "&id".$rowcount."=".$row["ID"];
echo "&item".$rowcount."=".$row["item"];
//and so on
}
}
then you use loadVars() and load the php page and get the variables, e.g.
Code:
myData = new LoadVars();
myData.load("mypage.php");
myData.onLoad = function() {
for (i=0; i<this.rowcount; i++) {
id = this["id"+i];
item=this["item"+i];
}
}
of course id and item should be arrays or something since you probably get more than just one row from the table, but you get the idea...
question two:
if i understand you right, you have images and php generates urls to these images? then you go the same as above. read the urls from the respective variables of php and then use loadMovie(url) to load your pics into flash...
-
i think i follow you but im not quite sure let me toss you a url
http://diamondandsphinx.com/MoonInLeoCMS/content.phps
http://diamondandsphinx.com/MoonInLeoCMS/content.php
see what i want to do is take that page's content and put them in a sql DB, but as you cna see the Querry Whiles uses tables (since the set inside scrolling iframes) if i use what you posted which the tables remain intact (assuming each querry area was its own page not one meta page) whoufh the flashscroll area display the content properly formated?
as for the second question yes i basicly want to load into flash this dynamic img
$CataTXT = "Moon in Leo Productions (818)572-3391";
<img src="imgdraw3.php?text='.$CataTXT.'&size=9&Angle=0 &x=365&y=54" border=0>
because i want to beable to just update the $cataTXT variable when i need to change the header contanct number and not update EVERY flash scene when that info changes.
-
1) well, what you can do is: query the db, then put html around it in php (or you even save the html formatting in the db, too. i don't know...). then you pass the html and all as one string to flash. you just have to make sure that your flash dynamic text field is html enabled (in the properties window) and then you set
myTextField.htmlText = myVariableFromPHP;
i never actually tried it this way, mind you. but it should nevertheless work, since textfields in flash can handle html...
2) just a wild guess: it won't work. because with loadMovie() you have to provide the url (which can come from a variable of course) to an actual jpg or swf...but try it and tell me if it worked.
3) cool music...
Last edited by theTick; 08-12-2005 at 01:43 PM.
-
could i load the base ing into flash and pass it the Catatxt variable?
-
hm...i'm not quite sure if i get you right, but you can put your images on the server and then just pass the variable with the url of the respective image to flash.
let's assume in php:
$catatxt="/mypix/myspecialpix/pic.jpg";
then you pass that to flash via loadVars(). let's assume you pass the value of catatxt to the flash variable myURL. Then you can loadMovie(myURL);
is that what you need?
Last edited by theTick; 08-12-2005 at 02:35 PM.
-
well see catatext is the actual text im wring in top of a base immage with the GD libarary
if i lose the base in flash i cosu pass the variable text into flash right?
-
Code:
myData = new LoadVars();
myData.load("mypage.php");
myData.onLoad = function() {
for (i=0; i<this.rowcount; i++) {
id = this["id"+i];
item=this["item"+i];
}
}
do you k now the swishmax version of this?
-
up to my .as in code
Our syntax differences are minor.
onFrame (1) {
myData = new LoadVars();
myData.load("mypage.php");
myData.onLoad = function() {
for (i=0; i<this.rowcount; i++) {
id = this["id"+i];
item=this["item"+i];
}
}
}
onLoad () {
myData = new LoadVars();
myData.load("mypage.php");
myData.onLoad = function() {
for (i=0; i<this.rowcount; i++) {
id = this["id"+i];
item=this["item"+i];
}
}
}
etc etc etc.....
-
hum i used on load didnt seem to work....maybe i shoud upload the swi to look at
-
-
any thoughts on why it doesnt work?
-
up to my .as in code
I see you trying to build the array with php but I'm not a fan of the structure. As far as the SWI, I'm guessing you want to duplicate a sprite containing 2 text fields ("id" and "item") populated with the returned array from the php correct?
With that swi...that's not gonna happen.
If I'm on the right track let me know and I'll build you a SWI that works. If you want it exact, post the table definition (with maybe 2 or 3 entries for data) and I can make it work for you without much editing (the php at least). If not, I will have to use a table from one of my databases for example which will require you to edit the working php when I'm done. Either way works for me.
-
basicly what i want to do is take
http://diamondandsphinx.com/MoonInLeoCMS/content.phps
http://diamondandsphinx.com/MoonInLeoCMS/content.php
and d th e layout in flash and the content (all the sql querries) in well php
you can check out the old flash and latest php version via the base url
http://diamondandsphinx.com/
-
any new thoughts on the issue?
-
up to my .as in code
I used one of my tables for a live example to show you. Granted my data differs but you get the idea. This example pulls the title and id of my news items and displays them with a duplicated sprite. This is to replicate your needing an id and item.
http://sandbox.serveftp.org/llxtest.swf
That source is here:
http://sandbox.serveftp.org/llxtest.swi
For the php...you need an array and total record count:
PHP Code:
<?
include ('SQLcon.php');
$query = "SELECT * FROM NewsByte WHERE ProjectID = '$projectid' AND catagory = '5' ORDER BY 'ScreeningID' DESC";
$result = mysql_query($query);
if (!$result) {
fail("Couldn't list threads from database");
}
$thiscount = mysql_num_rows($result);
$return = "&myCount=$thiscount";
for ($count = 0; $count < $thiscount; $count++)
{
$array = mysql_fetch_array($result);
$id = $array['ScreeningID'];
$item = $array['newsbyte'];
$return .= "&id" . $count . "=" . $id;
$return .= "&item" . $count . "=" . $item;
}
echo $return;
?>
Notice the structure of the container clip (myitems) and the nested clip that actually gets duped (listings) to see how it differed from your original.
Now this is just an example and the containers themselves, what they contain and how you lay it out (dimensions of textfields, items listed...etc) is completely up to you.
The main container itself is normally offstage and the X/Y coordinates are used to place it onstage where you want. If your list is long, you will need to apply a mask over the main container to show only the amount you want and add a scroll control.
Hope that helps.
Last edited by Chris_Seahorn; 09-10-2005 at 09:37 AM.
-
Looks promisiing i have to try it out tonight when i have my source files in front of me. and will reply if i encouter any problems.
-
up to my .as in code
-
-
did a test run and didnt notice any bugs at first then i took a closer look
http://www.diamondandsphinx.com/Moon...st/llxtest.swf
the test page only shows the first line of a entry and only a small number of entries how can i fix that?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|