By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
463,122 Members | 648 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 463,122 IT Pros & Developers. It's quick & easy.

swfobject

anfetienne
100+
P: 424
is it possible to add php array to vars in the swfobject code?
Jul 18 '09 #1
Share this Question
Share on Google+
49 Replies

Markus
Expert 5K+
P: 6,050
Have a look at encoding your array with json_encode and then, using action script decode it.
Jul 18 '09 #2

anfetienne
100+
P: 424
ok thanks marcus, ill go through that once ive set my computer back up properlly
Jul 18 '09 #3

Markus
Expert 5K+
P: 6,050
@anfetienne
OK - let me know how you get on. Bear in mind that the link I gave you is for AS2, I think.

Mark.
Jul 19 '09 #4

anfetienne
100+
P: 424
as the example shows for json_encode does it have to be on echo or can i assign it to a var then pass it to flash using swfobject?
Jul 20 '09 #5

Markus
Expert 5K+
P: 6,050
No - just encode and pass it as a flash var.
Jul 20 '09 #6

anfetienne
100+
P: 424
so ok does this look right to you as this is what i have......bear in mind all data is coming from a db

Expand|Select|Wrap|Line Numbers
  1. $user="theau10_tawUser";
  2. $pass="auction10";
  3. $data="theau10_resources";
  4.  
  5. $connection=mysql_connect("localhost" ,"$user", "$pass") or die("Unable to connect!");
  6.  
  7. @mysql_select_db($data) or die( "Unable to select database");
  8.  
  9. // Select column 1 from table name where column name = $your_var.
  10. $sql = "SELECT * FROM savedTemps WHERE tempID = '{$random_digit}'";
  11. // If mysql_query returns false, we'll die with the error.
  12. $res = mysql_query( $sql ) or die( mysql_error );
  13.  
  14. // If a there is a match
  15. if ( mysql_num_rows( $res ) > 0 )
  16. {
  17. $row = mysql_fetch_array( $res );
  18.  
  19. }
  20.  
  21. $myVar = json_encode($row);
  22.  
Jul 20 '09 #7

anfetienne
100+
P: 424
and then after that i can pass $row into flash with swf object i decode it by doing

#include "json.as"

trace( myVar );

varData = JSON.decode(myVar)

???
Jul 20 '09 #8

Markus
Expert 5K+
P: 6,050
Sounds about right - yes. Try it out and see.
Jul 20 '09 #9

P: 6
JSON.as: Line 37: Classes may only be defined in external ActionScript 2.0 class scripts.
class JSON {


what is this? how can i fix it?
i use flash 8
Jul 21 '09 #10

Markus
Expert 5K+
P: 6,050
You should be using import class.as (I think).
Jul 21 '09 #11

anfetienne
100+
P: 424
hi markus im back with some results.

the json prints out only 1 set of array....i have more than 1 row in my db that has the same tempID but different values for each image and the sql is just collecting the 1st set of values.

i called it like below:

Expand|Select|Wrap|Line Numbers
  1. $blank = "";
  2.  
  3. // Select column 1 from table name where column name = $your_var.
  4. $locSQL = "SELECT imageLoc FROM flashGallery WHERE tempID = '{$random_digit}'";
  5. // If mysql_query returns false, we'll die with the error.
  6. $locRES = mysql_query( $locSQL ) or die( mysql_error );
  7.  
  8. // If a there is a match
  9. if ( mysql_num_rows( $locRES ) > 0 )
  10. {
  11. $locAry = mysql_fetch_array( $locRES );
  12.  
  13. }
  14. else{
  15. echo $blank;
  16. }
  17.  
  18.  
  19. $locVar = json_encode($locAry);
  20.  
  21. // Select column 1 from table name where column name = $your_var.
  22. $tmbSQL = "SELECT thumbLoc FROM flashGallery WHERE tempID = '{$random_digit}'";
  23. // If mysql_query returns false, we'll die with the error.
  24. $tmbRES = mysql_query( $tmbSQL ) or die( mysql_error );
  25.  
  26. // If a there is a match
  27. if ( mysql_num_rows( $tmbRES ) > 0 )
  28. {
  29. $tmbAry = mysql_fetch_array( $tmbRES );
  30.  
  31. }
  32. else{
  33. echo $blank;
  34. }
  35.  
  36. $tmbVar = json_encode($tmbAry);
  37.  
  38. // Select column 1 from table name where column name = $your_var.
  39. $capSQL = "SELECT imageLoc FROM flashGallery WHERE tempID = '{$random_digit}'";
  40. // If mysql_query returns false, we'll die with the error.
  41. $capRES = mysql_query( $capSQL ) or die( mysql_error );
  42.  
  43. // If a there is a match
  44. if ( mysql_num_rows( $capRES ) > 0 )
  45. {
  46. $capAry = mysql_fetch_array( $capRES );
  47.  
  48. }
  49. else{
  50. echo $blank;
  51. }
  52.  
  53. $capVar = json_encode($capAry);
  54.  
  55. mysql_close();
  56.  
  57. $flashVar1 =  'so.addParam("locVar", "'.$locVar .'");';
  58. $flashVar2 =  'so.addParam("tmbVar", "'.$tmbVar .'");';
  59. $flashVar3 =  'so.addParam("capVar", "'.$capVar .'");';
  60.  
sql is only returning the 1st row?
Jul 22 '09 #12

anfetienne
100+
P: 424
i've decided to json_encode the necessary details before saving it to a db. im having trouble retrieving all data needed into an array as everything i have tried either shows the 1st or last row that is retrieved instead of all rows
Jul 22 '09 #13

anfetienne
100+
P: 424
ive fixed it here is the solution

Expand|Select|Wrap|Line Numbers
  1. // Select column 1 from table name where column name = $your_var.
  2. $locSQL = "SELECT imageLoc, thumbLoc, imageCap FROM flashGallery WHERE tempID = '{$random_digit}'";
  3. // If mysql_query returns false, we'll die with the error.
  4. $locRES = mysql_query( $locSQL ) or die( mysql_error );
  5.  
  6. // If a there is a match
  7. if ( mysql_num_rows( $locRES ) > 0 )
  8. {
  9.  
  10.     while($row = mysql_fetch_array($locRES,MYSQL_ASSOC)){
  11.  
  12.     $aryA[]=$row['imageLoc'];
  13.     $aryB[]=$row['thumbLoc'];
  14.     $aryC[]=$row['imageCap'];
  15.  
  16.     } 
  17. }
  18.     $locAry = implode($aryA);
  19.     $tmbAry = implode($aryB);
  20.     $capAry = implode($aryC);
  21.  
  22. $flash02="so.addVariable('locVar', '$locAry'); so.addVariable('tmbVar', '$tmbAry'); so.addVariable('capVar', '$capAry');";
  23.  
  24. mysql_close();
  25. ?>
  26.  
Jul 22 '09 #14

P: 6
what's the action script code?
i don't know how to decompile the json code into flash :|
Jul 22 '09 #15

anfetienne
100+
P: 424
this is all i have for actionscript so far im testing it right now

#include "json.as"

trace( myVar );

varData = JSON.decode(myVar)
Jul 22 '09 #16

Markus
Expert 5K+
P: 6,050
And is it working for you?
Jul 22 '09 #17

P: 6
for me isn't working
and i tried import "json.as"
could you send to me test files ? (just arhive and upload somewhere and send me the link on pm)
Jul 22 '09 #18

anfetienne
100+
P: 424
so far i cant even get the encoded var into flash using swf object because it creates extra double quotes and php isnt reading it too well.....

yeah ill sort that out and send you a link now
Jul 22 '09 #19

anfetienne
100+
P: 424
if you use ftp you can access the testFile.zip using the following.

hostname: ve-creative.com
user: anonymous@ve-creative.com
password: guest

im very close to getting swfobject to accept the encoded json as ive got it to take in half of the 1st value......getting close though
Jul 22 '09 #20

anfetienne
100+
P: 424
in the templateEdit file if you look for the same code as i just posted as my solution its the following that I am encoding. it starts at line 281

# $locAry = implode($aryA);
# $tmbAry = implode($aryB);
# $capAry = implode($aryC);
Jul 22 '09 #21

anfetienne
100+
P: 424
i think ive just had an epiphany.....would escape_string do the trick with getting the data in a var sent through because of the special characters?
Jul 22 '09 #22

anfetienne
100+
P: 424
ok so i used mysql_escape_string and json_encode my needed data into a mysql and called it back to be saved with the whole template data in a different table. i've add the escaped data to my code to be sent into flash and it's worked all the vars are being displayed properlly is the db and on the page that gets created from the db.....now to test the flash side....ill be posting soon
Jul 22 '09 #23

anfetienne
100+
P: 424
i got very close with this method up to the point of getting all codes in a sql readay to be read into vars to go into flash using swfobject.

but the problem then starts with the double quotes that is produced with json_encode.
Jul 23 '09 #24

Markus
Expert 5K+
P: 6,050
@anfetienne
Escape them with backslashes?
Jul 23 '09 #25

anfetienne
100+
P: 424
anyone got any clue on how to use htmlenitities() or htmlspecialchars() because ive tried to use these to encode the string but cant get it to work?
Jul 23 '09 #26

anfetienne
100+
P: 424
@Markus
i simply used mysql_real_escape_string and it escaped it all with backslashes but in flash it wouldn't decode
Jul 23 '09 #27

anfetienne
100+
P: 424
i have decided to output all json_encoded data into a flash array format into a text file then #include "tempID.txt"; to get it into flash that way.

ill will store all info in a db so that way they can be updated then it will output to text whenever there are changed.

also i have just started to get this error in flash when it comes to JSON.decode


json.as, line 39
classes may only be defined in external ActionScript 2.0 class scripts
source: class JSON {
Jul 23 '09 #28

P: 6
that's the error that i get too
there is another way then json ,to insert an array into flash with swfobject? (without auxiliary files)
Jul 23 '09 #29

anfetienne
100+
P: 424
the only way i found was to encode special characters. but im working on inserting a flash array into a text file so it can be load straight into flash that is the only way i can think of doing something from a database that doesn't have to be relative to a html file when there isn't a html file
Jul 23 '09 #30

anfetienne
100+
P: 424
you could cut out json_encode altogether and just use htmlspecialchars() with actionscript to as they use the same language to encode so it will be alot easier to decode within flash.

swf doesnt have a problem with any special characters apart from extra double and single quotes except where additional variable values should be.....i hate the fact that you can't pass anything to flash using swfobject that may have any quotes in its value
Jul 23 '09 #31

anfetienne
100+
P: 424
ok i've made this code to output flash vars to a text file.....i just need one thing to finish it off...... i just need to get the values in double quotes so i can test


CODING

Expand|Select|Wrap|Line Numbers
  1. $capSQL = "SELECT * FROM flashGallery WHERE tempID = '{$random_digit}'";
  2. $capRES = mysql_query( $capSQL ) or die( mysql_error );
  3.  
  4. if ( mysql_num_rows( $capRES ) > 0 )
  5. {
  6.  
  7. $query = "SELECT * FROM flashGallery WHERE tempID = '{$random_digit}'";
  8. $returnedData = selectMultiRows($query);
  9. $totalRecords =  count($returnedData);
  10.  
  11. $file = "upload/$random_digit/$random_digit.txt";
  12. $capHandle = fopen($file, 'w') or die("can't open file");
  13.  
  14.     $stringData = "var imgVar = new Array();\n";
  15.     fwrite($capHandle, $stringData);
  16.  
  17.     $iv= 0;
  18.  
  19.             for($i=0;$i<$totalRecords;$i++)
  20.             {
  21.                    echo $returnedData[$i]["imageLoc"] . "<br>";
  22.                 $stringData = "imgVar[".$iv++ ."] = ".$returnedData[$i]["imageLoc"] .", \n";
  23.                 fwrite($capHandle, $stringData);
  24.             } 
  25.  
  26. }
  27.  
  28. fclose($capHandle);
  29. mysql_close();
  30.  
RESULT

Expand|Select|Wrap|Line Numbers
  1. var imgVar = new Array();
  2. imgVar[0] = http://theauctionwinners.com/resources/upload/64516994/images/1.jpg, 
  3. imgVar[1] = http://theauctionwinners.com/resources/upload/64516994/images/2.jpg, 
  4. imgVar[2] = http://theauctionwinners.com/resources/upload/64516994/images/3.jpg, 
  5. imgVar[3] = http://theauctionwinners.com/resources/upload/64516994/images/4.jpg, 
  6.  
Jul 23 '09 #32

anfetienne
100+
P: 424
ooookkkkkkkkkkkkk new code......all that is needed is to import in flash and test the array

CODE

Expand|Select|Wrap|Line Numbers
  1. $capSQL = "SELECT * FROM flashGallery WHERE tempID = '{$random_digit}'";
  2. $capRES = mysql_query( $capSQL ) or die( mysql_error );
  3.  
  4. if ( mysql_num_rows( $capRES ) > 0 )
  5. {
  6.  
  7. $query = "SELECT * FROM flashGallery WHERE tempID = '{$random_digit}'";
  8. $returnedData = selectMultiRows($query);
  9. $totalRecords =  count($returnedData);
  10.  
  11. $file = "upload/$random_digit/$random_digit.txt";
  12. $capHandle = fopen($file, 'w') or die("can't open file");
  13.  
  14.     $stringData = "var imgVar = new Array();\n";
  15.     fwrite($capHandle, $stringData);
  16.  
  17.     $iv= 0;
  18.     $dQ = '"';
  19.  
  20.             for($i=0;$i<$totalRecords;$i++)
  21.             {
  22.                    echo $returnedData[$i]["imageLoc"] . "<br>";
  23.                 $stringData = "imgVar[".$iv++ ."] = " .$dQ .$returnedData[$i]["imageLoc"] .$dQ ."; \n";
  24.                 fwrite($capHandle, $stringData);
  25.             } 
  26.  
  27. }
  28.  
  29. fclose($capHandle);
  30. mysql_close();
  31.  
RESULTS

Expand|Select|Wrap|Line Numbers
  1. var imgVar = new Array();
  2. imgVar[0] = "http://theauctionwinners.com/resources/upload/64516994/images/1.jpg"; 
  3. imgVar[1] = "http://theauctionwinners.com/resources/upload/64516994/images/2.jpg"; 
  4. imgVar[2] = "http://theauctionwinners.com/resources/upload/64516994/images/3.jpg"; 
  5. imgVar[3] = "http://theauctionwinners.com/resources/upload/64516994/images/4.jpg"; 
  6.  
Jul 23 '09 #33

anfetienne
100+
P: 424
ok i've got it to import into flash and all my variables and arrays work fine.....now im stumped on how to get things to display in the gallery since the gallery was orriginally a xml gallery.....

does anybody know any good tutorials that could be useful working with arrays for galleries?
Jul 23 '09 #34

anfetienne
100+
P: 424
and my guess to loading an array using swfobject without auxiliary files after sleeping on it would be to create a string and use that as a value in swfobject code

so in your swfobject it would look like:

Expand|Select|Wrap|Line Numbers
  1. so.addVariable("varName", "<?php print $string?>");
  2.  
  3. or
  4.  
  5. so.addVariable("varName", "value1,value2,value3,value4");
  6.  
then it flash it looks like

Expand|Select|Wrap|Line Numbers
  1. trace ( varName )
  2. newAry=varName.split(",")
  3.  
and then you should have the array

Expand|Select|Wrap|Line Numbers
  1. newAry[0]=value1
  2. newAry[1]=value2
  3. newAry[2]=value3
  4. newAry[3]=value4
  5.  
i have not tested my thoery but i will do now
Jul 24 '09 #35

P: 6
yep , it should work
I found this method too ^^
you could use implode function in php to transform your array into string then put it in the database
Jul 25 '09 #36

P: 6
yep , it should work
I found this method too ^^
you could use implode function in php to transform your array into string then put it in the database
Jul 25 '09 #37

anfetienne
100+
P: 424
i've skipped trying to get my vars in through so.addVariable and stuff with a text file......i've tested it on a gallery i found that uses an array that you edit with you images and their locations and just basically took out that section add my array and changed all parts that had the old array name to mine and it works.

all i need now is thumbnails and captions to be included on it.......help?! lol ive posted it under flash/actionscript
Jul 26 '09 #38

anfetienne
100+
P: 424
i can't find any tutorial anywhere that is for a scrolling thumbnail bar wit buttons to go through them thumbnails.......

as for an example of what i've been dealing with here is code to an example of why i dont want to work with xml.....just copy and paste the code in a new html doc, save it and open it up. it loads the thumbnails, the captions but wont load the actual image....such a pain

Expand|Select|Wrap|Line Numbers
  1.  
  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml"><head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <script src="http://theauctionwinners.com/resources/templates/electronics_01/Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
  6. <style type="text/css">
  7. <!--
  8. .style94 {
  9.     color: #6C95B5
  10. }
  11. .style95 {
  12.     color: #C0C0C0;
  13.     font-family: Verdana, Arial, Helvetica, sans-serif;
  14. }
  15. .style96 {
  16.     font-family: Verdana, Arial, Helvetica, sans-serif;
  17.     font-weight: bold;
  18.     color: #AA33D1;
  19. }
  20. .style98 {font-size: 14px}
  21. body {
  22.     background-color: #aa33d1;
  23. }
  24. .style107 {
  25.     color: #666666;
  26.     font-family: Verdana, Arial, Helvetica, sans-serif;
  27.     font-size: 12px;
  28. }
  29. .style109 {font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif;}
  30. .style111 {
  31.     color: #6C95B5;
  32.     font-family: Verdana, Arial, Helvetica, sans-serif;
  33.     font-size: 14px;
  34. }
  35. a:link {
  36.     color: #C0C0C0;
  37.     text-decoration: none;
  38. }
  39. a:visited {
  40.     text-decoration: none;
  41.     color: #C0C0C0;
  42. }
  43. a:hover {
  44.     text-decoration: underline;
  45.     color: #6C95B5;
  46. }
  47. a:active {
  48.     text-decoration: none;
  49.     color: #C0C0C0;
  50. }
  51. .style113 {font-size: 12px}
  52. .style114 {font-weight: bold; font-family: Verdana, Arial, Helvetica, sans-serif;}
  53. .style115 {
  54.     font-family: Verdana, Arial, Helvetica, sans-serif;
  55.     font-size: 10px;
  56.     font-weight: bold;
  57. }
  58. .style117 {color: #C0C0C0}
  59. .style119 {color: #AA33D1}
  60. -->
  61. </style>
  62. <a name="top" id="top">
  63. <title></title>
  64. <STYLE type=text/css>
  65. BODY {
  66.     BACKGROUND-COLOR: #cccccc
  67. }
  68. BODY {
  69.     COLOR: #aa33d1
  70. }
  71. TD {
  72.     COLOR: #000000
  73. }
  74. TH {
  75.     COLOR: #000000
  76. }
  77. body {
  78.     margin:0px 0px;
  79.     padding:0px; /* Need to set body margin and padding to get consistency between browsers. */
  80.     text-align:center; /* Hack for IE5/Win */
  81.     background-color: #aa33d1;
  82.     }
  83.  
  84. #Content {
  85.     width:800px;
  86.     margin:0px auto; /* Right and left margin widths set to "auto" */
  87.     text-align:left; /* Counteract to IE5/Win Hack */
  88.     }
  89. </STYLE>
  90. </head><body>
  91. <div id="Content">
  92.     <TABLE cellSpacing=0 cellPadding=0 width=800 align=center border=0>
  93.       <TBODY>
  94.         <TR>
  95.           <TD height=300 background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg"><img src="http://theauctionwinners.com/resources/templates/electronics_01/header_bg.jpg" alt="" width="800" height="300" />                </TR>        <TR>
  96.         <TD height=29 background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg">        <div align="center">
  97.           <p class="style93 style96 style98"><a href="#description">Description</a> | <a href="#general">General</a> | <a href="#about">About</a> | <a href="#payment">Payment</a> | <a href="#terms">Terms & Conditions</a></p>
  98.         </div>          </TR>.        <TR>
  99.           <TD height=100 background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg"><div align="center">
  100.  
  101.             <h1><span class="style96">Motorbike Accessories</span></h1><h2 class="style95">Great leathers, helmets, boots and gloves!!!</h2>
  102.  
  103.         </div>        </TR>        <TR>
  104.           <TD height=450 background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg"><div align="center">
  105.  
  106.           <script type="text/javascript" src="http://theauctionwinners.com/resources/temp/swfobject.js"></script><div id="flashcontent">
  107.   This text is replaced by the Flash movie.
  108. </div><script type="text/javascript">
  109.    var so = new SWFObject("http://theauctionwinners.com/resources/upload/1035122540/gallery.swf", "gallery", "518", "536", "8", "#FFFFFF");so.addVariable("tempID", "http://theauctionwinners.com/resources/upload/1035122540/");so.write("flashcontent");
  110. </script> 
  111. </noscript></div>        </TR>
  112.  
  113. <TR>
  114.           <TD height=39 background="http://theauctionwinners.com/resources/templates/electronics_01/box_bottom.jpg">                </TR>
  115.         <TR>
  116.           <TD height=30>                </TR>        <TR>
  117.           <TD height=39 background="http://theauctionwinners.com/resources/templates/electronics_01/box_top.jpg">                </TR>
  118.         <TR>
  119.           <TD background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg"><table width="643" border="0" align="center" cellpadding="0" cellspacing="0">
  120.             <tr>
  121.               <td><a name="description" id="description"></a>
  122.                 <div align="left">
  123.                   <p class="style96">DESCRIPTION</p><p>asdaSDASD</p>              </div></td>
  124.             </tr>
  125.         </table>        </TR>
  126.         <TR>
  127.           <TD height=28 background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg">                </TR>        <TR>
  128.           <TD height=30 background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg"><table width="643" border="0" align="center" cellpadding="0" cellspacing="0">
  129.             <tr>
  130.               <td><a name="general" id="general"></a>
  131.                   <p class="style96">GENERAL</p><p>sdfgsdfgdsfgdsfgds</p>                <div align="left"><p> </p>
  132.                 </div></td>
  133.             </tr>
  134.         </table>        </TR>
  135.         <TR>
  136.           <TD height=39 background="http://theauctionwinners.com/resources/templates/electronics_01/box_bottom.jpg">                </TR>
  137.         <TR>
  138.           <TD height=30>                </TR>        <TR>
  139.           <TD height=39 background="http://theauctionwinners.com/resources/templates/electronics_01/box_top.jpg">                </TR>
  140.         <TR>
  141.           <TD height=30 background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg"><table width="643" border="0" align="center" cellpadding="0" cellspacing="0">
  142.             <tr>
  143.               <td><a name="about" id="about"></a>
  144.                 <div align="left">
  145.                   <p class="style96">ABOUT</p><p>sdgsdfgdsfgdsfgdsfg</p>              </div></td>
  146.             </tr>
  147.         </table>        </TR>
  148.  
  149.         <TR>
  150.           <TD height=30 background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg">                </TR>        <TR>
  151.           <TD height=27 background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg"><table width="643" border="0" align="center" cellpadding="0" cellspacing="0">
  152.             <tr>
  153.               <td><a name="payment" id="payment"></a>
  154.                 <p class="style96">PAYMENT</p>
  155.                 <p><span class="style111">PayPal</span><br /><img src=http://theauctionwinners.com/resources/temp/paypal.gif><img src=http://theauctionwinners.com/resources/temp/cheque.gif></p>
  156. </td>
  157.             </tr>
  158.         </table>        </TR>
  159.  
  160.         <TR>
  161.           <TD height=30 background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg">                </TR>        <TR>
  162.           <TD background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg">
  163.  
  164.  
  165.           <table width="628" border="0" align="center" cellpadding="0" cellspacing="0">
  166.  
  167.  
  168.             <tr>
  169.               <td><div align="left"><a name="terms" id="terms"></a>
  170.                 <p class="style96">TERMS & CONDITIONS</p><p>sdfgdsfgsdfgdsfgdsfg</p>              </div></td>
  171.             </tr>
  172.             <tr>
  173.               <td height="50"> </td>
  174.             </tr>
  175.         </table>        </TR>        <TR>
  176.           <TD height=40 background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg">        <div align="center" class="style93 style94">
  177.             <div align="center" class="style113">
  178.               <p class="style117"><span class="style93  style114"><a href="#description">Description</a> <span class="style119">|</span> <a href="#general">General</a> <span class="style119">|</span> <a href="#about">About</a> <span class="style119">|</span> <a href="#payment">Payment</a> <span class="style119">|</span> <a href="#terms">Terms & Conditions</a></span> <span class="style93  style114"><span class="style119">|</span></span> <span class="style114"><a href="#top">Back Top Top</a></span></p>
  179.               <p class="style115"><span class="style119">Designed By - <a href="http://www.auctioncreatorpro.com" target="_blank">The Auction Creator Pro</a></span></p>
  180.             </div>
  181.         </div>        </TR>
  182.         <TR>
  183.           <TD bgcolor="#aa33d1"><table width="200" border="0" cellspacing="0" cellpadding="0">
  184.             <tr>
  185.               <td><img src="http://theauctionwinners.com/resources/templates/electronics_01/box_bottom.jpg" alt="" width="800" height="28" /></td>
  186.             </tr>
  187.         </table>        </TR>
  188.       </TBODY>
  189.     </TABLE>
  190. </div>
  191. </body>
  192. </html>
  193.  
  194.  
  195.  
Jul 26 '09 #39

anfetienne
100+
P: 424
i have found the way to use swfobject to embed a flash movie and get vars to it.....funny thing is i don't need to use so.addVariable anymore. i found this in a tutorial at http://flash-creations.com/notes/dyn...dingviewer.php

i've set the filename in my swf file to be read as gallery.txt so whenever it gets copied to a new folder is will automatically look for it.

this is how my coding differs from the tutorial

Expand|Select|Wrap|Line Numbers
  1. /*********  DECLARE AND INITIALIZE VARIABLES  **************************/
  2. // names of folder and pictures, in the order to put them into the slider
  3. #include "gallery.txt"
  4.  
  5. var NPICS:Number = locVar.length;    // number of pictures to load
  6. var PICX:Number = 32.5;               // x loc of big picture
  7. var PICY:Number = 25;               // y loc
  8. var THUMBHOLDERX:Number = 50;        // x location of thumbnail holder movieclip
  9. var THUMBHOLDERY:Number = 430;      // y location
  10. var THUMBW:Number = 100;             // width of each thumbnail
  11. var THUMBH:Number = 75;             // height
  12. var MARGIN:Number = 10;             // margin between thumbnails
  13. var TOTALBYTES:Number = 212000;     // approx sum of bytes in all jpgs (x 2)
  14. var MAXPIXELS:Number = 12;          // max number of pixels to move slider per frame
  15.  
  16. // mask definition; mask is assumed to cover some part of the thumbnail slider (here the numbers
  17. // were chosen so that there are margins between the mask and the right and left edges of the movie
  18. // (which is 420 x 290), and enough space above and below the thumbs to show them when they 'grow'
  19. // on mouseover
  20. var MASKX:Number = 50;                // start x location of mask
  21. var MASKW:Number = 500;                // mask width
  22. var MASKY:Number = 438.5;                // start y location of mask
  23. var MASKH:Number = 90;                // mask height
  24.  
  25. var totalloaded:Number = 0;         // running tally of bytes loaded from all pics
  26.  
  27. // index into pictures array, used for loading
  28. var ipic:Number;
  29.  
  30. // set up loader, an instance of MovieClipLoader
  31. var loader:MovieClipLoader = new MovieClipLoader();
  32.  
  33. // use the main timeline to listen to and respond to loader's broadcast events
  34. loader.addListener(this);
  35.  
  36. /*********  DEFINE FUNCTIONS, INCLUDING INIT FOR MOVIE SETUP  **********/
  37. // thumbnail rollover handler
  38.  
  39. function grow() {
  40.    this.onEnterFrame = function() {
  41.       if (this._width < THUMBW * 1.2) {
  42.          this._x -= this._width * .025;
  43.          this._y -= this._height * .025;
  44.          this._width *= 1.05;
  45.          this._height *= 1.05;
  46.       } else delete this.onEnterFrame;
  47.    };
  48. }
  49.  
  50. // thumbnail rollout handler
  51.  
  52. function shrink() {
  53.    this.onEnterFrame = function() {
  54.       if (this._width > THUMBW) {
  55.          this._width /= 1.05;
  56.          this._height /= 1.05;
  57.          this._x += this._width * .025;
  58.          this._y += this._height * .025;
  59.       } else delete this.onEnterFrame;
  60.    };
  61. }
  62.  
  63. // function to move thumbnail slider ("this" = thumbs_mc)
  64.  
  65. function sliderControl() {
  66.    var w:Number = this._width/2;
  67.    var hw:Number = mask_mc._width/2;
  68.    var npixels:Number;
  69.    // only do when mouse over slider mask
  70.    if (_ymouse > mask_mc._y && _ymouse < mask_mc._y + mask_mc._height) {
  71.       // mouse over left half of slider:
  72.       if (_xmouse > mask_mc._x && _xmouse < mask_mc._x + hw) {
  73.          npixels = (hw - _xmouse) / hw * MAXPIXELS;
  74.          this._x += npixels;
  75.          if (this._x >= 0) this._x = this._x - w;
  76.       // mouse over right half of slider:
  77.       } else if (_xmouse > mask_mc._x + hw && _xmouse < mask_mc._x + mask_mc._width) {
  78.          npixels = (_xmouse - hw) / hw * MAXPIXELS;
  79.          this._x -= npixels;
  80.          if (this._x <= -w) this._x = this._x + w;
  81.       }
  82.    }
  83. }
  84.  
  85. // thumbnail click (onrelease) handler
  86.  
  87. function openPic() {
  88.    pic_mc.loadMovie(locVar[this.i]);
  89. }
  90.  
  91. // assign event handlers (called when all jpgs are loaded)
  92.  
  93. function setupHandlers() {
  94.    pct_txt.removeTextField();        // don't need loading indicator any more
  95.    thumbs_mc.onEnterFrame = sliderControl;
  96.    for (var i:Number = 0; i < NPICS*2; i++) {
  97.       thumbs_mc["mc"+i].onRollOver = grow;
  98.       thumbs_mc["mc"+i].onRollOut = shrink;       
  99.       thumbs_mc["mc"+i].onRelease = openPic;
  100.    }
  101. }
  102.  
  103. // listener function for broadcast 'done' message (for each pic)
  104. // onLoadInit gets executed when the movieclip has been loaded into _mc AND 
  105. //   its width and height data are available.
  106. //   (_mc = the movieclip being loaded into)
  107. // this routine sets the size and position of each thumbnail clip as its jpg
  108. //   is loaded and starts the next one loading.  When all have been loaded, 
  109. //   a random picture is loaded into pic_mc and setupHandlers is called to 
  110. //   assign handlers to each thumbnail movieclip
  111.  
  112. function onLoadInit(_mc:MovieClip) {
  113.    // this gets done when the jpg is completely loaded:
  114.    _mc._width = THUMBW;
  115.    _mc._height = THUMBH;
  116.    _mc._alpha = 99;        // for image clarity
  117.    // give the movieclip a property to remind it who it is
  118.    // (used by openPic to know which big picture to open)
  119.    _mc.i = (ipic >= NPICS ? ipic-NPICS : ipic);
  120.  
  121.    // add picture size to totalloaded variable
  122.    totalloaded += loader.getProgress(_mc).bytesTotal;
  123.  
  124.    // now load the next one (if there are more) or set up handlers if done
  125.    ipic++;
  126.    if (ipic == NPICS * 2) {
  127.       // start with a random photo displayed when all thumbs loaded
  128.       pic_mc.loadMovie(locVar[Math.floor(Math.random()*NPICS)]);
  129.       setupHandlers();
  130.    } else if (ipic >= NPICS) {
  131.       // load jpg into duplicate thumbnail (will already be cached)
  132.       loader.loadClip(locVar[ipic-NPICS],  thumbs_mc["mc"+ipic]);
  133.    } else {
  134.       // load jpg into thumbnail
  135.       loader.loadClip(locVar[ipic],  thumbs_mc["mc"+ipic]);
  136.    }
  137. }
  138.  
  139. // listener function to handle broadcast progress messages
  140. // make pct_txt show cumulative loading progress
  141.  
  142. function onLoadProgress(_mc:MovieClip, loaded:Number) {
  143.    var loadedsofar:Number = totalloaded + loaded;    
  144.    pct_txt.text = Math.floor(loadedsofar / TOTALBYTES * 100) + "%";
  145. }
  146.  
  147. function init() {
  148.    // create holder for pictures
  149.    createEmptyMovieClip("pic_mc", 1);
  150.    pic_mc._x = PICX;
  151.    pic_mc._y = PICY;
  152.  
  153.    // create (and draw) holder for thumbnails 
  154.    createEmptyMovieClip("thumbs_mc", 2);
  155.    thumbs_mc.beginFill(0, 100);    // black
  156.    thumbs_mc.moveTo(0, 0);
  157.       thumbs_mc.lineTo(2 * (MARGIN + THUMBW) * NPICS, 0);
  158.    thumbs_mc.lineTo(2 * (MARGIN + THUMBW) * NPICS, THUMBH);
  159.    thumbs_mc.lineTo(0, THUMBH);
  160.    thumbs_mc.endFill();
  161.    // drawing the thumb holder at 0, 0 and then moving it makes its reg point = upper left
  162.    thumbs_mc._x = THUMBHOLDERX;
  163.    thumbs_mc._y = THUMBHOLDERY;
  164.  
  165.    // create, draw and enable mask over thumbs (could use different variables to define mask
  166.    // if desired)
  167.    createEmptyMovieClip("mask_mc", 3);
  168.    mask_mc.beginFill(0x0000cc, 100);
  169.    mask_mc.moveTo(0, 0);
  170.    mask_mc.lineTo(MASKW, 0);
  171.    mask_mc.lineTo(MASKW, MASKH);
  172.    mask_mc.lineTo(0, MASKH);
  173.    mask_mc.endFill();
  174.    mask_mc._x = MASKX;
  175.    mask_mc._y = MASKY;
  176.    thumbs_mc.setMask(mask_mc);
  177.  
  178.    // create loading textfield indicator
  179.    createTextField("pct_txt", 4, 200, 100, 40, 100);
  180.    var tf:TextFormat = new TextFormat();
  181.    tf.align = "center";
  182.    tf.size = 12;
  183.    tf.font = "Verdana";
  184.    tf.color = 0xFFFF00;
  185.    pct_txt.setNewTextFormat(tf);
  186.  
  187.    // make empty movieclips in thumbs_mc for each pic to go into
  188.    // make double the number so the slider can move continuously and show content
  189.    for (var i:Number = 0; i < NPICS * 2; i++) {
  190.       var mc:MovieClip = thumbs_mc.createEmptyMovieClip("mc"+i, i+1);
  191.       mc._x = i*(MARGIN + THUMBW);
  192.       mc._y = 0;
  193.    }
  194.  
  195.    // set the pointer to the first jpg in the array picnames
  196.    ipic = 0;
  197.    // start loading jpgs (ipic is initialized to 0)
  198.    loader.loadClip(locVar[ipic], thumbs_mc["mc"+ipic]);
  199. }
  200.  
  201. /*********  CALL THE INIT FUNCTION TO START THE MOVIE  *****************/
  202. init();
  203.  
Jul 27 '09 #40

Markus
Expert 5K+
P: 6,050
You always managed to confuse me, Anfetienne. :P

Have you got your stuff working?
Jul 27 '09 #41

anfetienne
100+
P: 424
yes....ive got php to write a text file with flash vars.....then ive got flash to read the vars and import the large & thumbnail images.....i just need help with the captions now.

lol i dn't try to confuse you....it is always helpful to post my codes so other people can use it incase they try do the same thing i've done
Jul 27 '09 #42

anfetienne
100+
P: 424
this is a pain....now i test my codes fully and the vars wont load into the swf file even when using a text file and

#include "gallery.txt"

im using swfobject to load the swf into my code via an absolute link "http://" there are no variables beein passed through swf object as my code creates the array and saves it as gallery.txt in the same location as the swf file.
Jul 28 '09 #43

Canabeez
100+
P: 126
I think, this would be the solution to your problem...

The #include function only includes whenever you compile the swf, and it's saved in the swf, if the file is changed, you won't see any changes until you recompile the swf. I'd suggest you use XML() for loading information into flash.
Jul 28 '09 #44

anfetienne
100+
P: 424
i would love to use xml but when loading xml into flash it is relative to the html document flash is based on but....a very big but...the system i've made is all database generated....all codes are stored in a db and called up on when required i.e. to preview the coded page or to get the code.
Jul 28 '09 #45

anfetienne
100+
P: 424
and thank you for the suggestion....i will try it with my text file and if this doesn't work i will try it with a .as file
Jul 28 '09 #46

anfetienne
100+
P: 424
WWWWOOOOOOOOOOOOOOOOOO!!!!!!.......i have finally got it to work
Jul 28 '09 #47

anfetienne
100+
P: 424
haha now i have to get the captions to show.....oh joy oh joy.... :(
Jul 28 '09 #48

Canabeez
100+
P: 126
Still didn't get, you... There's no difference between loading a text file and loading XML, they can both be generated by backend script.
Jul 29 '09 #49

anfetienne
100+
P: 424
the problem with xml is when loading xml it needs to be relative to a html document....my codes are generated from a db and no html file is saved. i have my coding to create xml files and txt files with strings.

the problem im having is getting the final swf to loadVariables using http://myserver.com/test.txt as a url. it works locally but will not load anything once uploaded
Jul 29 '09 #50

Post your reply

Sign in to post your reply or Sign up for a free account.