Flash XML Review midterm Flash XML Presentations Midterm

  • Slides: 21
Download presentation
Flash & XML (Review midterm) Flash & XML Presentations

Flash & XML (Review midterm) Flash & XML Presentations

Midterm 1. Contacts 2. bedtime song 3. All: a) What are reasons to use

Midterm 1. Contacts 2. bedtime song 3. All: a) What are reasons to use xml and xsl to produce a web site? What are reasons NOT to use xml and xsl? b) What are the factors making an HTML site an XHTML site. To put it another way, what do you have to check and, possibly, modify? c) Give reasons pro and con for using graphical icons in interfaces. 4. bbc and purchase sites.

Flash & XML • Flash can open and 'use' an XML file on the

Flash & XML • Flash can open and 'use' an XML file on the server – and create/modify and XML document and send it back to server. • Action is asynchronous: does not happen instantly. Your code sets up the handler for when loading is done. • There is a XML Document Object Model that defines the objects, properties and methods. • Caution: test for tags by name. Extra tags (arising from white space) will be part of document. • Caution: the content of a tag is its first child.

<? xml version="1. 0" ? > <mylist> <contact> <name>Marty Lewinter</name> <email>mathman@purchase. edu</email> </contact> <name>Peter

<? xml version="1. 0" ? > <mylist> <contact> <name>Marty Lewinter</name> <email>mathman@purchase. edu</email> </contact> <name>Peter Ohring</name> <email>peter. ohring@purchase. edu</email> </contact> <name>Joe Skirvanek </name> <email>joes@purvid. purchase. edu </email> </contact> <name>Joel Tenenbaum</name> <email>joel@zephyr. ns. purchase. edu</email> </contact> </mylist>

Action. Script contact. XML=new XML(); contact. XML. on. Load=trans. XML; display 1="loading data"; contact.

Action. Script contact. XML=new XML(); contact. XML. on. Load=trans. XML; display 1="loading data"; contact. XML. load("contacts. xml"); Dynamic text field. function to be defined next.

function trans. XML() { if (this. loaded) { display 1 = "XML data is

function trans. XML() { if (this. loaded) { display 1 = "XML data is loaded. "; } key. Tag = new XML(); last. Child is first contact. List = new Array(); child is mylist key. Tag=this. last. Child; contact. List= key. Tag. child. Nodes; contactdata = new Array(); display = ""; Another dynamic textfield

for (kid = 0; kid<=contact. List. length; kid +=1) { contactdata = contact. List[kid].

for (kid = 0; kid<=contact. List. length; kid +=1) { contactdata = contact. List[kid]. child. Nodes; for (i=0; i<=contactdata. length; i++) { if (contactdata[i]. node. Name=="name") { display = display + newline+ contactdata[i]. firstchild. node. Value; } if (contactdata[i]. node. Name=="email") { display = display+newline + contactdata[i]. firstchild. node. Value; } the contents } (text) of display = display + newline; each node } }

nd 2 Example: soccer results • Similar to first: reading in data from XML

nd 2 Example: soccer results • Similar to first: reading in data from XML • duplicate. Movie. Clip to create places to load. Movie the jpg image files – create an empty movie clip symbol and one instance of it off stage. It is named 'place'. • position duplicate movie clips on stage by setting properties _x and _y of (duplicated) Movie clips.

<? xml version="1. 0" encoding="UTF-8"? > <results group="A"> <match feature="no"> <date>07 -Jun-2002 </date> <team

<? xml version="1. 0" encoding="UTF-8"? > <results group="A"> <match feature="no"> <date>07 -Jun-2002 </date> <team score="3">Spain </team> <team score="1">Paraguay </team> </match> … <match feature="yes"> <date>31 -May-2002 </date> <headline>France loses to Senegal </headline> <story>The 1998 World Cup Champion France lost the opening game to Senegal. It was Senegal's first appearance in a World Cup. This was a stunning upset for France. The team was playing without one of the stars, Zidane. </story> <team score="1">Senegal </team> <team score="0">France </team> <picture>soccer 1. jpg </picture> </match> … </results>

Similar start of Action. Script results. XML=new XML(); results. XML. on. Load=trans. XML; display

Similar start of Action. Script results. XML=new XML(); results. XML. on. Load=trans. XML; display 1="getting data"; results. XML. load("resultsnoref. xml");

Similar start of trans. XML() function trans. XML() { if (this. loaded) { display

Similar start of trans. XML() function trans. XML() { if (this. loaded) { display 1 = "XML data is loaded. "; } key. Tag = new XML(); match. List = new Array(); key. Tag=this. last. Child; match. List= key. Tag. child. Nodes; matchdata = new Array(); ccount = 0; nump = 0; will be display = ""; used for any pictures.

for (m = 0; m<=match. List. length; m +=1) { if (match. List[m]. node.

for (m = 0; m<=match. List. length; m +=1) { if (match. List[m]. node. Name=="match") { ccount++; matchdata = match. List[m]. child. Nodes; for (i=0; i<=matchdata. length; i++) { if (matchdata[i]. node. Name=="team") { display = display + newline+ matchdata[i]. firstchild. node. Value; display = display+": "+matchdata[i]. attributes["score"]; }

if (matchdata[i]. node. Name=="picture") { incremented for each picture nump++; newp = "place"+nump; duplicate.

if (matchdata[i]. node. Name=="picture") { incremented for each picture nump++; newp = "place"+nump; duplicate. Movie. Clip(place, newp, nump); set. Property(newp, _x, 400); set. Property(newp, _y, 10 + 200*(nump-1)); load. Movie(matchdata[i]. firstchild. node. Value, newp); } } display = display + newline; } } display 1="Number of matches: " + ccount; }

Flash: Moving photos http: //newmedia. purchase. edu/~Jeanine/interfaces/xmlstuff. html choose xmlfamily. html Building on previous

Flash: Moving photos http: //newmedia. purchase. edu/~Jeanine/interfaces/xmlstuff. html choose xmlfamily. html Building on previous examples: reads in name, picture file name, and speed creates arrays, including arrays of movie instances holding pictures Looping using frames, move instances by the corresponding speed

<? xml version="1. 0" encoding="UTF-8"? > <scenes> <scene> <name>Winter Piano Party: Esther and Aviva</name>

<? xml version="1. 0" encoding="UTF-8"? > <scenes> <scene> <name>Winter Piano Party: Esther and Aviva</name> <picture>avivagrandma. jpg</picture> <speed>6</speed> </scene> <name>Uday with Amy and her sisters</name> <picture>sisters. jpg</picture> <speed>10</speed> </scene> … </scenes>

for (i=0; i<=matchdata. length; i++) { if (matchdata[i]. node. Name=="picture") { nump++; newp =

for (i=0; i<=matchdata. length; i++) { if (matchdata[i]. node. Name=="picture") { nump++; newp = "place"+nump; duplicate. Movie. Clip(place, newp, nump); set. Property(newp, _y, 10+60*(nump)); set. Property(newp, _x, 200*(nump-1)); load. Movie(matchdata[i]. firstchild. node. Value, newp); stuff. Push(_root[newp]); } if (matchdata[i]. node. Name=="speed") { speeds. Push(Number(matchdata[i]. firstchild. node. Value)); } if (matchdata[i]. node. Name=="name"){ names. Push(matchdata[i]. firstchild. node. Value); } }

frame looping for (i=0; i<stuff. length; i++) { stuff[i]. _x = stuff[i]. _x+speeds[i]; if

frame looping for (i=0; i<stuff. length; i++) { stuff[i]. _x = stuff[i]. _x+speeds[i]; if (stuff[i]. _x>rightbound) { speeds[i]=-speeds[i]; } if (stuff[i]. _x<leftbound) { speeds[i]=-speeds[i]; } } goto. And. Play("loop");

Flash exercise • Optional (if you know some Flash and want to use it

Flash exercise • Optional (if you know some Flash and want to use it for your projects) • Get this example running. Improve graphics. • Use the on-line help to add the headline under any photos. – create a set number of dynamic text fields and limit pictures to that many. – re-position text fields near pictures.

Lab time • Presentations

Lab time • Presentations