Welcome to WebmasterWorld Guest from 54.145.221.99

Forum Moderators: open

Message Too Old, No Replies

CS3 AS2.0 Dynamic Image issue

   
9:16 pm on Jul 21, 2008 (gmt 0)

5+ Year Member



Ok here is where I am at. I have an action script that pulls data from a database by way of PHP. When it comes back to flash, I use parseInt() to be able to read the numbers with Flash.

This all works fine and the number displays fine in flash, however I got to thinking. Instead of displaying the number I would like to display an image. Meaning if x = 1 then display the image otherwise if x = 0 then display nothing.

What I want to know is, is this posiible and if so... How do I do it?

Thanks!

MM

10:44 pm on Jul 21, 2008 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



You need to write conditionals:

if(x == 1) {
// show image
} else {
// do not show image
}

See the docs: [adobe.com...]

11:21 pm on Jul 21, 2008 (gmt 0)

5+ Year Member



Im sorry I probably should have been more clear in my question. 5hrs of sleep in the last three days will do that to ya! ;)

I know to put it in a if else statement, but do I put that in Flash? And if so can I have the image display in a dynamic text box or what do I have to put there to have the image appear in a certain spot on the stage?

MM

6:17 am on Jul 22, 2008 (gmt 0)

5+ Year Member



Would something like this work?

<?php
//--------------------MYSQL DETAILS ---------------------------------------//
//mysql details
require_once("config.php");
//Passing the lookup variable from flash
$user = $_POST['user'];
$stash = $_POST['tStash'];
$SQL = "SELECT * FROM mobster WHERE account_id ='".$user."'";
$rs = mysql_query($SQL,$conn);
//Putting the results in an array
$result = mysql_fetch_array($rs);
//------------------ Assign Variables ---------------------------------//
$chr_name = $result['chr_name'];
$tMail2 = $result['new_mail'];
$tAttack2 = $result['new_attack'];
$tInvite2 = $result['new_invite'];
$tTransfer2 = $result['new_transfer'];
$tFammsg2 = $result['new_fammsg'];
$tBusmsg2 = $result['new_busmsg'];
$tTurns = $result['cturns'];
$tNet = $result['networth'];
$tStashTurns = $result['stashTurns'];
if ($tMail2 == 1){
$tMail = "http://www.mydomain.com/images/dicered.gif";
} else {
$tMail = '';
}
if ($tAttack2 == 1){
$tAttack= "http://www.mydomain.com/images/dicered.gif";
} else {
$tAttack = '';
}
if ($tInvite2 == 1){
$tInvite = "http://www.mydomain.com/images/dicered.gif";
} else {
$tInvite = '';
}
if ($tTransfer2 == 1){
$tTransfer = "http://www.mydomain.com/images/dicered.gif";
} else {
$tTransfer = '';
}
if ($tFammsg2 == 1){
$tFammsg = "http://www.mydomain.com/images/dicered.gif";
} else {
$tFammsg = '';
}
if ($tBusmsg2 = =1){
$tBusmsg = "http://www.mydomain.com/images/dicered.gif";
} else {
$tBusmsg = '';
}
echo "&var1=$tMail&var2=$tAttack&var3=$tInvite&var4=$tTransfer&var5=$tFammsg&var6=$tBusmsg&var7=$tTurns&var8=$tNet&var9=$tStashTurns&varName=$chr_name&";
?>

The if statements are to load the content path of a loader in Flash.

Thanks!

MM

EDIT: Actually I got it working... I changed the == 1 to > 0 and not the images are coming up!

[edited by: Modern_Merlin at 6:24 am (utc) on July 22, 2008]

3:12 pm on Jul 22, 2008 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



Nice :) Glad you got it working.