is it possible to add php array to vars in the swfobject code?
49 5724
Have a look at encoding your array with json_encode and then, using action script decode it.
ok thanks marcus, ill go through that once ive set my computer back up properlly
@anfetienne
OK - let me know how you get on. Bear in mind that the link I gave you is for AS2, I think.
Mark.
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?
No - just encode and pass it as a flash var.
so ok does this look right to you as this is what i have......bear in mind all data is coming from a db -
$user="theau10_tawUser";
-
$pass="auction10";
-
$data="theau10_resources";
-
-
$connection=mysql_connect("localhost" ,"$user", "$pass") or die("Unable to connect!");
-
-
@mysql_select_db($data) or die( "Unable to select database");
-
-
// Select column 1 from table name where column name = $your_var.
-
$sql = "SELECT * FROM savedTemps WHERE tempID = '{$random_digit}'";
-
// If mysql_query returns false, we'll die with the error.
-
$res = mysql_query( $sql ) or die( mysql_error );
-
-
// If a there is a match
-
if ( mysql_num_rows( $res ) > 0 )
-
{
-
$row = mysql_fetch_array( $res );
-
-
}
-
-
$myVar = json_encode($row);
-
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)
???
Sounds about right - yes. Try it out and see.
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
You should be using import class.as (I think).
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: -
$blank = "";
-
-
// Select column 1 from table name where column name = $your_var.
-
$locSQL = "SELECT imageLoc FROM flashGallery WHERE tempID = '{$random_digit}'";
-
// If mysql_query returns false, we'll die with the error.
-
$locRES = mysql_query( $locSQL ) or die( mysql_error );
-
-
// If a there is a match
-
if ( mysql_num_rows( $locRES ) > 0 )
-
{
-
$locAry = mysql_fetch_array( $locRES );
-
-
}
-
else{
-
echo $blank;
-
}
-
-
-
$locVar = json_encode($locAry);
-
-
// Select column 1 from table name where column name = $your_var.
-
$tmbSQL = "SELECT thumbLoc FROM flashGallery WHERE tempID = '{$random_digit}'";
-
// If mysql_query returns false, we'll die with the error.
-
$tmbRES = mysql_query( $tmbSQL ) or die( mysql_error );
-
-
// If a there is a match
-
if ( mysql_num_rows( $tmbRES ) > 0 )
-
{
-
$tmbAry = mysql_fetch_array( $tmbRES );
-
-
}
-
else{
-
echo $blank;
-
}
-
-
$tmbVar = json_encode($tmbAry);
-
-
// Select column 1 from table name where column name = $your_var.
-
$capSQL = "SELECT imageLoc FROM flashGallery WHERE tempID = '{$random_digit}'";
-
// If mysql_query returns false, we'll die with the error.
-
$capRES = mysql_query( $capSQL ) or die( mysql_error );
-
-
// If a there is a match
-
if ( mysql_num_rows( $capRES ) > 0 )
-
{
-
$capAry = mysql_fetch_array( $capRES );
-
-
}
-
else{
-
echo $blank;
-
}
-
-
$capVar = json_encode($capAry);
-
-
mysql_close();
-
-
$flashVar1 = 'so.addParam("locVar", "'.$locVar .'");';
-
$flashVar2 = 'so.addParam("tmbVar", "'.$tmbVar .'");';
-
$flashVar3 = 'so.addParam("capVar", "'.$capVar .'");';
-
sql is only returning the 1st row?
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
ive fixed it here is the solution -
// Select column 1 from table name where column name = $your_var.
-
$locSQL = "SELECT imageLoc, thumbLoc, imageCap FROM flashGallery WHERE tempID = '{$random_digit}'";
-
// If mysql_query returns false, we'll die with the error.
-
$locRES = mysql_query( $locSQL ) or die( mysql_error );
-
-
// If a there is a match
-
if ( mysql_num_rows( $locRES ) > 0 )
-
{
-
-
while($row = mysql_fetch_array($locRES,MYSQL_ASSOC)){
-
-
$aryA[]=$row['imageLoc'];
-
$aryB[]=$row['thumbLoc'];
-
$aryC[]=$row['imageCap'];
-
-
}
-
}
-
$locAry = implode($aryA);
-
$tmbAry = implode($aryB);
-
$capAry = implode($aryC);
-
-
$flash02="so.addVariable('locVar', '$locAry'); so.addVariable('tmbVar', '$tmbAry'); so.addVariable('capVar', '$capAry');";
-
-
mysql_close();
-
?>
-
what's the action script code?
i don't know how to decompile the json code into flash :|
this is all i have for actionscript so far im testing it right now
#include "json.as"
trace( myVar );
varData = JSON.decode(myVar)
And is it working for you?
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)
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
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
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);
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?
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
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.
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?
@Markus
i simply used mysql_real_escape_string and it escaped it all with backslashes but in flash it wouldn't decode
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 {
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)
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
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
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 -
$capSQL = "SELECT * FROM flashGallery WHERE tempID = '{$random_digit}'";
-
$capRES = mysql_query( $capSQL ) or die( mysql_error );
-
-
if ( mysql_num_rows( $capRES ) > 0 )
-
{
-
-
$query = "SELECT * FROM flashGallery WHERE tempID = '{$random_digit}'";
-
$returnedData = selectMultiRows($query);
-
$totalRecords = count($returnedData);
-
-
$file = "upload/$random_digit/$random_digit.txt";
-
$capHandle = fopen($file, 'w') or die("can't open file");
-
-
$stringData = "var imgVar = new Array();\n";
-
fwrite($capHandle, $stringData);
-
-
$iv= 0;
-
-
for($i=0;$i<$totalRecords;$i++)
-
{
-
echo $returnedData[$i]["imageLoc"] . "<br>";
-
$stringData = "imgVar[".$iv++ ."] = ".$returnedData[$i]["imageLoc"] .", \n";
-
fwrite($capHandle, $stringData);
-
}
-
-
}
-
-
fclose($capHandle);
-
mysql_close();
-
RESULT -
var imgVar = new Array();
-
imgVar[0] = http://theauctionwinners.com/resources/upload/64516994/images/1.jpg,
-
imgVar[1] = http://theauctionwinners.com/resources/upload/64516994/images/2.jpg,
-
imgVar[2] = http://theauctionwinners.com/resources/upload/64516994/images/3.jpg,
-
imgVar[3] = http://theauctionwinners.com/resources/upload/64516994/images/4.jpg,
-
ooookkkkkkkkkkkkk new code......all that is needed is to import in flash and test the array
CODE -
$capSQL = "SELECT * FROM flashGallery WHERE tempID = '{$random_digit}'";
-
$capRES = mysql_query( $capSQL ) or die( mysql_error );
-
-
if ( mysql_num_rows( $capRES ) > 0 )
-
{
-
-
$query = "SELECT * FROM flashGallery WHERE tempID = '{$random_digit}'";
-
$returnedData = selectMultiRows($query);
-
$totalRecords = count($returnedData);
-
-
$file = "upload/$random_digit/$random_digit.txt";
-
$capHandle = fopen($file, 'w') or die("can't open file");
-
-
$stringData = "var imgVar = new Array();\n";
-
fwrite($capHandle, $stringData);
-
-
$iv= 0;
-
$dQ = '"';
-
-
for($i=0;$i<$totalRecords;$i++)
-
{
-
echo $returnedData[$i]["imageLoc"] . "<br>";
-
$stringData = "imgVar[".$iv++ ."] = " .$dQ .$returnedData[$i]["imageLoc"] .$dQ ."; \n";
-
fwrite($capHandle, $stringData);
-
}
-
-
}
-
-
fclose($capHandle);
-
mysql_close();
-
RESULTS -
var imgVar = new Array();
-
imgVar[0] = "http://theauctionwinners.com/resources/upload/64516994/images/1.jpg";
-
imgVar[1] = "http://theauctionwinners.com/resources/upload/64516994/images/2.jpg";
-
imgVar[2] = "http://theauctionwinners.com/resources/upload/64516994/images/3.jpg";
-
imgVar[3] = "http://theauctionwinners.com/resources/upload/64516994/images/4.jpg";
-
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?
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: -
so.addVariable("varName", "<?php print $string?>");
-
-
or
-
-
so.addVariable("varName", "value1,value2,value3,value4");
-
then it flash it looks like -
trace ( varName )
-
newAry=varName.split(",")
-
and then you should have the array -
newAry[0]=value1
-
newAry[1]=value2
-
newAry[2]=value3
-
newAry[3]=value4
-
i have not tested my thoery but i will do now
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
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
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
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 -
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml"><head>
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-
<script src="http://theauctionwinners.com/resources/templates/electronics_01/Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
-
<style type="text/css">
-
<!--
-
.style94 {
-
color: #6C95B5
-
}
-
.style95 {
-
color: #C0C0C0;
-
font-family: Verdana, Arial, Helvetica, sans-serif;
-
}
-
.style96 {
-
font-family: Verdana, Arial, Helvetica, sans-serif;
-
font-weight: bold;
-
color: #AA33D1;
-
}
-
.style98 {font-size: 14px}
-
body {
-
background-color: #aa33d1;
-
}
-
.style107 {
-
color: #666666;
-
font-family: Verdana, Arial, Helvetica, sans-serif;
-
font-size: 12px;
-
}
-
.style109 {font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif;}
-
.style111 {
-
color: #6C95B5;
-
font-family: Verdana, Arial, Helvetica, sans-serif;
-
font-size: 14px;
-
}
-
a:link {
-
color: #C0C0C0;
-
text-decoration: none;
-
}
-
a:visited {
-
text-decoration: none;
-
color: #C0C0C0;
-
}
-
a:hover {
-
text-decoration: underline;
-
color: #6C95B5;
-
}
-
a:active {
-
text-decoration: none;
-
color: #C0C0C0;
-
}
-
.style113 {font-size: 12px}
-
.style114 {font-weight: bold; font-family: Verdana, Arial, Helvetica, sans-serif;}
-
.style115 {
-
font-family: Verdana, Arial, Helvetica, sans-serif;
-
font-size: 10px;
-
font-weight: bold;
-
}
-
.style117 {color: #C0C0C0}
-
.style119 {color: #AA33D1}
-
-->
-
</style>
-
<a name="top" id="top">
-
<title></title>
-
<STYLE type=text/css>
-
BODY {
-
BACKGROUND-COLOR: #cccccc
-
}
-
BODY {
-
COLOR: #aa33d1
-
}
-
TD {
-
COLOR: #000000
-
}
-
TH {
-
COLOR: #000000
-
}
-
body {
-
margin:0px 0px;
-
padding:0px; /* Need to set body margin and padding to get consistency between browsers. */
-
text-align:center; /* Hack for IE5/Win */
-
background-color: #aa33d1;
-
}
-
-
#Content {
-
width:800px;
-
margin:0px auto; /* Right and left margin widths set to "auto" */
-
text-align:left; /* Counteract to IE5/Win Hack */
-
}
-
</STYLE>
-
</head><body>
-
<div id="Content">
-
<TABLE cellSpacing=0 cellPadding=0 width=800 align=center border=0>
-
<TBODY>
-
<TR>
-
<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>
-
<TD height=29 background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg"> <div align="center">
-
<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>
-
</div> </TR>. <TR>
-
<TD height=100 background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg"><div align="center">
-
-
<h1><span class="style96">Motorbike Accessories</span></h1><h2 class="style95">Great leathers, helmets, boots and gloves!!!</h2>
-
-
</div> </TR> <TR>
-
<TD height=450 background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg"><div align="center">
-
-
<script type="text/javascript" src="http://theauctionwinners.com/resources/temp/swfobject.js"></script><div id="flashcontent">
-
This text is replaced by the Flash movie.
-
</div><script type="text/javascript">
-
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");
-
</script>
-
</noscript></div> </TR>
-
-
<TR>
-
<TD height=39 background="http://theauctionwinners.com/resources/templates/electronics_01/box_bottom.jpg"> </TR>
-
<TR>
-
<TD height=30> </TR> <TR>
-
<TD height=39 background="http://theauctionwinners.com/resources/templates/electronics_01/box_top.jpg"> </TR>
-
<TR>
-
<TD background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg"><table width="643" border="0" align="center" cellpadding="0" cellspacing="0">
-
<tr>
-
<td><a name="description" id="description"></a>
-
<div align="left">
-
<p class="style96">DESCRIPTION</p><p>asdaSDASD</p> </div></td>
-
</tr>
-
</table> </TR>
-
<TR>
-
<TD height=28 background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg"> </TR> <TR>
-
<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">
-
<tr>
-
<td><a name="general" id="general"></a>
-
<p class="style96">GENERAL</p><p>sdfgsdfgdsfgdsfgds</p> <div align="left"><p> </p>
-
</div></td>
-
</tr>
-
</table> </TR>
-
<TR>
-
<TD height=39 background="http://theauctionwinners.com/resources/templates/electronics_01/box_bottom.jpg"> </TR>
-
<TR>
-
<TD height=30> </TR> <TR>
-
<TD height=39 background="http://theauctionwinners.com/resources/templates/electronics_01/box_top.jpg"> </TR>
-
<TR>
-
<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">
-
<tr>
-
<td><a name="about" id="about"></a>
-
<div align="left">
-
<p class="style96">ABOUT</p><p>sdgsdfgdsfgdsfgdsfg</p> </div></td>
-
</tr>
-
</table> </TR>
-
-
<TR>
-
<TD height=30 background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg"> </TR> <TR>
-
<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">
-
<tr>
-
<td><a name="payment" id="payment"></a>
-
<p class="style96">PAYMENT</p>
-
<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>
-
</td>
-
</tr>
-
</table> </TR>
-
-
<TR>
-
<TD height=30 background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg"> </TR> <TR>
-
<TD background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg">
-
-
-
<table width="628" border="0" align="center" cellpadding="0" cellspacing="0">
-
-
-
<tr>
-
<td><div align="left"><a name="terms" id="terms"></a>
-
<p class="style96">TERMS & CONDITIONS</p><p>sdfgdsfgsdfgdsfgdsfg</p> </div></td>
-
</tr>
-
<tr>
-
<td height="50"> </td>
-
</tr>
-
</table> </TR> <TR>
-
<TD height=40 background="http://theauctionwinners.com/resources/templates/electronics_01/body_bg.jpg"> <div align="center" class="style93 style94">
-
<div align="center" class="style113">
-
<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>
-
<p class="style115"><span class="style119">Designed By - <a href="http://www.auctioncreatorpro.com" target="_blank">The Auction Creator Pro</a></span></p>
-
</div>
-
</div> </TR>
-
<TR>
-
<TD bgcolor="#aa33d1"><table width="200" border="0" cellspacing="0" cellpadding="0">
-
<tr>
-
<td><img src="http://theauctionwinners.com/resources/templates/electronics_01/box_bottom.jpg" alt="" width="800" height="28" /></td>
-
</tr>
-
</table> </TR>
-
</TBODY>
-
</TABLE>
-
</div>
-
</body>
-
</html>
-
-
-
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 -
/********* DECLARE AND INITIALIZE VARIABLES **************************/
-
// names of folder and pictures, in the order to put them into the slider
-
#include "gallery.txt"
-
-
var NPICS:Number = locVar.length; // number of pictures to load
-
var PICX:Number = 32.5; // x loc of big picture
-
var PICY:Number = 25; // y loc
-
var THUMBHOLDERX:Number = 50; // x location of thumbnail holder movieclip
-
var THUMBHOLDERY:Number = 430; // y location
-
var THUMBW:Number = 100; // width of each thumbnail
-
var THUMBH:Number = 75; // height
-
var MARGIN:Number = 10; // margin between thumbnails
-
var TOTALBYTES:Number = 212000; // approx sum of bytes in all jpgs (x 2)
-
var MAXPIXELS:Number = 12; // max number of pixels to move slider per frame
-
-
// mask definition; mask is assumed to cover some part of the thumbnail slider (here the numbers
-
// were chosen so that there are margins between the mask and the right and left edges of the movie
-
// (which is 420 x 290), and enough space above and below the thumbs to show them when they 'grow'
-
// on mouseover
-
var MASKX:Number = 50; // start x location of mask
-
var MASKW:Number = 500; // mask width
-
var MASKY:Number = 438.5; // start y location of mask
-
var MASKH:Number = 90; // mask height
-
-
var totalloaded:Number = 0; // running tally of bytes loaded from all pics
-
-
// index into pictures array, used for loading
-
var ipic:Number;
-
-
// set up loader, an instance of MovieClipLoader
-
var loader:MovieClipLoader = new MovieClipLoader();
-
-
// use the main timeline to listen to and respond to loader's broadcast events
-
loader.addListener(this);
-
-
/********* DEFINE FUNCTIONS, INCLUDING INIT FOR MOVIE SETUP **********/
-
// thumbnail rollover handler
-
-
function grow() {
-
this.onEnterFrame = function() {
-
if (this._width < THUMBW * 1.2) {
-
this._x -= this._width * .025;
-
this._y -= this._height * .025;
-
this._width *= 1.05;
-
this._height *= 1.05;
-
} else delete this.onEnterFrame;
-
};
-
}
-
-
// thumbnail rollout handler
-
-
function shrink() {
-
this.onEnterFrame = function() {
-
if (this._width > THUMBW) {
-
this._width /= 1.05;
-
this._height /= 1.05;
-
this._x += this._width * .025;
-
this._y += this._height * .025;
-
} else delete this.onEnterFrame;
-
};
-
}
-
-
// function to move thumbnail slider ("this" = thumbs_mc)
-
-
function sliderControl() {
-
var w:Number = this._width/2;
-
var hw:Number = mask_mc._width/2;
-
var npixels:Number;
-
// only do when mouse over slider mask
-
if (_ymouse > mask_mc._y && _ymouse < mask_mc._y + mask_mc._height) {
-
// mouse over left half of slider:
-
if (_xmouse > mask_mc._x && _xmouse < mask_mc._x + hw) {
-
npixels = (hw - _xmouse) / hw * MAXPIXELS;
-
this._x += npixels;
-
if (this._x >= 0) this._x = this._x - w;
-
// mouse over right half of slider:
-
} else if (_xmouse > mask_mc._x + hw && _xmouse < mask_mc._x + mask_mc._width) {
-
npixels = (_xmouse - hw) / hw * MAXPIXELS;
-
this._x -= npixels;
-
if (this._x <= -w) this._x = this._x + w;
-
}
-
}
-
}
-
-
// thumbnail click (onrelease) handler
-
-
function openPic() {
-
pic_mc.loadMovie(locVar[this.i]);
-
}
-
-
// assign event handlers (called when all jpgs are loaded)
-
-
function setupHandlers() {
-
pct_txt.removeTextField(); // don't need loading indicator any more
-
thumbs_mc.onEnterFrame = sliderControl;
-
for (var i:Number = 0; i < NPICS*2; i++) {
-
thumbs_mc["mc"+i].onRollOver = grow;
-
thumbs_mc["mc"+i].onRollOut = shrink;
-
thumbs_mc["mc"+i].onRelease = openPic;
-
}
-
}
-
-
// listener function for broadcast 'done' message (for each pic)
-
// onLoadInit gets executed when the movieclip has been loaded into _mc AND
-
// its width and height data are available.
-
// (_mc = the movieclip being loaded into)
-
// this routine sets the size and position of each thumbnail clip as its jpg
-
// is loaded and starts the next one loading. When all have been loaded,
-
// a random picture is loaded into pic_mc and setupHandlers is called to
-
// assign handlers to each thumbnail movieclip
-
-
function onLoadInit(_mc:MovieClip) {
-
// this gets done when the jpg is completely loaded:
-
_mc._width = THUMBW;
-
_mc._height = THUMBH;
-
_mc._alpha = 99; // for image clarity
-
// give the movieclip a property to remind it who it is
-
// (used by openPic to know which big picture to open)
-
_mc.i = (ipic >= NPICS ? ipic-NPICS : ipic);
-
-
// add picture size to totalloaded variable
-
totalloaded += loader.getProgress(_mc).bytesTotal;
-
-
// now load the next one (if there are more) or set up handlers if done
-
ipic++;
-
if (ipic == NPICS * 2) {
-
// start with a random photo displayed when all thumbs loaded
-
pic_mc.loadMovie(locVar[Math.floor(Math.random()*NPICS)]);
-
setupHandlers();
-
} else if (ipic >= NPICS) {
-
// load jpg into duplicate thumbnail (will already be cached)
-
loader.loadClip(locVar[ipic-NPICS], thumbs_mc["mc"+ipic]);
-
} else {
-
// load jpg into thumbnail
-
loader.loadClip(locVar[ipic], thumbs_mc["mc"+ipic]);
-
}
-
}
-
-
// listener function to handle broadcast progress messages
-
// make pct_txt show cumulative loading progress
-
-
function onLoadProgress(_mc:MovieClip, loaded:Number) {
-
var loadedsofar:Number = totalloaded + loaded;
-
pct_txt.text = Math.floor(loadedsofar / TOTALBYTES * 100) + "%";
-
}
-
-
function init() {
-
// create holder for pictures
-
createEmptyMovieClip("pic_mc", 1);
-
pic_mc._x = PICX;
-
pic_mc._y = PICY;
-
-
// create (and draw) holder for thumbnails
-
createEmptyMovieClip("thumbs_mc", 2);
-
thumbs_mc.beginFill(0, 100); // black
-
thumbs_mc.moveTo(0, 0);
-
thumbs_mc.lineTo(2 * (MARGIN + THUMBW) * NPICS, 0);
-
thumbs_mc.lineTo(2 * (MARGIN + THUMBW) * NPICS, THUMBH);
-
thumbs_mc.lineTo(0, THUMBH);
-
thumbs_mc.endFill();
-
// drawing the thumb holder at 0, 0 and then moving it makes its reg point = upper left
-
thumbs_mc._x = THUMBHOLDERX;
-
thumbs_mc._y = THUMBHOLDERY;
-
-
// create, draw and enable mask over thumbs (could use different variables to define mask
-
// if desired)
-
createEmptyMovieClip("mask_mc", 3);
-
mask_mc.beginFill(0x0000cc, 100);
-
mask_mc.moveTo(0, 0);
-
mask_mc.lineTo(MASKW, 0);
-
mask_mc.lineTo(MASKW, MASKH);
-
mask_mc.lineTo(0, MASKH);
-
mask_mc.endFill();
-
mask_mc._x = MASKX;
-
mask_mc._y = MASKY;
-
thumbs_mc.setMask(mask_mc);
-
-
// create loading textfield indicator
-
createTextField("pct_txt", 4, 200, 100, 40, 100);
-
var tf:TextFormat = new TextFormat();
-
tf.align = "center";
-
tf.size = 12;
-
tf.font = "Verdana";
-
tf.color = 0xFFFF00;
-
pct_txt.setNewTextFormat(tf);
-
-
// make empty movieclips in thumbs_mc for each pic to go into
-
// make double the number so the slider can move continuously and show content
-
for (var i:Number = 0; i < NPICS * 2; i++) {
-
var mc:MovieClip = thumbs_mc.createEmptyMovieClip("mc"+i, i+1);
-
mc._x = i*(MARGIN + THUMBW);
-
mc._y = 0;
-
}
-
-
// set the pointer to the first jpg in the array picnames
-
ipic = 0;
-
// start loading jpgs (ipic is initialized to 0)
-
loader.loadClip(locVar[ipic], thumbs_mc["mc"+ipic]);
-
}
-
-
/********* CALL THE INIT FUNCTION TO START THE MOVIE *****************/
-
init();
-
You always managed to confuse me, Anfetienne. :P
Have you got your stuff working?
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
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.
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.
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.
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
WWWWOOOOOOOOOOOOOOOOOO!!!!!!.......i have finally got it to work
haha now i have to get the captions to show.....oh joy oh joy.... :(
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.
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
Sign in to post your reply or Sign up for a free account.
Similar topics
by: dragze |
last post by:
Hi,
On one of the pages of my site i use two javascripts, one makes transparency of png's work in IE, and the other embeds a flash player.
Now use one of the scripts it works fine, use both and...
|
by: Dariusz Tomoń |
last post by:
Hello,
I'd like to include JS from C# code (ASP.NET 2.0). I'm trying not directly
from i.e. default.aspx.cs code but from a class belonging to DLL, which is
referred in my project.
The code...
|
by: luispunchy |
last post by:
I have a .swf file that is going in the web page for the logo. It is supposed to be 610px wide and 81px in height when rendered in the HTML. The actual .swf file, when viewed standalone, appears much...
|
by: K. |
last post by:
Hello!
I have a problem with javascript script called: SWFObject.
I have a web page which displays on IE 7.0. i Firefox in a good way.
All flash objects are displayed on a web page.
The problem...
|
by: yogarajan |
last post by:
hi friend
this is my code
<script type="text/javascript">
// <!]>
</script>
it is working fine for (open file)
file:///D:/WebSite4/swfobject/swfobject1-5/fullpage.html
|
by: jay11 |
last post by:
Hello peeps
I am trying to run a banner with SWFObject from within PHP/Mambo.
I have two others SWF in the same page, so I know it works.
Also checked the Developer tool in Chrome and saw that...
|
by: mikek12004 |
last post by:
Trying to build a flash rotator which takes some swf from a db and rotates them.
In the head I have
<script type="text/javascript">
clock_ads(1);
function clock_ads(i)
{
<?php...
|
by: jeddiki |
last post by:
I am reading up on this swfobject which uses javascript to embed the
swf files.
They say that I need to have adobe flash player 9.0
Well I was going to use Flowplayer.
Does this mean that...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made but the http to https rule only works for...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
header("Location:".$urlback);
Is this the right layout the...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
| |