Re: [Flashcoders] Noob, basic questions on actionscript, with methodology suggestions

2006-11-09 Thread Glen Pike

Hi,

   You will need to move external_xml.load call below the onLoad 
function because your file will probably be loaded before the handler is 
defined (locally).


   with trace(myXML) you have defined myXML inside the function - 
this means it is not in scope outside the function.  Try:


 var external_xml:XML = new XML();

  //trace if loaded, or not
 external_xml.onLoad = function(success:Boolean) {
   if (success) {
trace(xml loaded successfully.);
//Do something with the XML in here.
   }  else {
 trace(xml failed to load.);
   } 
};


//variable loads external XML file afterwards
external_xml.load(example1.xml);

trace(external_xml); 



Scott Haneda wrote:

Hi, downloaded Flash, 1st post! w00t! need to work out a small project.  I
have experience in programming, not specifically OOP, and actionscript seems
to be very OOP.  I few questions:

I am loading up some XML per an example:
//ignore whitespace
XML.prototype.ignoreWhite = true;

//create variable and new XML Object
var external_xml:XML = new XML();

//variable loads external XML file
external_xml.load(example1.xml);

//trace if loaded, or not
external_xml.onLoad = function(success:Boolean) {
   if (success) {
 trace(xml loaded successfully.);
 var myXML = external_xml;
   } else {
 trace(xml failed to load.);
   } 
};


trace(myXML); 


What I don't get, it why this needs to be in a function, my experice tells
me you use functions for things you may otherwise need to use again, either
putting the in a file elsewhere, whatever.  It makes no sense to me to
functionize the reading in of XML, why not just approach it procedurally?

And, as you can see, my trace(myXML); does not work, so how would I access
the XML data outside the function, is there a local keyword I am not
finding?

Finally, As for details on what I need to do, to start, as a way to learn
this, I want to get a trace of something to happen:

Load in this XML file:
camps sport=Tennis
state name=California cc=3 url=a/
state name=Oregon cc=13 url=b/
state name=Washington cc=2 url=c/
/camps


I have that much working, I can not figure out how to access each item as of
yet, but did have a plan.  Of course, there will be 50 items in that XML
file.

Each item eventually needs to be hooked up to a map, so each state can some
coloring based on the cc value, and if there is a value for a, I can take
them to that url.

I was going to iterate the XML, and create an assoc array, in which I could
then simply call out each state name, and hopefully get to its parameters.
I can then learn how to hook those  up to each state on the graphic file.

I wonder, do I even need the assoc array idea at all?

So, right now, I need to get myself in a case, where I can do something like
this: trace(xml.state.california[2]) and have it give me a back.  Assuming
0 based lists in ActionScript?  I know my trace statement above is making
you laugh, but as you know, I am hour 1 into this.

Thanks for any handholding.
  

___
Flashcoders@chattyfig.figleaf.com
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] Noob, basic questions on actionscript, with methodology suggestions

2006-11-09 Thread Scott Haneda
 Hi,
 
 You will need to move external_xml.load call below the onLoad
 function because your file will probably be loaded before the handler is
 defined (locally).
 
 with trace(myXML) you have defined myXML inside the function -
 this means it is not in scope outside the function.  Try:
 
   var external_xml:XML = new XML();
 
//trace if loaded, or not
   external_xml.onLoad = function(success:Boolean) {
 if (success) {
 trace(xml loaded successfully.);
 //Do something with the XML in here.
 }  else {
   trace(xml failed to load.);
 } 
  };
 
 //variable loads external XML file afterwards
 external_xml.load(example1.xml);
 
 trace(external_xml);

Thanks, and if my XML looks like this:
Load in this XML file:
camps sport=Tennis
state name=California cc=3 url=a/
state name=Oregon cc=13 url=b/
state name=Washington cc=2 url=c/
/camps

What would be the best way to get myself a set of accessible variables in
which I can call out a state name, and get  the two remaining parameters?
-- 
-
Scott HanedaTel: 415.898.2602
http://www.newgeo.com Novato, CA U.S.A.


___
Flashcoders@chattyfig.figleaf.com
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] Noob, basic questions on actionscript, with methodology suggestions

2006-11-09 Thread Mike Keesey
You have to use a function because the loading is asynchronous. It
doesn't stop program flow while it's loading; it continues with the
program and calls a handler (onLoad) once the load is complete.

I'm not sure this is the proper forum for n00b questions
―
Mike Keesey

___
Flashcoders@chattyfig.figleaf.com
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] Noob, basic questions on actionscript, with methodology suggestions

2006-11-09 Thread Pete Miller
Additionally, the reason you must create a function is because, as you
put it, it is something that one will use again and again.  Not in the
way you understand it however.

The XML class definition knows that there is (should be) a function
called onLoad() that it must call when it successfully loads an XML
file.  It doesn't exist until you write it, but the class nevertheless
expects one to exist.  So, when I say that it is used again and again, I
mean that the XML class, when instantiated by any user, calls onLoad().

The reason you can't do it procedurally is because the load process is
asynchronous.  When you call external_xml.load(example1.xml), you
haven't loaded the entire file, you have merely *started* the load.
When it is finished (depending on the file size, the speed of the hard
drive, the bandwidth of the connection, etc.), then the object calls
onLoad().

I use to trip over this one, calling xml.load() then immediately trying
to use data from the load, forgetting that I needed to wait for the
onLoad() to tell me that it was done.

P.

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:flashcoders-
 [EMAIL PROTECTED] On Behalf Of Glen Pike
 Sent: Thursday, November 09, 2006 4:51 PM
 To: Flashcoders mailing list
 Subject: Re: [Flashcoders] Noob, basic questions on actionscript,with
 methodology suggestions
 
 Hi,
 
 You will need to move external_xml.load call below the onLoad
 function because your file will probably be loaded before the handler
is
 defined (locally).
 
 with trace(myXML) you have defined myXML inside the function -
 this means it is not in scope outside the function.  Try:
 
   var external_xml:XML = new XML();
 
//trace if loaded, or not
   external_xml.onLoad = function(success:Boolean) {
 if (success) {
  trace(xml loaded successfully.);
  //Do something with the XML in here.
 }  else {
   trace(xml failed to load.);
 }
  };
 
 //variable loads external XML file afterwards
 external_xml.load(example1.xml);
 
 trace(external_xml);
 
 
 Scott Haneda wrote:
  Hi, downloaded Flash, 1st post! w00t! need to work out a small
project.
 I
  have experience in programming, not specifically OOP, and
actionscript
 seems
  to be very OOP.  I few questions:
 
  I am loading up some XML per an example:
  //ignore whitespace
  XML.prototype.ignoreWhite = true;
 
  //create variable and new XML Object
  var external_xml:XML = new XML();
 
  //variable loads external XML file
  external_xml.load(example1.xml);
 
  //trace if loaded, or not
  external_xml.onLoad = function(success:Boolean) {
 if (success) {
   trace(xml loaded successfully.);
   var myXML = external_xml;
 } else {
   trace(xml failed to load.);
 }
  };
 
  trace(myXML);
 
  What I don't get, it why this needs to be in a function, my
experice
 tells
  me you use functions for things you may otherwise need to use
again,
 either
  putting the in a file elsewhere, whatever.  It makes no sense to me
to
  functionize the reading in of XML, why not just approach it
 procedurally?
 
  And, as you can see, my trace(myXML); does not work, so how would I
 access
  the XML data outside the function, is there a local keyword I am
not
  finding?
 
  Finally, As for details on what I need to do, to start, as a way to
 learn
  this, I want to get a trace of something to happen:
 
  Load in this XML file:
  camps sport=Tennis
  state name=California cc=3 url=a/
  state name=Oregon cc=13 url=b/
  state name=Washington cc=2 url=c/
  /camps
 
 
  I have that much working, I can not figure out how to access each
item
 as of
  yet, but did have a plan.  Of course, there will be 50 items in
that
 XML
  file.
 
  Each item eventually needs to be hooked up to a map, so each state
can
 some
  coloring based on the cc value, and if there is a value for a, I
can
 take
  them to that url.
 
  I was going to iterate the XML, and create an assoc array, in which
I
 could
  then simply call out each state name, and hopefully get to its
 parameters.
  I can then learn how to hook those  up to each state on the graphic
 file.
 
  I wonder, do I even need the assoc array idea at all?
 
  So, right now, I need to get myself in a case, where I can do
something
 like
  this: trace(xml.state.california[2]) and have it give me a back.
 Assuming
  0 based lists in ActionScript?  I know my trace statement above is
 making
  you laugh, but as you know, I am hour 1 into this.
 
  Thanks for any handholding.
 
 ___
 Flashcoders@chattyfig.figleaf.com
 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
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options

Re: [Flashcoders] Noob, basic questions on actionscript, with methodology suggestions

2006-11-09 Thread Glen Pike

Hi,

   Apologies, I missed your other question:

   You can extend the XML object to include a reference to its parent - 
which would contain a function that allowed you to parse it and do 
things with your movie, like so:


 var external_xml:XML = new XML();

 external_xml.parent = this;

 function xmlHandler(success:Boolean) {
   if(success) }
//Do stuff with external_xml here.
//it's not quite external_xml.state.california[2], you will have to 
walk your XML tree.
//have a look at the documentation for XMLNode - childNodes, 
firstNode and attributes should help
} else {
trace(xml failed to load.);
}
 }

 external_xml.onLoad = function(success:Boolean) {
parent.xmlHandler(success);
 }

  
   Glen

___
Flashcoders@chattyfig.figleaf.com
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] Noob, basic questions on actionscript, with methodology suggestions

2006-11-09 Thread Scott Haneda
 Hi,
 
 You will need to move external_xml.load call below the onLoad
 function because your file will probably be loaded before the handler is
 defined (locally).
 
 with trace(myXML) you have defined myXML inside the function -
 this means it is not in scope outside the function.  Try:
 
   var external_xml:XML = new XML();
 
//trace if loaded, or not
   external_xml.onLoad = function(success:Boolean) {
 if (success) {
 trace(xml loaded successfully.);
 //Do something with the XML in here.
 }  else {
   trace(xml failed to load.);
 } 
  };
 
 //variable loads external XML file afterwards
 external_xml.load(example1.xml);
 
 trace(external_xml);

I get nothing at all on the final trace, not null, not undefined, just
blank.
-- 
-
Scott HanedaTel: 415.898.2602
http://www.newgeo.com Novato, CA U.S.A.


___
Flashcoders@chattyfig.figleaf.com
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] Noob, basic questions on actionscript, with methodology suggestions

2006-11-09 Thread Scott Haneda
 You have to use a function because the loading is asynchronous. It
 doesn't stop program flow while it's loading; it continues with the
 program and calls a handler (onLoad) once the load is complete.

Thanks, I understand that part now.

 I'm not sure this is the proper forum for n00b questions

If I am in the wrong forum, please point me to the correct one, Its called
Flashcoders mailing list, so I thought that was what this was about.  If I
just jump into a general flash mailing list, I don't know what help I will
get, this is pure actionscript more or less.

At any rate, point me to the correct mail list and I will be there, thanks
again.
-- 
-
Scott HanedaTel: 415.898.2602
http://www.newgeo.com Novato, CA U.S.A.


___
Flashcoders@chattyfig.figleaf.com
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] Noob, basic questions on actionscript, with methodology suggestions

2006-11-09 Thread Scott Haneda
 I use to trip over this one, calling xml.load() then immediately trying
 to use data from the load, forgetting that I needed to wait for the
 onLoad() to tell me that it was done.

Thanks you as well, at least I am not the first to trip up on this, its a
bit wonky coming from other languages, then again, the way in which flash
works, and interacts with the user, I can understand how this is the only
way.
-- 
-
Scott HanedaTel: 415.898.2602
http://www.newgeo.com Novato, CA U.S.A.


___
Flashcoders@chattyfig.figleaf.com
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] Noob, basic questions on actionscript, with methodology suggestions

2006-11-09 Thread Pete Miller
I wuz a noob once.  I cured it by hanging out with non-noobs.

P.

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:flashcoders-
 [EMAIL PROTECTED] On Behalf Of Merrill, Jason
 Sent: Thursday, November 09, 2006 5:36 PM
 To: Flashcoders mailing list
 Subject: RE: [Flashcoders] Noob, basic questions on actionscript,with
 methodology suggestions
 
 There is Flashnewbies, but any Actionscript question is supposed to
be
 welcome here.  Don't listen, they're just grumpy. :)
 
 Jason Merrill
 Bank of America
 Learning  Organizational Effectiveness
 
 
 
 
 
 
 -Original Message-
 From: [EMAIL PROTECTED]
[mailto:flashcoders-
 [EMAIL PROTECTED] On Behalf Of Scott Haneda
 Sent: Thursday, November 09, 2006 5:16 PM
 To: Flashcoders mailing list; Mike Keesey
 Subject: Re: [Flashcoders] Noob, basic questions on actionscript,
with
 methodology suggestions
 
  You have to use a function because the loading is asynchronous.
It
  doesn't stop program flow while it's loading; it continues with
the
  program and calls a handler (onLoad) once the load is complete.
 
 Thanks, I understand that part now.
 
  I'm not sure this is the proper forum for n00b questions
 
 If I am in the wrong forum, please point me to the correct one, Its
 called
 Flashcoders mailing list, so I thought that was what this was
about.
 If I
 just jump into a general flash mailing list, I don't know what help
I
 will
 get, this is pure actionscript more or less.
 
 At any rate, point me to the correct mail list and I will be there,
 thanks
 again.
 --
 -
 Scott HanedaTel: 415.898.2602
 http://www.newgeo.com Novato, CA U.S.A.
 
 
 ___
 Flashcoders@chattyfig.figleaf.com
 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
 ___
 Flashcoders@chattyfig.figleaf.com
 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
___
Flashcoders@chattyfig.figleaf.com
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] Noob, basic questions on actionscript, with methodology suggestions

2006-11-09 Thread Scott Haneda
 I wuz a noob once.  I cured it by hanging out with non-noobs.

Thanks, I tend to agree, however, I will move to the flash beginners mail
list, I just hope there are people there who are not as lost as me, as that
probably wont help :-)

-- 
-
Scott HanedaTel: 415.898.2602
http://www.newgeo.com Novato, CA U.S.A.


___
Flashcoders@chattyfig.figleaf.com
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