Welcome, Guest. Please login or register.
Did you miss your activation email?
05/22/12, 06:12
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  MySQL, PostgreSQL, MS SQL, Access (Moderators: Flash-db, Musicman, Ronald Wernecke, Jorge Solis, Andries Seutens)
| | |-+  php mysql pass dynamic URL into button
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: php mysql pass dynamic URL into button  (Read 5410 times)
brentc73
Server what's that
*
Posts: 16


View Profile WWW
« on: 09/30/08, 20:00 »

I have read the saving and loading tut and have it working... my only problem is that I have a button and I am trying to have the db pass the url to the button and it is not working.

in my fla I have an mc container holding the picture "c", heading "news" and a button "b".
All the information is coming through but when I click the button ("b") the url is coming up undefined. Obviously something is screwy in my AS, any help would be greatly appreciated.

Code:
myData = new LoadVars();
myData.load("prod_quickfind_thumbs.php?"+Math.random());
myData.ref = this;
myData.onLoad = function(success) {
if (success) {
for (var i = 0; i<this.count; i++) {
this.ref["news"+i].text = this["Fname"+i];
trace(this.ref["news"+i]);
this.ref["c"+i].loadMovie(this["Fimage"+i]);
this.ref["b"+i].onRelease = function() {
getURL(this.ref["Flink"+i], "iframemain");
};
trace(this.ref["b"+i]);
trace(this["Flink"+i]);
}
} else {
trace("Error loading data");
}
};
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #1 on: 10/01/08, 05:26 »

The button should be a MovieClip, then use this:

Code:
this.ref["b"+i].uri = this.ref["Flink"+i]
this.ref["b"+i].onRelease = function() {
getURL(this.uri, "iframemain");
};

Jorge
Logged

brentc73
Server what's that
*
Posts: 16


View Profile WWW
« Reply #2 on: 10/01/08, 12:02 »

Thank you, very much appreciated...
However it is still not working, I am still getting an undefined var when I click the link.
Could it be because it is an mc inside an mc? Should I lock the root?

I now have
Code:
myData = new LoadVars();
myData.load("prod_quickfind_thumbs.php?"+Math.random());
myData.ref = this;
myData.onLoad = function(success) {
if (success) {
for (var i = 0; i<this.count; i++) {
this.ref["news"+i].text = this["Fname"+i];
trace(this.ref["news"+i]);
this.ref["c"+i].loadMovie(this["Fimage"+i]);
this.ref["b"+i].uri = this.ref["Flink"+i];
this.ref["b"+i].onRelease = function() {
getURL(this.uri, "iframemain");
};
trace(this.ref["b"+i]);
trace(this["Flink"+i]);
}
} else {
trace("Error loading data");
}
};

Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #3 on: 10/01/08, 12:17 »

Are you tracing this.ref["Flink"+i];
Can you see it in the PHP output?

Jorge
Logged

brentc73
Server what's that
*
Posts: 16


View Profile WWW
« Reply #4 on: 10/01/08, 12:36 »

Hi Jorge,

Yes I am tracing - trace(this["Flink"+i]);
and I do see it in the in the php output as well as the when I test the mc in the variables

Below is the link to the mc (as of now only the first 2 links/thumbs pull from the db) and the php, I removed the iframe for test purposes. You can see when the button is clicked it will show the link as undefined.
I have a custom 404.

http://www.softlineonline.com/New/prod_quickfind_thumbs.php
http://www.softlineonline.com/New/prod_quickfind_thumbs_db2.swf

Please let me know if you see anything.
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #5 on: 10/01/08, 12:46 »

The Loadvars object isolate the scope of the data, so no matters where deep is inside another objects
This line copy the received variable to the MC timeline:

this.ref["b"+i].uri = this.ref["Flink"+i];

This line use this lookup to use the copied data

getURL(this.uri, "iframemain");

So there's no error on the code, should be something contextual (another button uis receiving the event, the object is not an MC but a button, etc)

Jorge
Logged

brentc73
Server what's that
*
Posts: 16


View Profile WWW
« Reply #6 on: 10/01/08, 12:49 »

From my trace I believe it is pointing to right place but I will keep looking.

Thank you, I appreciate all your help!
« Last Edit: 10/01/08, 13:04 by brentc73 » Logged
brentc73
Server what's that
*
Posts: 16


View Profile WWW
« Reply #7 on: 10/01/08, 17:55 »

Did more testing with no luck...
Looks like the variable link is not getting passed to the button mc and I have no idea on how to fix it.

Below is the AS

Code:
myData = new LoadVars();
myData.load("anastasio.php");
myData.ref = this;
myData.onLoad = function(succes){
if(succes){
for(var i=0; i<this.cant; i++){
this.ref["Title_txt"+i].htmlText = "<b>"+this["Fname"+i]+"</b>"
this.ref["holder_mc"+i].loadMovie(this["Fimage"+i])
this.ref["Comments_txt"+i].uri = this.ref["Furl"+i];
this.ref["Comments_txt"+i].onRelease = function() {
getURL(this.uri, "_parent")
}
}
} else trace("Error loading data")
}
stop();

This is the variable trace:

onLoad:[function 'onLoad'],
Fname0:"Abruzzo",                  = Title_txt, vars is coming through.
Furl0:"06glossary_c.php",        = Furl, vars is coming through.
Fimage0:"\\New\\images\\curtains\\Abruzzo_thumb.jpg"    = Fimage, vars is coming through.

Problem is that (with this code - this.ref["Comments_txt"+i].uri = this.ref["Furl"+i];" the Furl var is not being pushed to Comments_txt0 as you can see below.

Movie Clip: Target="_level0.Comments_txt0"
Variable _level0.Comments_txt0.uri = undefined
Variable _level0.Comments_txt0.onRelease = [function 'onRelease']

Anyone else know what it could be?
« Last Edit: 10/01/08, 18:12 by brentc73 » Logged
brentc73
Server what's that
*
Posts: 16


View Profile WWW
« Reply #8 on: 10/01/08, 19:07 »

Hi Jorge,

Thank you for all you help!

Finally got it working

Code:
this.ref["b"+i].uri = this.ref["Flink"+i]

should be

Code:
this.ref["b"+i].uri = this["Flink"+i]

no .ref on the = part.
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #9 on: 10/01/08, 21:51 »

Yep, you're rigth, didn't check carefully.
Nice it works

Jorge
Logged

Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!