all groups > flash data integration > november 2005 >
You're in the

flash data integration

group:

Reloading information into flash from MySQL


Re: Reloading information into flash from MySQL Motion Maker
11/20/2005 8:37:40 PM
flash data integration:
1. What does the reloadSlides function do? That seems to be the one needed
to evaluate.

2. May not be the problem, but be sure the load method follows the onLoad
handler in your code in both places. It is possible load could complete
before the line is reached and thus the code for the onLoad event does not
get processed resulting in random failed results.

--
Lon Hosford
www.lonhosford.com
May many happy bits flow your way!
[quoted text, click to view]
hey all,

i am having an odd problem. I dont understand why it dont work (well der
otherwise why would i be positng). Right.. well i am creating a dynamic
photo
gallery. The basics of it work well. The combo box is dynamically loaded
from
a php script that calls the MySQL DB and returns it in a string.... sorry
if i
am a bit slow and explaining every strep but only just learnt the loadVars
bit
today.

The pictures are also loaded into flash through the same style. (different
loadVars() thingy).. this works great the first time. but what i want to do
is
when they select an option on the combo box it requiries the DB through the
php
script and loads the new pictures up.

I know the php script works as i build a quick html page to check the post
and
it does return only the required pictures when there is something in the
post,
and when there isnt it returns them all.

but nothing is (seems) to be reloaded. i am not understanding where it is
going wrong. any suggestions plz? I am hoping from looking at that the
problem
will be visible. i am sure thats where the problem lies as i tested the php
script on its own.

Thank you for your help in advance.

Twiggy:o

//loads in the combo box options
headerLoader = new LoadVars();
headerLoader.load("headers.php");
headerLoader.ref = this;
headerLoader.onLoad = function(success) {
if(success) {
for(var i=0; i < this.EOF; i++) {
picid = this["catid"+i];
name = this["name"+i];
headers.addItem(name,picid);
}
}
headers.rowCount = 10;
}
//loads in the pictures
slideLoader = new LoadVars();
slideLoader.load("slides.php");
slideLoader.ref = this;
slideLoader.onLoad = loadSlides;
//in theory this should reload the pictures when combo box is used
function reloadSlides(searchString) {
slideLoader.search = searchString;
slideLoader.sendAndLoad("slides.php",this,"POST");
slideLoader.onLoad = loadSlides;
}

function loadSlides(success) {
if(success) {
for(var i=0; i < this.EOF; i++) {
urlss = this["URL"+i];
widthss = this["height"+i];
heightss = this["width"+i];
commentsss = this["comments"+i];
namess = this["name"+i];
slideNode = new Array();
slideNode[0] = urlss;
slideNode[1] = heightss;
slideNode[2] = widthss;
slideNode[3] = commentsss;
slideNode[4] = namess;
slides[i] = slideNode;
}
}
else {
picName.text = "fuckup";
}
startSlideShow();
}

// Show the first slide and intialize variables
function startSlideShow() {
_global.max = slides.length;
totalPicsNum.text = _global.max;
_global.index = 0;
picNum.text = _global.index+1;
updateSlide(_global.index);
}
//
// Updates the current slide with new image and text
function updateSlide(pointer) {
node = slides[pointer];
imagePath = node[0];
picName.text = node[4];
picComment.text = node[3];
imgwidth = Number(node[2]);
imgheight= Number(node[1]);
loadMovie(imagePath, targetClip);
var x = ((((100-((imgwidth/swidth)*100)) / 2 ) / 100) * swidth);
var y = ((((100-((imgheight/sheight)*100)) / 2 ) / 100) * sheight) + 18;
_root.targetClip._x = x;
_root.targetClip._y = y;
testButtons();

picName = slides.length;
}

//combo box code
on(change) {
reloadSlides(this.value);
}

Re: Reloading information into flash from MySQL TwistedTwig
11/21/2005 12:00:00 AM
OMG thank you sooo sooo much!!!!

that was the perfect fix. i see what was going wrong.. only thing i am just
trying to fix is getting the change option on the combo box to work.. made a
quick button and that worked great... over the moon.

THX
Reloading information into flash from MySQL TwistedTwig
11/21/2005 1:17:16 AM
hey all,

i am having an odd problem. I dont understand why it dont work (well der
otherwise why would i be positng). Right.. well i am creating a dynamic photo
gallery. The basics of it work well. The combo box is dynamically loaded from
a php script that calls the MySQL DB and returns it in a string.... sorry if i
am a bit slow and explaining every strep but only just learnt the loadVars bit
today.

The pictures are also loaded into flash through the same style. (different
loadVars() thingy).. this works great the first time. but what i want to do is
when they select an option on the combo box it requiries the DB through the php
script and loads the new pictures up.

I know the php script works as i build a quick html page to check the post and
it does return only the required pictures when there is something in the post,
and when there isnt it returns them all.

but nothing is (seems) to be reloaded. i am not understanding where it is
going wrong. any suggestions plz? I am hoping from looking at that the problem
will be visible. i am sure thats where the problem lies as i tested the php
script on its own.

Thank you for your help in advance.

Twiggy:o

//loads in the combo box options
headerLoader = new LoadVars();
headerLoader.load("headers.php");
headerLoader.ref = this;
headerLoader.onLoad = function(success) {
if(success) {
for(var i=0; i < this.EOF; i++) {
picid = this["catid"+i];
name = this["name"+i];
headers.addItem(name,picid);
}
}
headers.rowCount = 10;
}
//loads in the pictures
slideLoader = new LoadVars();
slideLoader.load("slides.php");
slideLoader.ref = this;
slideLoader.onLoad = loadSlides;
//in theory this should reload the pictures when combo box is used
function reloadSlides(searchString) {
slideLoader.search = searchString;
slideLoader.sendAndLoad("slides.php",this,"POST");
slideLoader.onLoad = loadSlides;
}

function loadSlides(success) {
if(success) {
for(var i=0; i < this.EOF; i++) {
urlss = this["URL"+i];
widthss = this["height"+i];
heightss = this["width"+i];
commentsss = this["comments"+i];
namess = this["name"+i];
slideNode = new Array();
slideNode[0] = urlss;
slideNode[1] = heightss;
slideNode[2] = widthss;
slideNode[3] = commentsss;
slideNode[4] = namess;
slides[i] = slideNode;
}
}
else {
picName.text = "fuckup";
}
startSlideShow();
}

// Show the first slide and intialize variables
function startSlideShow() {
_global.max = slides.length;
totalPicsNum.text = _global.max;
_global.index = 0;
picNum.text = _global.index+1;
updateSlide(_global.index);
}
//
// Updates the current slide with new image and text
function updateSlide(pointer) {
node = slides[pointer];
imagePath = node[0];
picName.text = node[4];
picComment.text = node[3];
imgwidth = Number(node[2]);
imgheight= Number(node[1]);
loadMovie(imagePath, targetClip);
var x = ((((100-((imgwidth/swidth)*100)) / 2 ) / 100) * swidth);
var y = ((((100-((imgheight/sheight)*100)) / 2 ) / 100) * sheight) + 18;
_root.targetClip._x = x;
_root.targetClip._y = y;
testButtons();

picName = slides.length;
}

//combo box code
on(change) {
reloadSlides(this.value);
}
Re: Reloading information into flash from MySQL Motion Maker
11/21/2005 10:24:56 AM
Sorry you did post it I just did not see it.

The function LoadSlides really should be before the assignment to
slideLoader.onLoad. This needs to be the case for all the onLoad
assignments, the function needs to before the assignment.

You cannot
b = a
a = 1

and expect b to be 1.

So you cannot expect

slideLoader.onLoad = loadSlides
loadSlides = function() ....

and expect slideLoader.onLoad to be loadSlides.

The order is reversed.
loadSlides = function() ....
slideLoader.onLoad = loadSlides

So that above needs to be straighted out regardless if the real problem is
more scoping or a logic error.

To keep from going insane the easiest way to do this would be to declare the
loadVars as a timeline variable. So just on a frame script. Then use
function to call the sendAndLoad (and after the initial assignment of
onLoad)

myReceive_lv = new LoadVars()
myReceive_lv.onLoad = function()
{
trace (myReceive_lv.var1)
trace (myReceive_lv.var2)
}
mySend_lv = new LoadVars()

Then functions on that same timeline can reference it

slideLoader = function()
{
mySnd_lv.sendAndLoad("slides.php",myReceive_lv, "POST");
}

myBtn.onRelease()
{
mySnd_lv.var1 = ____
mySnd_lv.var2 = ____
slideLoader()

}
// Initial loading
mySnd_lv.var1 = ____
mySnd_lv.var2 = ____
slideLoader()





--
Lon Hosford
www.lonhosford.com
May many happy bits flow your way!
[quoted text, click to view]
thx for gettign back to me.

i may not have explained my self very well... was late and i sometimes are
a
terrible code commenter. the reload funciton

function reloadSlides(searchString) {
slideLoader.search = searchString;
slideLoader.sendAndLoad("slides.php",this,"POST");
slideLoader.onLoad = loadSlides;
}

is supposed to be called when and only when the combo box on(change) method
is
envoked. it would pass in the value of the combo box selection to the
method.
then the variable searchstring should be attached to a post variable search
that the php script could retrieve. the the sendAndLoad method should call
the
slides.php script telling it that theres the posted variable and the
information should be passed back in. from what i have read that code just
above this method should automatically be called, (i think... this could be
where i am falling down)... and then it should re load the images with the
method call

//loads in the pictures
slideLoader = new LoadVars();
slideLoader.load("slides.php");
slideLoader.ref = this;
slideLoader.onLoad = loadSlides;

loadSlides should set things up and redo the first pic and counters. i am
aware i have some issues with the array.. ie if it went for 150 pics to 10
there would still be all the old pics from 11 onwards... i think i would
just
need to create a new array each time loadSlides was called.

am i way off base with my line of thinking here? bit confused

thx Twiggy

Re: Reloading information into flash from MySQL TwistedTwig
11/21/2005 10:42:42 AM
thx for gettign back to me.

i may not have explained my self very well... was late and i sometimes are a
terrible code commenter. the reload funciton

function reloadSlides(searchString) {
slideLoader.search = searchString;
slideLoader.sendAndLoad("slides.php",this,"POST");
slideLoader.onLoad = loadSlides;
}

is supposed to be called when and only when the combo box on(change) method is
envoked. it would pass in the value of the combo box selection to the method.
then the variable searchstring should be attached to a post variable search
that the php script could retrieve. the the sendAndLoad method should call the
slides.php script telling it that theres the posted variable and the
information should be passed back in. from what i have read that code just
above this method should automatically be called, (i think... this could be
where i am falling down)... and then it should re load the images with the
method call

//loads in the pictures
slideLoader = new LoadVars();
slideLoader.load("slides.php");
slideLoader.ref = this;
slideLoader.onLoad = loadSlides;

loadSlides should set things up and redo the first pic and counters. i am
aware i have some issues with the array.. ie if it went for 150 pics to 10
there would still be all the old pics from 11 onwards... i think i would just
need to create a new array each time loadSlides was called.

am i way off base with my line of thinking here? bit confused

thx Twiggy
Re: Reloading information into flash from MySQL Motion Maker
11/21/2005 7:08:45 PM
Super!

--=20
Lon Hosford
www.lonhosford.com
May many happy bits flow your way!
[quoted text, click to view]
OMG thank you sooo sooo much!!!!

that was the perfect fix. i see what was going wrong.. only thing i am =
just=20
trying to fix is getting the change option on the combo box to work.. =
made a=20
quick button and that worked great... over the moon.

AddThis Social Bookmark Button