Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to create dynamic button that displays database text?

Status
Not open for further replies.

iostream71

Programmer
Mar 13, 2002
229
US
i'm trying to create dynamic buttons that can load news text from my database. basically, each button would represent a news post and pull it from the database. the algorithm i thought of is something like:

-count x posts in database
-duplicate x buttons for each post
(assign newsID from news database to button while creating it)
-when user clicks button, grab same newsID from database and write to text field

hope that makes sense :p
 
where is the the db ?
straightforward if php, xml, text file bur different methods for all
might help if you gave more info as to what you are seeking to do? are buttons the best way? maybe a list/combobox ?
 
the databse is hosted and i'm using php. i know how to write querries fine. i just don't know the flash commands to do it dynamically.

let me try to make clearer...

x x x x x x x
x x x x x x x
x x x x x x x

imagine those ^ are squares and you click on them to retrieve a news item from the database which is displayed in a text box below

the site is pixel-werx.com then click on about to see



 
ok, i got it to do what i want, sort of
(i hardcoded the id for testing)

button1.duplicateMovieClip('button2', 1);
button2.newsID = 1;
//newsID is index to pull news item from database
newsID = button2.newsID;
button2.onPress = function(){
loadVariables("news3.php","", "POST");
//newsContainer is my dynamic text field
newsContainer = news;
}

it works like i expect, except i have to click the button twice to work....any idea why?. click the button in the bottom corner to test:
 
figured out why i was having to click twice....needed to add an onclipevent(data) to the newsContainer clip
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top