Groups | Blog | Home
all groups > flash data integration > march 2005 >

flash data integration : Linking with dynamic variables problem..getUrl


roddyguy
3/26/2005 4:28:06 PM
I needed to create a flash scrollbar with dynamically generated thumbnails that
would link to a page and send the ImageID as a URL parameter. Could not find
much reference material for this, was but successfully able to produce such a
scenario... almost. My problem is, that even though my ProblemVariable (taken
from a Dataset) displays correct ImageIDs and Thumbnails (loader objects)
display correct Thumbnails (within a while statement)...The ProblemVariable
when placed in the repeating getUrl function always links to the last
ProblemVariable set and not the current.

The only reason I had added the Label object was so that I could test that the
problem really was within the getUrl function. Sure enough, the Label's HTML
link with the ProblemVariable works perfectly because it is picking up the
current dataset record.

I'm sure the reason that the repeating getUrl functions keep grabbing the last
ProblemVariable set is because the function actually happens outside of the
loop and because the variable is not static, it will always grab the last value
set.... but does anyone know and answer to my problem. I have been wresting
with this for days now. I have tried using 'eval', 'String.concat',
'loadVars.send', among other things.

I'm sure there is a simple answer, but it is out of my expertise.

Below is my code for the movieclip that resides in the scrollpane:

var thisim:Number = _root.iid;
var numstr:Number = 0;
var ImageDepth:Number = 0;
var LabelDepth:Number = 10;
var yVal:Number = 10;
var strImageName = "loader"+(numstr);
var strLabelName = "label"+(numstr);
var ProblemVariable = "";

while (images_dataset.hasNext()) {
if (images_dataset.currentItem.ImageID != thisim) {
newxImage = createClassObject(mx.controls.Loader, strImageName, ImageDepth);
newxImage._y = yVal;
newxImage._x = 10;
newxImage.contentPath = (images_dataset.currentItem.Thumbnail);

newxLabel = createClassObject(mx.controls.Label, strLabelName, LabelDepth);
newxLabel._x = 1;
newxLabel._y = yVal;
newxLabel.html = true;

ProblemVariable = images_dataset.currentItem.ImageID;

newxLabel.text = "<a
href=\"project_category.php?iid="+ProblemVariable+"\">"+ProblemVariable+"</a>";

newxImage.onPress = function() {
getUrl("project_category.php?iid="+ProblemVariable+");
};

yVal = yVal+110;
ImageDepth = ImageDepth+1;
LabelDepth = LabelDepth+1;
numstr = numstr+1;
strImageName = "loader"+(numstr);
strImageName = "label"+(numstr);
}
images_dataset.next();
}
stop();

:confused;
roddyguy
3/29/2005 12:44:41 AM
someone on another board gave me the solution. I hope this helps others:

newxImage.ProblemVariable = images_dataset.currentItem.ImageID;
...
newxImage.onPress = function() {
getUrl("project_category.php?iid="+this.ProblemVariable+"");
};

This solves the problem ... a local variable in the newximage object, wich
will have no connection with the changes in while {

By the way, I'll have to agree with the post above mine.
This board kind of sucks. Where are the people that made the product.
AddThis Social Bookmark Button