PDA

Click to See Complete Forum and Search --> : Flashcom Database Records



faeryking
09-19-2002, 09:16 PM
I understand how to set a connection.

Is there a tutorial or a someone who can explain how you do the following basic interactions with flashcom.

1. Create a record structure
2. List record structure
3. Search records
4. Delete records
5. Update recrods
6. List records

I have search all over the net and I only bit and pieces of how do this stuff. I mean I know sql but these basic calls are pretty important and I can't find a good tutorial on how to do them.

If anyone know how to do these or can send me to a tutorial it would be great appreciated.

Thanks
Chris

psychlonex
09-19-2002, 10:18 PM
Hey -
You'll need to use remoting or possibly a middleware of some sort. I haven't messed with getting data into a database from the comserver yet, but it's defintely made for flash remoting. I've no idea if there is a server-side equivilent(sp?) to "loadVars" in flashcom for use with things like php, etc.

If your structure isn't overly complex, or simply too big for flash, then I think you could do it using a shared-object (or a few) to act as your database. Then it's simply a matter of writing the functions to do all the things you want it to do. Set your so's to be persistent and define the structure. I'm going to have to fool with this anyway someday soon here.. I'll try to post my progress if I have any success.

Psx

faeryking
09-20-2002, 03:10 PM
Actually you can turn objects into minture databases on Flashcom server. For example:

//+
// Add the entry to the remote shared object: _root.so.data[index]
// The _root.so shared-object is an array of objects
// Each object has the following fields:
// title.......the entry title
// date........the entry date and time, automatically calculated
// text........[the entry text|"null"]
// AVType......["null"|"AV"|"audio"]
// streamName..["null"|an unique id for the stream]
//-
function processEntry(index)
{
var userTitle = _root.newEntry_mc.entry_title.text;
var userDateTime = _root.newEntry_mc.entry_datetime.text;

switch (_root.newEntryType) {
case "textonly":
var userText = _root.newEntry_mc.entry.entry_text.text;
_root.entries_so.data[index] = {title:userTitle, date:userDateTime, text:userText, AVType:"null", streamName:"null"};
break;
case "textav":
var userText = _root.newEntry_mc.entry.entry_text.text;
var userStreamName = _root.newEntry_mc.entry.entry_streamname;
_root.entries_so.data[index] = {title:userTitle, date:userDateTime, text:userText, AVType:"AV", streamName:userStreamName};
break;
case "textaudio":
var userText = _root.newEntry_mc.entry.entry_text.text;
var userStreamName = _root.newEntry_mc.entry.entry_streamname;
_root.entries_so.data[index] = {title:userTitle, date:userDateTime, text:userText, AVType:"audio", streamName:userStreamName};
break;
case "avonly":
var userStreamName = _root.newEntry_mc.entry.entry_streamname;
_root.entries_so.data[index] = {title:userTitle, date:userDateTime, text:"null", AVType:"AV", streamName:userStreamName};
break;
case "audioonly":
var userStreamName = _root.newEntry_mc.entry.entry_streamname;
_root.entries_so.data[index] = {title:userTitle, date:userDateTime, text:"null", AVType:"audio", streamName:userStreamName};
break;
default:
//trace("Unknown entry type. Weird!");
}

//debugging
//trace("["+_root.newEntryType+"] title: "+userTitle+", date: "+userDateTime+", text: "+userText+", streamName: "+userStreamName);

_root.newEntry_mc.RemoveMovieClip();
_root.textcbox.setValue(false);
_root.avcbox.setValue(false);
_root.addBut.setEnabled(false);

gotoAndStop("guestBook");
}

//+
// Call the server to get the number of the next available slot.
// This avoids conflicts if two users try to add an entry at the same time.
//-
function doAddEntry()
{
function EntryResult(targetObject)
{
this.targetObject = targetObject;

this.onResult = function(result)
{
//trace("last entry = " + result);
this.targetObject.processEntry(result + 1);
}
}

_root.main_nc.call("getEntryIndex", new EntryResult(this));
}

Aware0
09-20-2002, 11:32 PM
yes yes...do that...or go get ColdFusion MX, learn how to use CFC's then do it that way.

Isn't that what CFMX was designed to do in the first place?

:: Sidenote ::

YAY!!! people are using the switch/case stuff now! awsome