Re: [Flashcoders] LoadVars array.length problem
My apologies Muzak, I think I sent my previous answer to your private email; If i forget to change the address, when i click 'replay' to an email, for some strange reasons, this lists uses the originator's address and not the lists', sheesh! any how Thank you for the info. i have tried to access the page but the server must be down at the moment, i will follow up later. In any case, t he reason I want all the info in a database is so that the client can manage/amend/update the content via a dedicated CMS and be totally independent of the developers (me). Meis a ctually a team of three doing a group project (uni project) for a real client who needs total independence at the end. The client and his staff are not programmers at all so I thought, if I use the databse approach I can use the table names to populate my menues and the content of the tables to drive the content of the site as required. Am I on the wrong track completely? As you can see I am not at a level that will afford me any ease during production so any tips are much appreciated. Thanks JohnT Muzak wrote: Heya John, If the data will eventually be coming from a database, don't use XML. See my previous reply on why not to use JSON with a text file ;-) When communicating with a database I'd avoid using XML (and even JSON for that matter). Have a look at Flash Remoting instead which allows you to receive data in a format that Flash understands. For PHP, there's AMFPHP: http://www.amfphp.org Now with all that said, I'm wondering why you'd want to store menu information in a database at all. Storing this in a database doesn't really make sense to me: about us news portfolio regards, Muzak - Original Message - From: "John Trentini" <[EMAIL PROTECTED]> To: Sent: Saturday, May 05, 2007 10:04 AM Subject: Re: [Flashcoders] LoadVars array.length problem That sounds right, even to me, eheheh! I was trying to test my skills with AS. I eventually need to get the data, via PHP, from a database. I suppose I will need to format my php response to produce an xml file but I am quuite new to this and am tentative.. Thanks MuzaK ^_^ JohnT ___ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] LoadVars array.length problem
Heya John, If the data will eventually be coming from a database, don't use XML. See my previous reply on why not to use JSON with a text file ;-) When communicating with a database I'd avoid using XML (and even JSON for that matter). Have a look at Flash Remoting instead which allows you to receive data in a format that Flash understands. For PHP, there's AMFPHP: http://www.amfphp.org Now with all that said, I'm wondering why you'd want to store menu information in a database at all. Storing this in a database doesn't really make sense to me: about us news portfolio regards, Muzak - Original Message - From: "John Trentini" <[EMAIL PROTECTED]> To: Sent: Saturday, May 05, 2007 10:04 AM Subject: Re: [Flashcoders] LoadVars array.length problem > That sounds right, even to me, eheheh! > > I was trying to test my skills with AS. > > I eventually need to get the data, via PHP, from a database. > I suppose I will need to format my php response to produce an xml file but I > am quuite new to this and am tentative.. > > Thanks MuzaK ^_^ > > JohnT ___ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] LoadVars array.length problem
If you're loading data from a file I wouldn't recommend JSON. It's not really readable. JSON is nice for serializing/deserializing data coming from a database or for communicating with for instance Javascript. Not at all for storing data in a text file. Right tool for the job and all that.. regards, Muzak - Original Message - From: "eka" <[EMAIL PROTECTED]> To: Sent: Saturday, May 05, 2007 10:07 AM Subject: Re: [Flashcoders] LoadVars array.length problem > Hello :) > > It's more easy to use JSON ? Xml is more difficult in AS2 ? > > EKA+ :) ___ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] LoadVars array.length problem
Hello :)
It's more easy to use JSON ? Xml is more difficult in AS2 ?
EKA+ :)
2007/5/5, Muzak <[EMAIL PROTECTED]>:
Dump the textfile idea and use XML instead, which is far better suited for
stuff like menu's.
regards,
Muzak
- Original Message -
From: "John Trentini" <[EMAIL PROTECTED]>
To:
Sent: Saturday, May 05, 2007 8:56 AM
Subject: [Flashcoders] LoadVars array.length problem
> Hello,
>
> I am trying to generate two separate menus dynamically and populated by
the content of tow text files.
>
> The text files have the following info.
>
> menuItems.txt contains:
>
>&var1=about us&
>&var2=news&
>&var3=portfolio& etc.
>
> submenuItems.txt contains:
> &var1=branding&
>&var2=interactives&
>&var3=marks& etc.
>
> these will be updateable files with any numbers of elements added to or
removed from.
>
>
> I have this code at the root level:
>
>menuLoadVars = new LoadVars();
>menuLoadVars.load("menuItems.txt");
>
>subMenuLoadVars = new LoadVars();
>subMenuLoadVars.load("submenuItems.txt");
>
> How can I generate an array that only contains the values of each item
if I don't know the length of the text file?
>
> I have tried:
>
>menuItems.onLoad = function(){
>
>for(i=0; itrace(menuItemds[i]);
>
>}
>
>}
>
> but the menuItems.length is undefined and does not return a value.
>
> What can I do instead?
>
> Any tip would be a big help.
> Thanks
>
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
Re: [Flashcoders] LoadVars array.length problem
That sounds right, even to me, eheheh! I was trying to test my skills with AS. I eventually need to get the data, via PHP, from a database. I suppose I will need to format my php response to produce an xml file but I am quuite new to this and am tentative.. Thanks MuzaK ^_^ JohnT ___ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] LoadVars array.length problem
Dump the textfile idea and use XML instead, which is far better suited for
stuff like menu's.
regards,
Muzak
- Original Message -
From: "John Trentini" <[EMAIL PROTECTED]>
To:
Sent: Saturday, May 05, 2007 8:56 AM
Subject: [Flashcoders] LoadVars array.length problem
> Hello,
>
> I am trying to generate two separate menus dynamically and populated by the
> content of tow text files.
>
> The text files have the following info.
>
> menuItems.txt contains:
>
>&var1=about us&
>&var2=news&
>&var3=portfolio& etc.
>
> submenuItems.txt contains:
> &var1=branding&
>&var2=interactives&
>&var3=marks& etc.
>
> these will be updateable files with any numbers of elements added to or
> removed from.
>
>
> I have this code at the root level:
>
>menuLoadVars = new LoadVars();
>menuLoadVars.load("menuItems.txt");
>
>subMenuLoadVars = new LoadVars();
>subMenuLoadVars.load("submenuItems.txt");
>
> How can I generate an array that only contains the values of each item if I
> don't know the length of the text file?
>
> I have tried:
>
>menuItems.onLoad = function(){
>
>for(i=0; itrace(menuItemds[i]);
>
>}
>
>}
>
> but the menuItems.length is undefined and does not return a value.
>
> What can I do instead?
>
> Any tip would be a big help.
> Thanks
>
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
Re: Re: [Flashcoders] LoadVars array.length problem
Hello :)
for me your method is not good :)
Use JSON or Eden format in your external text file.
Example JSON = Javascript Object Notation ( http://json.org/ )
JSON is better to parse Array, Object, String, Boolean, Number ...
You can use JSON with my openSource framework :
http://code.google.com/p/vegas/
Serialize (ActionScript to String ) :
import vegas.string.JSON ;
var a:Array = [2, true, "coucou"] ;
var o:Object = { prop1 : 1 , prop2 : 2 } ;
var s:String = "hello world" ;
var n:Number = 4 ;
var b:Boolean = true ;
trace("* a : " + JSON.serialize( a ) ) ;
trace("* o : " + JSON.serialize( o ) ) ;
trace("* s : " + JSON.serialize( s ) ) ;
trace("* n : " + JSON.serialize( n ) ) ;
trace("* b : " + JSON.serialize( b ) ) ;
Deserialize (String to ActionScript )
import vegas.string.JSON ;
var source:String = '[ { "prop1" : 0xFF , "prop2":2,
"prop3":"hello", "prop4":true} , 2, true, 3, [3, 2] ]' ;
var o = JSON.deserialize(source) ;
var l:Number = o.length ;
for (var i:Number = 0 ; i " + i + " : " + o[i] + " -> typeof :: " + typeof(o[i])) ;
if (typeof(o[i]) == "object")
{
for (var each:String in o[i])
{
trace("> " + each + " : " + o[i][each] + " :: " +
typeof(o[i][each]) ) ;
}
}
}
If your string representation contains an error :
import vegas.string.JSON ;
import vegas.string.errors.JSONError ;
var source:String = "[3, 2," ;
try
{
var o = JSON.deserialize(source) ;
}
catch(e:JSONError)
{
trace( e.toString()) ; // output: [JSONError] Bad Array, at:6 in "[3, 2,"
}
Now.. with a LoadVars :
import vegas.string.JSON ;
var result ;
var loader = new LoadVars() ;
loader.onData = function ( source:String )
{
result = JSON.deserialize(source) ;
trace(result) ;
}
loader.load("data.txt") ;
In your external data.txt you can write an array with the Javascript
notation :
[ 1 , 2 , true, "hello world" , { "prop1" : "value1", "prop2" : "value2" } ,
0xFF ]
To install my framework you can read this page :
http://code.google.com/p/vegas/wiki/InstallVEGASwithSVN
More easy... more speed :)
EKA+ :)
2007/5/5, John Trentini <[EMAIL PROTECTED]>:
Thanks sebastian,
I had tried something like:
menuLoadVars.onLoad = function(){
var my = menuLoadVars.split("\r");
for (var i = 0; ihttp://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
Re: [Flashcoders] LoadVars array.length problem
hmmm, how about first doing a String function to split the text file
into elements of an Array before checking the length of the Array? Just
a thought; but that would probably work. Hopefully you can use the line
return character '\r' as your splitter.
John Trentini wrote:
Hello,
I am trying to generate two separate menus dynamically and populated by
the content of tow text files.
The text files have the following info.
menuItems.txt contains:
&var1=about us&
&var2=news&
&var3=portfolio& etc.
submenuItems.txt contains:
&var1=branding&
&var2=interactives&
&var3=marks& etc.
these will be updateable files with any numbers of elements added to or
removed from.
I have this code at the root level:
menuLoadVars = new LoadVars();
menuLoadVars.load("menuItems.txt");
subMenuLoadVars = new LoadVars();
subMenuLoadVars.load("submenuItems.txt");
How can I generate an array that only contains the values of each item
if I don't know the length of the text file?
I have tried:
menuItems.onLoad = function(){
for(i=0; ihttp://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

