PDA

View Full Version : Look Simple But...... Flash/ColdFusion


oleung
05-25-2001, 12:34 AM
Having refer to web site like http://www.flashcfm.com

It seems easy to pass data from coldfusion to flash. But other than post the data to the dynamic text box. Can we use the data that pass from coldfusion to do other thing such as doing calculation or process under actionscripts. I am very frustrate on this.

Having use
loadVariablesNum ("#", 0); in flash to import data. I can't process the field data within action scripts. Can anyone give me help?

Can anyone show me how loadVariablesNum action works? Cause I can't get any help from Flash's actionscripts online help?

Thanks in advance.

Oliver

Jesse
05-25-2001, 06:11 AM
The variables are loaded in as strings by default. So 5 is loaded in as "5" and you can't perform math actions on strings. Assuming you load a variable 'num1' whose loaded value ends up as "5" and another, 'num2' whose loaded value is "24" you can then perform math operations using:

total = Number(num1) + Number(num2)

Cheers

Jesse

oleung
05-25-2001, 06:39 AM
Thanks.

But it seems not so simple.

What happen to string? Say there is a field named "FirstName" and "LastName". Can I use add '+' operator to combined it like :

FullName = FirstName + " " + LastName;

I read from the tutorial that variable is typeless. So it suppose can convert to the corresponding type whenever necessary.

It seems I can only pop the field to the dynamic text box and can't make use of these fields on other process and calculation. No matter string or number.

Oliver

Jesse
05-25-2001, 06:43 AM
Variables in Flash aren't typeless...

The code you gave should work fine:

first = "Jesse"
second = "Startford"

full = first + " " + second

Note that loadVariables is asyncrnous though so you have to wait for the variables to be loaded before you can perform operations on them.

Cheers

Jesse

oleung
05-25-2001, 07:36 AM
You say we have to wait for the variables to be loaded before I can perform operations on them. How long does it takes? How can I assure the variables has been loaded?

For Example:

loadVariablesNum ("#", 0);

//first and second are field name from table
namefull = frist + " " + second


Above code tries to combine first and second together and assign to namefull variable. Then, I have a dynamic text box on the movie which point to namefull. Should this work?

If it should, then I don't know what I have done wrong.

See if you can help me on this. Thanks.

Oliver

Jesse
05-25-2001, 07:56 AM
The best idea is to make all your queries return an extra variable as well as the variables you want. So if they return:

&first=Jesse&second=Stratford

make them also return a standard last variable, loaded=true

&first=Jesse&second=Stratford&loaded=true

Then you can run a loop which tests the loaded variable:

onClipEvent (enterFrame) {
if (_root.loaded != null) {
// vars are loaded
} else {
// not yet loaded
}
}

Cheers

Jesse

oleung
05-25-2001, 08:22 AM
Do you mean I should loop a function from the action script. I will try. Thanks.

Oliver




Then you can run a loop which tests the loaded variable:

onClipEvent (enterFrame) {
if (_root.loaded != null) {
// vars are loaded
} else {
// not yet loaded
}
}

Cheers

Jesse
05-25-2001, 10:02 AM
onClipEvent (enterFrame) actions are run every time a frame is run. So they are aeffectively a loop. If your frame rate is 12 fps, they will be run 12 times per second.

Cheers

Jesse