<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Flash and PHP</title>
	<atom:link href="http://jesperfriis.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://jesperfriis.wordpress.com</link>
	<description>Specialiserings projekt af Jesper Friis (MMD)</description>
	<lastBuildDate>Wed, 01 Apr 2009 19:24:10 +0000</lastBuildDate>
	<language>da</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='jesperfriis.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Flash and PHP</title>
		<link>http://jesperfriis.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://jesperfriis.wordpress.com/osd.xml" title="Flash and PHP" />
	<atom:link rel='hub' href='http://jesperfriis.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Procesevaluering</title>
		<link>http://jesperfriis.wordpress.com/2009/04/01/procesevaluering/</link>
		<comments>http://jesperfriis.wordpress.com/2009/04/01/procesevaluering/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 19:24:10 +0000</pubDate>
		<dc:creator>jesperfriis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jesperfriis.wordpress.com/?p=116</guid>
		<description><![CDATA[Den måde jeg har lært mest på i dette projekt, er bl.a., at jeg har tvunget mig selv til at kommentere og forstå næsten al koden både AS3, PHP og MySQL.Jeg har også haft det udgangspunkt, at jeg selv skulle oploade applikationerne til enten min localhost eller egen webserver på nettet og få dem til [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=116&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><!--[if gte mso 9]&gt;  Normal 0   21   false false false  DA X-NONE X-NONE              MicrosoftInternetExplorer4              &lt;![endif]--><!--[if gte mso 9]&gt;                                                                                                                                            &lt;![endif]--><!--  /* Font Definitions */  @font-face 	{font-family:"Cambria Math"; 	panose-1:2 4 5 3 5 4 6 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face 	{font-family:Calibri; 	panose-1:2 15 5 2 2 2 4 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1073750139 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-unhide:no; 	mso-style-qformat:yes; 	mso-style-parent:""; 	margin:0cm; 	margin-bottom:.0001pt; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi; 	mso-fareast-language:EN-US;} .MsoChpDefault 	{mso-style-type:export-only; 	mso-default-props:yes; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi; 	mso-fareast-language:EN-US;} .MsoPapDefault 	{mso-style-type:export-only; 	line-height:115%;} @page Section1 	{size:595.3pt 841.9pt; 	margin:3.0cm 2.0cm 3.0cm 2.0cm; 	mso-header-margin:35.4pt; 	mso-footer-margin:35.4pt; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --><!--[if gte mso 10]&gt; &lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Tabel - Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-priority:99; 	mso-style-qformat:yes; 	mso-style-parent:""; 	mso-padding-alt:0cm 5.4pt 0cm 5.4pt; 	mso-para-margin:0cm; 	mso-para-margin-bottom:.0001pt; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-theme-font:minor-fareast; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin;} --> <!--[endif]--></p>
<p class="MsoNormal">Den måde jeg har lært mest på i dette projekt, er bl.a., at jeg har tvunget mig selv til at kommentere og forstå næsten al koden både AS3, PHP og MySQL.Jeg har også haft det udgangspunkt, at jeg selv skulle oploade applikationerne til enten min localhost eller egen webserver på nettet og få dem til at virke. På denne måde har jeg været tvunget til at arbejde med en MySQL database, min webserver samt forbindelsen mellem disse.Hvis jeg ikke har kunnet få noget til at virke, hvilket tit skete, undersøgte jeg det på forskellig vis indtil jeg fandt løsningen. Dette lærte jeg meget af, fordi jeg var tvunget til at forstå koden fuldt ud for at kunne lokalisere, hvor fejlen evt. kunne være.Men som man kan se og læse om, så har jeg alligevel ikke fået alle applikationer til at virke fuldt ud. Men det har så for det meste også været fordi, at jeg er stødt ind i nogle problemer, jeg ikke lige har haft overskud til at undersøge nærmere, da ville tage fokus væk fra det, jeg havde som udgangspunkt at undersøge. Det gode er jo at få en viden om, hvilke ting man så skal undersøge nærmere for at komme videre næste gang, når det er selve applikationen, der er i fokus.Jeg har selvfølgelig også lært meget af de beskrivelser og forklaringer, der har været af koden til applikationerne i bogen og den generelle beskrivelse af både AS3, PHP og MySQL. Men jeg har også lært meget ved at se tutorials, der beskriver koderne.Sidst har det også været godt at skulle skrive om projektet og videns dele mine erfaringer på en blog. Det har også været med til at jeg har skullet forstå tingene fuldt ud, før jeg kunne skrive om dem, samt at det har været med til, at jeg har skullet producere noget hver dag, så jeg kunne skrive om det på bloggen.Jeg synes det gode ved at følge en bog hele vejen, er at man gentager en masse øvelser igen og igen og derved forstår mere og mere, samtidig med at det selvfølgelig også bliver sværere og sværere, så man også lære noget nyt.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jesperfriis.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jesperfriis.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jesperfriis.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jesperfriis.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jesperfriis.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jesperfriis.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jesperfriis.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jesperfriis.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jesperfriis.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jesperfriis.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jesperfriis.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jesperfriis.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jesperfriis.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jesperfriis.wordpress.com/116/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=116&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jesperfriis.wordpress.com/2009/04/01/procesevaluering/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c0ef281313c27323cbad18a6446945bc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">jesperfriis</media:title>
		</media:content>
	</item>
		<item>
		<title>File editor (lille cms system!)</title>
		<link>http://jesperfriis.wordpress.com/2009/03/26/file-editor-lille-cms-system/</link>
		<comments>http://jesperfriis.wordpress.com/2009/03/26/file-editor-lille-cms-system/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 13:41:47 +0000</pubDate>
		<dc:creator>jesperfriis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jesperfriis.wordpress.com/?p=104</guid>
		<description><![CDATA[I dag har jeg kigget på en &#8220;file editor&#8221; applikation. Det er også, hvad man måske kan kalde et meget lille CMS system (content managment system). Denne file editor lader dig ændre i en af de tre tekst filer og gemme det i en mappe på serveren. Næste gang man så loader filen, er den [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=104&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div>I dag har jeg kigget på en &#8220;file editor&#8221; applikation. Det er også, hvad man måske kan kalde et meget lille CMS system (content managment system). Denne file editor lader dig ændre i en af de tre tekst filer og gemme det i en mappe på serveren. Næste gang man så loader filen, er den ændret. Dette foregår ved hjælp af  AS3 koden, der kalder et PHP script, der alt efter om man vil &#8220;loade&#8221; en fil eller &#8220;save&#8221; en ændring i teksten, henter den ønskede tekst fil i en tekst mappe, der selfølgelig også er at finde på serveren, og enten redigerer i den og sender den tilbage til Flash, eller bare sender den tibage, som den var.</div>
<div>Man har også mulighed for at &#8220;reset&#8221; det,  man har ændret i teksten, inden man trykker på &#8220;save&#8221; knappen. Dette foregår i AS3 koden, der &#8220;cacher&#8221; (opfanger og gemmer), den tekst der bliver skrevet i tekstfeltet.</div>
<div>I et større CMS system ville man normalt have langt flere funktioner at vælge mellem bl.a. en &#8220;delete&#8221; og &#8220;move&#8221; funktion, samt at der vil være mange flere muligheder end kun at rette og skrive tekst. Der skulle også være langt større sikkerhed omkring dataen, der bliver udvekslet mellem applikationen og serveren, samt et login system. Samtidig ville de fleste cms systemer gøre brug af en database til at opbevare de forskellige filer.</div>
<div>Det ville også være en god ide, at give brugeren besked, når system er i gang med at save og loade filer.</div>
<div>Men ved hjælp af denne lille applikation synes jeg, man får et godt billede af, hvordan man laver og bruger et sådan system, og samtidig også kan se de store fordele, der er ved, at brugeren selv kan opdatere indholdet i sin flash applikation.</div>
<div>Men som man nok kan regne ud, er det en større opgave at gå i gang med et rigtigt cms system!</div>
<div>File editoren kan ses og prøves på:<a href="http://jesperf.dk/flashandphp/file_editor/index.html" target="_blank"> http://jesperf.dk/flashandphp/file_editor/index.html</a></div>
<div>Og her kommer koden:</div>
<div>AS3:</div>
<div>//path to the php file<br />
<span style="color:#ff0000;">var phpFile:String = &#8220;http://jesperf.dk/flashandphp/file_editor/fileEditor.php&#8221;;</span><br />
// and defining the variables to be used<br />
<span style="color:#ff0000;">var files:Array = ['sample.txt', 'anotherfile.txt', 'readme.txt'];<br />
var storedFileData:String;<br />
</span><br />
// responsible for populating the file list comboBox<br />
<span style="color:#ff0000;">function populateFileList():void<br />
{</span><br />
// by going through the &#8220;files&#8221; array<br />
<span style="color:#ff0000;"> for(var i:uint=0; i &lt; files.length; i++)<br />
{</span><br />
// add the items to the list using a for loop<br />
<span style="color:#ff0000;"> fileListCombo.addItem({label:files[i], data:files[i]});<br />
}<br />
}</span>//The method loadFile is called when the loadbtn is clicked. this handler sets up a file request<br />
// &#8211; with a file variable that PHP uses to load the actual file<br />
<span style="color:#ff0000;">function loadFile(e:MouseEvent):void<br />
{</span><br />
<span style="color:#ff0000;"> var variables:URLVariables = new URLVariables();</span><br />
// the selected file from the list is sent to PHP as a variable request<br />
<span style="color:#ff0000;"> variables.file = fileListCombo.selectedItem.data;</span></p>
<p><span style="color:#ff0000;"> var urlRequest:URLRequest = new URLRequest(phpFile);<br />
urlRequest.data = variables;</span></p>
<p>// loads the requested file from PHP<br />
<span style="color:#ff0000;"> var urlLoader:URLLoader = new URLLoader();</span><br />
// calls the fileLoaded function when the load is complete<br />
<span style="color:#ff0000;"> urlLoader.addEventListener(Event.COMPLETE, fileLoaded);<br />
urlLoader.load(urlRequest);<br />
}</span><br />
<span style="color:#ff0000;"><br />
function fileLoaded(e:Event):void<br />
{</span><br />
<span style="color:#ff0000;"> var urlLoader:URLLoader = URLLoader(e.target);<br />
var variables:URLVariables = new URLVariables(urlLoader.data);</span></p>
<p>// the loaded data is sent into the bodyTxt textArea<br />
<span style="color:#ff0000;"> bodyTxt.text = unescape(variables.fileContents);</span><br />
// &#8211; and also to the storedFileData variable<br />
// this variable is used to cache the unmodified results.<br />
// -You can revert to these results later by clicking the reset button<br />
<span style="color:#ff0000;"> storedFileData = bodyTxt.text;<br />
}</span></p>
<p><span style="color:#ff0000;">function resetHandler(e:MouseEvent):void<br />
{</span><br />
//this function simply replaces the text in the text area with the stored text<br />
<span style="color:#ff0000;"> bodyTxt.text = storedFileData;<br />
}</span></p>
<p>// the last function is responsible for saving the edited content.<br />
// Before the data is saved, it is cached ,which eliminates the need to reload the data<br />
<span style="color:#ff0000;">function saveHandler(e:MouseEvent):void<br />
{</span><br />
// the text written is stored in the storedFileData variable<br />
<span style="color:#ff0000;"> var body:String = bodyTxt.text;<br />
storedFileData = body;</span></p>
<p>// calls PHP with the variables containing the action &#8220;save&#8221; and the bodyTxt<br />
<span style="color:#ff0000;"> var variables:URLVariables = new URLVariables();<br />
variables.file = fileListCombo.selectedItem.data;<br />
variables.action = &#8220;save&#8221;;<br />
variables.fileContents = body;</span></p>
<p><span style="color:#ff0000;">var urlRequest:URLRequest = new URLRequest(phpFile);</span><br />
<span style="color:#ff0000;">urlRequest.data = variables;</span></p>
<p><span style="color:#ff0000;">var urlLoader:URLLoader = new URLLoader();<br />
urlLoader.load(urlRequest);<br />
}</span></p>
<p>//the click on the different buttons calls the different functions<br />
<span style="color:#ff0000;">loadFileBtn.addEventListener(MouseEvent.CLICK, loadFile);<br />
saveBtn.addEventListener(MouseEvent.CLICK, saveHandler);<br />
resetBtn.addEventListener(MouseEvent.CLICK, resetHandler);</span></p>
<p>// calls the populateFileList function so the list is populated<br />
<span style="color:#ff0000;">populateFileList();</span></div>
<div>PHP&#8217;en:</div>
<div><span style="color:#0000ff;">&lt;?phperror_reporting(0);</p>
<p></span>// check for valid file because whether you are saving or loading you need a valid file<br />
// this application doesn&#8217;t have a delete og move action as you probably would in a bigger real world application<br />
<span style="color:#0000ff;">if(!empty($_GET['file']))<br />
{</span><br />
// path to the folder with the different files<br />
<span style="color:#0000ff;"> $file = &#8216;./files/&#8217; . $_GET['file'];</span></p>
<p>// the save action is responsible for loading the requested file, replacing the existing text, and finally resaving the file<br />
// this example doesn&#8217;t focus on security so checking for valid characters and other security stuff is let out<br />
<span style="color:#0000ff;"> if($_GET['action'] == &#8216;save&#8217;)<br />
{</span><br />
// the variable $fileContents is retrieved from the GET data sent by Flash<br />
<span style="color:#0000ff;"> $fileContents = $_GET['fileContents'];</span></p>
<p>// the file  is loaded using fopen() with write access to overwrite<br />
<span style="color:#0000ff;"> $handle = fopen($file, &#8216;w+&#8217;);</span><br />
// once the file is loaded a call to fwrite() is made, which actually writes the content to the file and saves the file<br />
<span style="color:#0000ff;"> fwrite($handle, $fileContents);</span><br />
// last step of the save action is to close the file resource and free up teh memory<br />
<span style="color:#0000ff;"> fclose($handle);<br />
}</span><br />
// the loading of a file is much easier. Just reference the file and load the contents using file_get_contents<br />
// &#8211; which returns the entire file as a string<br />
<span style="color:#0000ff;"> else<br />
{<br />
$loadedFile = file_get_contents($file);<br />
print &#8220;fileContentsq=&#8221; . $loadedFile;<br />
}<br />
}</span></p>
<p><span style="color:#0000ff;">?&gt;</span></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jesperfriis.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jesperfriis.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jesperfriis.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jesperfriis.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jesperfriis.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jesperfriis.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jesperfriis.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jesperfriis.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jesperfriis.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jesperfriis.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jesperfriis.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jesperfriis.wordpress.com/104/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jesperfriis.wordpress.com/104/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jesperfriis.wordpress.com/104/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=104&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jesperfriis.wordpress.com/2009/03/26/file-editor-lille-cms-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c0ef281313c27323cbad18a6446945bc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">jesperfriis</media:title>
		</media:content>
	</item>
		<item>
		<title>Videoplayer</title>
		<link>http://jesperfriis.wordpress.com/2009/03/25/videoplayer/</link>
		<comments>http://jesperfriis.wordpress.com/2009/03/25/videoplayer/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 15:08:35 +0000</pubDate>
		<dc:creator>jesperfriis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jesperfriis.wordpress.com/?p=95</guid>
		<description><![CDATA[Video afspillere bliver mere og mere populære eftersom, at internettet bliver hurtigere og hurtigere. Flash har en indbygget videoplayer component og ved hjlæp af denne og en ComboBox component har jeg i denne applikation lavet en video afspiller, der kommunikere med PHP som sender et XML objekt tilbage til swf. filen, som på denne måde [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=95&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Video afspillere bliver mere og mere populære eftersom, at internettet bliver hurtigere og hurtigere. Flash har en indbygget videoplayer component og ved hjlæp af denne og en ComboBox component har jeg i denne applikation lavet en video afspiller, der kommunikere med PHP som sender et XML objekt tilbage til swf. filen, som på denne måde ved, hvormange videoer der er at vælge imellem fra video listen, samt at den via XML&#8217;en kan finde ud af URL&#8217;en til netop den video, man vælger at se fra video listen. Man kan desværre kun se 1 video fra listen, da den ikke vil loade en ny. Men videoen er alligevel den samme allesammen, så det gør nok ikke så meget! Det ville den dog gerne på min localhost server, så endnu engang er det lidt mærkeligt, hvad der sker, når jeg uploader tingene på min rigtig server.</p>
<p>Applikationen kan ses her: <a href="http://jesperf.dk/flashandphp/video/index.html" target="_blank">http://jesperf.dk/flashandphp/video/index.html</a></p>
<p>Her kommer koden, først AS3:</p>
<p><span style="color:#ff0000;">package<br />
{</span><br />
// imports the nescesary classes<br />
<span style="color:#ff0000;"> import flash.display.MovieClip;<br />
import flash.events.*;<br />
import flash.net.URLVariables;<br />
import flash.net.URLRequest;<br />
import flash.net.URLLoader;</span><br />
<span style="color:#ff0000;"> import flash.media.Video;<br />
public class VideoPlayer extends MovieClip<br />
{</span><br />
// the path to the pphp file<span style="color:#ff0000;"><br />
public var phpFile:String = &#8220;http://jesperf.dk/flashandphp/video/videoManager.php&#8221;;</span></p>
<p>// creates a variable to hold the videoplayer object. It uses the FLVPlayback class which are located in the library<br />
<span style="color:#ff0000;"> private var _player:FLVPlayback;</span></p>
<p><span style="color:#ff0000;">public function VideoPlayer()<br />
{</span><br />
// sets the variable equal to the &#8220;player&#8221; instance on the stage<br />
<span style="color:#ff0000;"> _player = this['player'];</span><br />
// put an event listener to the videoListCombo instance(instance of ComboBox) on the stage and when its clicked it calls the comboHandler function<br />
<span style="color:#ff0000;"> this['videoListCombo'].addEventListener(Event.CHANGE, comboHandler);</span></p>
<p>// calls the loadData function<br />
<span style="color:#ff0000;"> loadData();<br />
}</span></p>
<p>//calls the php file and loads the video data (urlvariables) which is returned in XML format<br />
<span style="color:#ff0000;"> public function loadData():void<br />
{</span><br />
//<br />
<span style="color:#ff0000;"> var urlVariables:URLVariables = new URLVariables;</span><br />
// the request send along to php with the get method is &#8220;getvideos&#8221; which is send as the variable &#8220;a&#8221;<br />
<span style="color:#ff0000;"> urlVariables.a = &#8220;getvideos&#8221;;</span></p>
<p><span style="color:#ff0000;"> var urlRequest:URLRequest = new URLRequest(phpFile);<br />
<span style="color:#ff0000;"> urlRequest.data = urlVariabl</span></span><span style="color:#ff0000;">es;</span></p>
<p>// when the data is fully loaded it calls the dataLoaded function<br />
<span style="color:#ff0000;"> var urlLoader:URLLoader = new URLLoader();<br />
urlLoader.addEventListener(Event.COMPLETE, dataLoaded);</span><br />
<span style="color:#ff0000;"> urlLoader.load(urlRequest);<br />
}</span></p>
<p>// this function makes the loaded XML inta a valid xml object for flash to work with<br />
<span style="color:#ff0000;"> private function dataLoaded(e:Event):void<br />
{</span><br />
<span style="color:#ff0000;"> var urlLoader:URLLoader = URLLoader(e.target);<br />
var xml:XML = new XML(urlLoader.data);<br />
trace(xml);</span><br />
//add an item to the &#8220;videoListCombo&#8221;&#8216;s list<br />
<span style="color:#ff0000;"> this['videoListCombo'].addItem({label:&#8217;Choose Video&#8230;&#8217;, data:1});</span><br />
// going through the xml and adds the video items to the &#8220;videoListCombo&#8221;&#8216;s list<br />
<span style="color:#ff0000;"> for each(var item in xml..video)<br />
{</span><br />
// makes the variables to refer to when you click in the video list<br />
<span style="color:#ff0000;"> var name:String = item..attribute(&#8216;name&#8217;);<br />
var src:String = item..attribute(&#8216;src&#8217;);</span></p>
<p>// adds the variables to the list each time the loop goes through the xml<br />
<span style="color:#ff0000;"> this['videoListCombo'].addItem({label:name, data:src});<br />
}<br />
}</span></p>
<p><span style="color:#ff0000;">private function comboHandler(e:Event):void<br />
{</span><br />
//only if a valid data value is found the video is loaded<br />
<span style="color:#ff0000;"> if(e.target.selectedItem.data == -1) return;</span><br />
// writes to the output panel which video you load<br />
<span style="color:#ff0000;"> trace(&#8220;Load Video: &#8221; + e.target.selectedItem.data);</span><br />
//the string that specifies the URL of the FLV file to stream and how to stream it when you click an item in the list.<br />
<span style="color:#ff0000;"> _player.source = &#8216;videos/&#8217; + e.target.selectedItem.data;<br />
}<br />
}<br />
}</span></p>
<p><span style="color:#ff0000;"><span style="color:#000000;">Her PHP&#8217;en:</span></span></p>
<p><span style="color:#ff0000;"><span style="color:#000000;"><span style="color:#0000ff;">&lt;?php</span></span></span></p>
<p>// this variable snaps the urlvariable send with the get method from flash if its set<br />
<span style="color:#0000ff;">$action = (isset($_GET['a'])); </span></p>
<p>// the array of videos. Its a static array but one could easily use a MySQL database instead<br />
<span style="color:#0000ff;">$videos = array(<br />
array(&#8220;Sample Video 1&#8243;, &#8220;color.flv&#8221;, 0),<br />
array(&#8220;Sample Video 2&#8243;, &#8220;color.flv&#8221;, 0),</span><br />
<span style="color:#0000ff;"> array(&#8220;Sample Video 3&#8243;, &#8220;color.flv&#8221;, 0),<br />
array(&#8220;Sample Video 4&#8243;, &#8220;color.flv&#8221;, 0),<br />
array(&#8220;Sample Video 5&#8243;, &#8220;color.flv&#8221;, 0),<br />
array(&#8220;Sample Video 6&#8243;, &#8220;color.flv&#8221;, 0)<br />
);</span></p>
<p>// if the urlvariable sent from flash is equal to &#8220;getvideos&#8221;<br />
// &#8211; the video list is retrieved and a XML object is build to be passsed back to flash<br />
<span style="color:#0000ff;">if($action == &#8220;getvideos&#8221;)<br />
{<br />
$xml = &#8220;&lt;videos&gt;&#8221;;<br />
for($i=0; $i &lt; count($videos); $i++)<br />
{<br />
$xml .= &#8220;\t&lt;video&#8221;;</span><br />
<span style="color:#0000ff;"> $xml .= &#8221; name=\&#8221;" . $videos[$i][0] . &#8220;\&#8221;";<br />
$xml .= &#8221; src=\&#8221;" . $videos[$i][1] . &#8220;\&#8221;";<br />
$xml .= &#8221; playCount=\&#8221;" . $videos[$i][2] . &#8220;\&#8221;";<br />
$xml .= &#8221; /&gt;\n&#8221;;<br />
}<br />
$xml .= &#8220;&lt;/videos&gt;&#8221;;</span></p>
<p>//a header type of XML is outputted<br />
<span style="color:#0000ff;"> header(&#8220;Content-type: text/xml&#8221;);</span><br />
//output the XML code<br />
<span style="color:#0000ff;"> print $xml;</span><br />
<span style="color:#0000ff;">}</span></p>
<p>?&gt;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jesperfriis.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jesperfriis.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jesperfriis.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jesperfriis.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jesperfriis.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jesperfriis.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jesperfriis.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jesperfriis.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jesperfriis.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jesperfriis.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jesperfriis.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jesperfriis.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jesperfriis.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jesperfriis.wordpress.com/95/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=95&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jesperfriis.wordpress.com/2009/03/25/videoplayer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c0ef281313c27323cbad18a6446945bc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">jesperfriis</media:title>
		</media:content>
	</item>
		<item>
		<title>Gemme et billede fra en tegne applikation!</title>
		<link>http://jesperfriis.wordpress.com/2009/03/24/gemme-et-billede-fra-en-tegneapplikation/</link>
		<comments>http://jesperfriis.wordpress.com/2009/03/24/gemme-et-billede-fra-en-tegneapplikation/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 12:02:39 +0000</pubDate>
		<dc:creator>jesperfriis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jesperfriis.wordpress.com/?p=89</guid>
		<description><![CDATA[I går og i dag har jeg siddet og bakset med at få tegneapplikationen til at gemme et png billede på serveren. Det lader sig faktisk også gøre på min localhost, men problemet er bare at billede,t der bliver gemt ikke registrerer nogle pixels farver. Den registrerer størrelsen på det billede, man tegner, og den [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=89&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I går og i dag har jeg siddet og bakset med at få tegneapplikationen til at gemme et png billede på serveren. Det lader sig faktisk også gøre på min localhost, men problemet er bare at billede,t der bliver gemt ikke registrerer nogle pixels farver. Den registrerer størrelsen på det billede, man tegner, og den genererer også den xml, der skal til , og som skal sendes videre til php. Det er funktionen &#8220;getPixel&#8221;, der skulle registrere de forskellige farver, men som ikke gør det. Jeg vil bruge lidt mere tid på at se, om jeg kan få det til at virke, og selv om det ikke lykkes, så vil jeg senere lige uploade den kode, der skal bruges for at lave applikationen.</p>
<p>Applikationen ser således ud : <a href="http://jesperf.dk/flashandphp/drawing1/index.html" target="_blank">http://jesperf.dk/flashandphp/drawing1/index.html</a> og tager udgangspunkt i en den tegne applikation og tilhørende kode jeg har  uploaded her på bloggen før. Men den virker som sagt ikke!!!</p>
<p>Koden der skal tilføjes til koden til tegneapplikationen som er beskrevet tidligere her på bloggen er følgende:</p>
<p>AS3 koden: ( det grå er noget af koden fra tegneapplikationen, så man ved hvor det skal sættes ind!)</p>
<p><span style="color:#c0c0c0;">var penMC:MovieClip;<br />
var isDrawing:Boolean = false;<br />
var penTipSize:uint = 1;<br />
var penColor:<span style="color:#c0c0c0;">Number = 0&#215;0000</span></span><span style="color:#c0c0c0;">00;</span><br />
<span style="color:#000000;">// path to the php file</span><br />
<span style="color:#ff0000;">var phpFile:String = &#8220;http://localhost/flashandphp/DrawingGD/ImageGenerator.php&#8221;;</span></p>
<p><span style="color:#c0c0c0;">function init():void<br />
{<br />
penMC = new MovieClip();<br />
stage.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing);<br />
stage.addEventListener(MouseEvent.MOUSE_UP, stopDrawing);<br />
stage.addEventListener(MouseEvent.MOUSE_MOVE, drawing);</span><br />
// when you click the generate image button you call the generateImage function<br />
<span style="color:#ff0000;"> toolsMC.generateMC.addEventListener(MouseEvent.CLICK, generateImage);</span><br />
<span style="color:#c0c0c0;"> addChild(penMC);</span></p>
<p><span style="color:#ff0000;">function generateImage(e:MouseEvent):void<br />
{</span><br />
// the variables used to determind the width and height of the image<br />
<span style="color:#ff0000;"> var width:uint = penMC.width;<br />
var height:uint = penMC.height;</span><br />
// the buildingImageMC becomes visible when you&#8217;ve clicked the button<br />
<span style="color:#ff0000;"> toolsMC.buildingImageMC.visible = true;</span></p>
<p>// building a new bitmap using the draw method of the BitmapData class<br />
<span style="color:#ff0000;"> var bmp:BitmapData = new BitmapData(width, height, false, 0xFFFFFF);</span><br />
// it takes one argument which is the target. The method takes the argument and copies the pixel data to the new bitmap<br />
<span style="color:#ff0000;"> bmp.draw(penMC);</span><br />
// after the new bitmap is created you can build a loop that will scan the bitmap and grap the color of each pixel<br />
<span style="color:#ff0000;"> var xml:String = &#8220;&lt;points&gt;&#8221;;</span></p>
<p><span style="color:#ff0000;"> for(var i:uint=0; i &lt; width; i++)</span><br />
<span style="color:#ff0000;">{<br />
for(var j:uint=0; j &lt; height; j++)<br />
{<br />
var color:String = bmp.getPixel(i, j).toString(16);</span></p>
<p><span style="color:#ff0000;"> if(color == &#8220;0&#8243;)<br />
{<br />
color = &#8220;00FF33&#8243;;<br />
}</span></p>
<p><span style="color:#ff0000;"> xml += &#8220;&lt;point&gt;&#8221;;<br />
xml += &#8220;    &lt;x&gt;&#8221; + i + &#8220;&lt;/x&gt;&#8221;;<br />
xml += &#8220;    &lt;y&gt;&#8221; + j + &#8220;&lt;/y&gt;&#8221;;<br />
xml += &#8220;    &lt;c&gt;&#8221; +  color + &#8220;&lt;/c&gt;&#8221;;<br />
xml += &#8220;&lt;/point&gt;&#8221;;<br />
}</span><br />
<span style="color:#ff0000;"> }</span></p>
<p><span style="color:#ff0000;">xml += &#8220;&lt;/points&gt;&#8221;;<br />
trace(xml);</span></p>
<p>// the color data is stored in a custom xml document that is sent of to php once the entire image is scanned<br />
<span style="color:#ff0000;"> var urlVariables:URLVariables = new URLVariables();<br />
urlVariables.width = width;</span><br />
<span style="color:#ff0000;"> urlVariables.height = height;<br />
urlVariables.pointData = xml;<br />
</span></p>
<p><span style="color:#ff0000;"> var urlRequest:URLRequest = new URLRequest(phpFile);<br />
urlRequest.method = URLRequestMethod.POST;<br />
urlRequest.data = urlVariables;</span><span style="color:#ff0000;"><span style="color:#000000;"><br />
// the sendToURL is used when you don&#8217;t expect to get something back from php</span><br />
sendToURL(urlRequest);</span><br />
<span style="color:#ff0000;">}</span></p>
<p><span style="color:#ff0000;">function imageGenerated(e:Event):void<br />
{</span><br />
// when the image is generated the &#8220;building image&#8221; text is removed<br />
<span style="color:#ff0000;"> toolsMC.buildingImageMC.visible = false;<br />
}</span></p>
<p><span style="color:#ff0000;"><span style="color:#0000ff;">&lt;?php</span><br />
<span style="color:#000000;">// the width,cheight and xml are all passed using post data because a get request would fail</span><br />
<span style="color:#0000ff;">$width = $_POST['width'];<br />
$height = $_POST['height'];</span></p>
<p><span style="color:#000000;">// makes an xml object that is used to generate or render the final image</span><br />
<span style="color:#0000ff;">$points = simplexml_load_string($_POST['pointData']);</span></p>
<p><span style="color:#000000;">// when the data is properly loaded you set up the base for the rendered image using imagecreatetruecolor function which is part of the GD library</span><br />
<span style="color:#0000ff;">$img = imagecreatetruecolor($width, $height);</span></p>
<p><span style="color:#000000;">// the actual image is generated by looping through all of the xml data that is pulling out the color values that was captured in flash</span><br />
<span style="color:#0000ff;">$limit = count($points-&gt;point);</span><br />
<span style="color:#0000ff;"><br />
for($j=0; $j &lt; $limit; $j++)<br />
{<br />
$x = $points-&gt;point[$j]-&gt;x;<br />
$y = $points-&gt;point[$j]-&gt;y;</span></p>
<p><span style="color:#0000ff;"> $color = $points-&gt;point[$j]-&gt;c;<br />
$color = hexdec($color);</span></p>
<p><span style="color:#000000;"> // all of the data is passed to the imagesetpixel function on each pass of the inner loop</span><br />
<span style="color:#0000ff;"> imagesetpixel($img, $x, $y, $color);<br />
}<br />
</span><br />
<span style="color:#000000;">// render the image as png and save it to the file system</span><br />
<span style="color:#0000ff;">header(&#8216;Content-Type: image/png&#8217;);<br />
imagepng($img, &#8216;render_&#8217; . time() . &#8216;.png&#8217;);</p>
<p>?&gt;</span><br />
</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jesperfriis.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jesperfriis.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jesperfriis.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jesperfriis.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jesperfriis.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jesperfriis.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jesperfriis.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jesperfriis.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jesperfriis.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jesperfriis.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jesperfriis.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jesperfriis.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jesperfriis.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jesperfriis.wordpress.com/89/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=89&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jesperfriis.wordpress.com/2009/03/24/gemme-et-billede-fra-en-tegneapplikation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c0ef281313c27323cbad18a6446945bc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">jesperfriis</media:title>
		</media:content>
	</item>
		<item>
		<title>Ny problemformulering</title>
		<link>http://jesperfriis.wordpress.com/2009/03/24/ny-problemformulering/</link>
		<comments>http://jesperfriis.wordpress.com/2009/03/24/ny-problemformulering/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 11:04:27 +0000</pubDate>
		<dc:creator>jesperfriis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jesperfriis.wordpress.com/?p=87</guid>
		<description><![CDATA[- Hvordan bruger man Flash og AS3 sammen med PHP og MySQL? - Hvilke forskellige typer af applikationer kan man med fordel lave, når man bruger disse teknologier sammen? - Hvordan kan jeg blive bedre til AS3, PHP og mySQL? - Hvordan bliver jeg bedre og mere erfaren til at arbejde med en webserver og [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=87&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>- Hvordan bruger man Flash og AS3 sammen med PHP og MySQL?</p>
<p>- Hvilke forskellige typer af applikationer kan man med fordel lave, når man bruger disse teknologier sammen?</p>
<p>- Hvordan kan jeg blive bedre til AS3,  PHP og mySQL?</p>
<p>- Hvordan bliver jeg bedre og mere erfaren til at arbejde med en webserver og en database?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jesperfriis.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jesperfriis.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jesperfriis.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jesperfriis.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jesperfriis.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jesperfriis.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jesperfriis.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jesperfriis.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jesperfriis.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jesperfriis.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jesperfriis.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jesperfriis.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jesperfriis.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jesperfriis.wordpress.com/87/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=87&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jesperfriis.wordpress.com/2009/03/24/ny-problemformulering/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c0ef281313c27323cbad18a6446945bc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">jesperfriis</media:title>
		</media:content>
	</item>
		<item>
		<title>Tegne applikation</title>
		<link>http://jesperfriis.wordpress.com/2009/03/23/tegne-applikation/</link>
		<comments>http://jesperfriis.wordpress.com/2009/03/23/tegne-applikation/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 11:13:40 +0000</pubDate>
		<dc:creator>jesperfriis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jesperfriis.wordpress.com/?p=83</guid>
		<description><![CDATA[Ved hjælp af den tegne API der er inkluderet i Flash kan man designe sine egne tegne applikationer. Den kan ses og prøves her:  http://www.jesperf.dk/flashandphp/drawing/index.html Det er så meningen i de kommende applikationer, jeg skal prøve at lave, at man bl.a. kan gemme det billede, man tegner ved hjælp af noget, der hedder GD Library [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=83&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Ved hjælp af den tegne API der er inkluderet i Flash kan man designe sine egne tegne applikationer. Den kan ses og prøves her:  <a href="http://www.jesperf.dk/flashandphp/drawing/index.html" target="_blank">http://www.jesperf.dk/flashandphp/drawing/index.html</a></p>
<p>Det er så meningen i de kommende applikationer, jeg skal prøve at lave, at man bl.a. kan gemme det billede, man tegner ved hjælp af noget, der hedder GD Library i PHP.</p>
<p>Her kommer AS3 koden:</p>
<p>// the container reference in which you draw<br />
<span style="color:#ff0000;">var penMC:MovieClip;</span><br />
// the boolian variable used to start and stop drawing<br />
<span style="color:#ff0000;">var isDrawing:Boolean = false;</span><br />
// the variables that holds the default pen color and size<br />
<span style="color:#ff0000;">var penTipSize:uint = 1;<br />
var penColor:Number = 0&#215;000000;</span></p>
<p>// this function is responsible for building the toolbox and initializing the mouse event handlers<br />
<span style="color:#ff0000;">function init():void<br />
{</span><br />
// makes a new instance of the penMC movieclip<br />
<span style="color:#ff0000;"> penMC = new MovieClip();</span><br />
// set eventhandler on the mouse down,up and move and call a function when they are used<br />
<span style="color:#ff0000;"> stage.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing);<br />
stage.addEventListener(MouseEvent.MOUSE_UP, stopDrawing);<br />
stage.addEventListener(MouseEvent.MOUSE_MOVE, drawing);</span><br />
//add the penMC movieclip to the stage<br />
<span style="color:#ff0000;"> addChild(penMC);</span></p>
<p>// Puts event listeners on all the colors and line styles in the toolbox, so the can change color an line style<br />
// &#8211; by changing the values of the penColor variable and the penTipSize variable<br />
<span style="color:#ff0000;"> toolsMC.swatchPurpleMC.addEventListener(MouseEvent.CLICK, function():void<br />
{<br />
penColor = 0x9999CC;<br />
});<br />
toolsMC.swatchBlueMC.addEventListener(MouseEvent.CLICK, function():void<br />
{<br />
penColor = 0x0000FF;<br />
});<br />
toolsMC.swatchRedMC.addEventListener(MouseEvent.CLICK, function():void<br />
{<br />
penColor = 0xFF0000;<br />
});<br />
toolsMC.swatchGreenMC.addEventListener(MouseEvent.CLICK, function():void<br />
{<br />
penColor = 0x00FF00;<br />
});<br />
toolsMC.swatchOrangeMC.addEventListener(MouseEvent.CLICK, function():void<br />
{<br />
penColor = 0&#215;009900;</span><br />
<span style="color:#ff0000;"> });<br />
toolsMC.swatchBlackMC.addEventListener(MouseEvent.CLICK, function():void<br />
{<br />
penColor = 0&#215;000000;</span><br />
<span style="color:#ff0000;"> });</span></p>
<p><span style="color:#ff0000;">toolsMC.brushSize1MC.addEventListener(MouseEvent.CLICK, function():void<br />
{ </span><br />
<span style="color:#ff0000;"> penTipSize = 1;<br />
});<br />
toolsMC.brushSize2MC.addEventListener(MouseEvent.CLICK, function():void<br />
{ </span><br />
<span style="color:#ff0000;"> penTipSize = 2;<br />
});</span></p>
<p><span style="color:#ff0000;">toolsMC.brushSize4MC.addEventListener(MouseEvent.CLICK, function():void<br />
</span> <span style="color:#ff0000;"><span style="color:#ff0000;"> {</span><br />
penTipSize = 4;<br />
});</span></p>
<p><span style="color:#ff0000;"> toolsMC.brushSize6MC.addEventListener(MouseEvent.CLICK, function():void<br />
{<br />
penTipSize = 6;<br />
});</span></p>
<p>// makes sure you can&#8217;t accidently draw on the tool interface, by swapping children<br />
<span style="color:#ff0000;"> swapChildren(toolsMC, penMC);<br />
}</span><br />
// the function that enables you to start drawing, and it is called when the mouse is clicked<br />
<span style="color:#ff0000;">function startDrawing(e:MouseEvent):void<br />
{</span><br />
// the output panel tells you that the function is called!<br />
<span style="color:#ff0000;"> trace(&#8220;Start Drawing&#8221;);</span><br />
// the boolian is set to true so it can be used to determin whether to draw or to stop drawing<br />
<span style="color:#ff0000;"> isDrawing = true;</span><br />
// a new default line is created in case the color or size variables has changed.<br />
// it is set inside the penMC movieclip<br />
<span style="color:#ff0000;"> penMC.graphics.lineStyle(penTipSize, penColor, 1.0);</span><br />
// Moves the current drawing position to where mouse x and y is inside the penMC movieclip<br />
<span style="color:#ff0000;"> penMC.graphics.moveTo(mouseX, mouseY);<br />
}</span><br />
// when the drawing flag is set you can start drawing the actual pen stroke(s)<br />
<span style="color:#ff0000;">function drawing(e:MouseEvent):void<br />
{</span><br />
//you can draw if &#8220;isDrawing&#8221; is set to true<br />
<span style="color:#ff0000;"> if(isDrawing)<br />
{</span><br />
// draws a line from the current position of the mouse pointer in the penMC movieclip<br />
<span style="color:#ff0000;"> penMC.graphics.lineTo(mouseX, mouseY);<br />
}<br />
}<br />
</span><br />
// when the mouse button is released you stop drawing<br />
<span style="color:#ff0000;">function stopDrawing(e:MouseEvent):void<br />
{</span><br />
// you get a message in the output panel when you stop (only in your fla file)<br />
<span style="color:#ff0000;"> trace(&#8220;Stop Drawing&#8221;);</span><br />
// the stop drawing is done by setting the boolian to false<br />
<span style="color:#ff0000;"> isDrawing = false;<br />
}<br />
</span>// calls the init function<br />
<span style="color:#ff0000;">init();</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jesperfriis.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jesperfriis.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jesperfriis.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jesperfriis.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jesperfriis.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jesperfriis.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jesperfriis.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jesperfriis.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jesperfriis.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jesperfriis.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jesperfriis.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jesperfriis.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jesperfriis.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jesperfriis.wordpress.com/83/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=83&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jesperfriis.wordpress.com/2009/03/23/tegne-applikation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c0ef281313c27323cbad18a6446945bc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">jesperfriis</media:title>
		</media:content>
	</item>
		<item>
		<title>flickr gallery</title>
		<link>http://jesperfriis.wordpress.com/2009/03/20/flickr-gallery/</link>
		<comments>http://jesperfriis.wordpress.com/2009/03/20/flickr-gallery/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 11:32:06 +0000</pubDate>
		<dc:creator>jesperfriis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jesperfriis.wordpress.com/?p=77</guid>
		<description><![CDATA[Så har jeg også lavet et billede galleri, hvor jeg har brugt den API, som flickr stiller gratis til rådighed. Man søger så efter billeder i en bestemt katagori, og flickr returnerer billeder fra deres database.  Det eneste, man skal gøre, er at oprette en flickr account på http://flickr.com/signup og derefter ansøge om en API [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=77&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Så har jeg også lavet et billede galleri, hvor jeg har brugt den API, som flickr stiller gratis til rådighed. Man søger så efter billeder i en bestemt katagori, og flickr returnerer billeder fra deres database.  Det eneste, man skal gøre, er at oprette en flickr account på <a href="http://flickr.com/signup" target="_blank">http://flickr.com/signup </a>og derefter ansøge om en API på <a href="http://flickr.com/services/api/keys/apply" target="_blank">http://flickr.com/services/api/keys/apply</a></p>
<p>Denne applikation minder meget om den forrige applikation, jeg lavede nemlig &#8220;amazon search&#8221; applikationen. Koden er også mange steder næsten den samme, og hvis man lavede endnu større applikationer, er det her, at det ville være en stor fordel at lave nogle genbrugelige  AS3 &#8220;classes&#8221;, som man blot henviser til i sin &#8220;package&#8221;, og som man så måke bare behøver at ændre små ting i.</p>
<p>Jeg prøvede at kommentere AS3 koden storts set uden brug af bogen, og det var rart, at jeg faktisk selv kunne gennemskue, hvordan koden hang sammen, og hvilken betydning de forskellige variabler, funktioner osv har.</p>
<p>PHP koden kommenterede jeg dog med hjælp fra bogen, da der var flere koder, jeg ikke lige selv kunne gennemskue. Specielt fordi det er noget kode, som kommer fra flickr og er helt nyt for mig.</p>
<p>Galleriet kan ses på <a href="http://www.jesperf.dk/flashandphp/flickr_gallery/index.html" target="_blank">http://www.jesperf.dk/flashandphp/flickr_gallery/index.html</a> , men igen så er der problemer med at få lov til at søge og hente billederne  ned, da det har noget med &#8220;cross domain policy&#8221; at gøre, og det har jeg ikke tid til at undersøge lige nu, hvordan man løser. Et andet problem er, at min server kun understøtter PHP4, og da PHP&#8217;en i min kode gør brug af &#8220;simpleXML&#8221; library, som kun virker i PHP 5, så ville der også komme en fejlmelding, hvis det andet problem var løst. Jeg forstår ikke helt hvorfor, de kun understøtter PHP4, og jeg overvejer at sende dem en mail, hvor jeg spørger hvorfor.</p>
<p>Her kommer koden, og så kan man jo selv prøve det af derhjemme på ens &#8220;localhost&#8221; server, for der virker det fint , og billedrne fra flickr dukker helt planlagt op, når man søger.</p>
<p>Først AS3 som er i 2 &#8220;classes&#8221;:</p>
<p>1:<span style="color:#ff0000;"><br />
package<br />
{</span><br />
// imports the nescesary classes<br />
<span style="color:#ff0000;"> import flash.display.MovieClip;<br />
import flash.events.*;<br />
import flash.net.URLRequest;<br />
import flash.net.URLVariables;<br />
import flash.net.URLLoader;</span></p>
<p><span style="color:#ff0000;"> public class PhotoGallery extends MovieClip<br />
{</span><br />
// path to the php file on the server<br />
<span style="color:#ff0000;"> public var webServiceURL:String = &#8220;http://localhost/flashandphp/flickrGallery/photoGallery.php&#8221;;</span></p>
<p>// defines the variables to use later, the photos array and the movieclip to hold the photos<br />
<span style="color:#ff0000;"> private var photos:Array;<br />
private var photosContainer:MovieClip;</span></p>
<p>// this function runs everytime the search button is clicked (the constructor function)<br />
<span style="color:#ff0000;"> public function PhotoGallery()<br />
{</span><br />
//this is only visible in the fla file and this way you can follow the process<br />
<span style="color:#ff0000;"> trace(&#8220;Simple WebService Searcher Started&#8221;);</span><br />
// makes new instance<br />
<span style="color:#ff0000;"> photos = new Array();</span><br />
// makes new instance<br />
<span style="color:#ff0000;"> photosContainer = new MovieClip();</span><br />
// places the photos movieclip on the stage<br />
<span style="color:#ff0000;"> photosContainer.y = 75;</span><br />
// adds an eventlistener to the search button<br />
<span style="color:#ff0000;"> searchBtn.addEventListener(MouseEvent.CLICK, searchHandler);</span><br />
//  adds photos movieclip holder to the stage<br />
<span style="color:#ff0000;"> addChild(photosContainer);<br />
}</span></p>
<p>// this function is responsible for removing old photos if any<br />
// and to search for photos when something is entered in the &#8220;enter keywords&#8221; textfield<br />
<span style="color:#ff0000;"> public function searchHandler(e:MouseEvent):void<br />
{</span><br />
// it only runs if something is entered<br />
<span style="color:#ff0000;"> if(searchTxt.text.length &gt; 0)<br />
{</span><br />
<span style="color:#000000;"> </span><span style="color:#ff0000;"><span style="color:#000000;"> // calls the removeOldPhotos function</span><br />
removeOldPhotos();</span><br />
// calls the loadSearchResults function and sends along the keywords entered as an argument<br />
<span style="color:#ff0000;"> loadSearchResults(searchTxt.text);<br />
}<br />
}</span></p>
<p>// this function send the request to the php file on the server which connects to flick to search for results<br />
// the php file the sends the requested data back<br />
<span style="color:#ff0000;"> public function loadSearchResults(tags:String):void<br />
{</span><br />
//this is only visible in the fla file and this way you can follow the process<br />
<span style="color:#ff0000;"> trace(&#8220;loadSearchResults()&#8221;);<br />
var urlVariables:URLVariables = new URLVariables();<br />
urlVariables.tags = tags;<br />
</span><br />
// connects to the php file on the server<br />
<span style="color:#ff0000;"> var urlRequest:URLRequest = new URLRequest(webServiceURL);</span><br />
//the dat send to the php file is the tags entered in the &#8220;enter keywords&#8221; textfield<br />
<span style="color:#ff0000;"> urlRequest.data = urlVariables;</span></p>
<p>// uses the loader class to load the data<br />
<span style="color:#ff0000;"> var urlLoader:URLLoader = new URLLoader();</span><br />
//when the data is fully loaded the loadedResultsHandler function is called<br />
<span style="color:#ff0000;"> urlLoader.addEventListener(Event.COMPLETE, loadedResultsHandler);<br />
urlLoader.load(urlRequest);<br />
</span><span style="color:#ff0000;"><span style="color:#ff0000;"> }</span></span></p>
<p>public function loadedResultsHandler(e:Event):void<br />
{<br />
//this is only visible in the fla file and this way you can follow the process<br />
<span style="color:#ff0000;"> trace(&#8220;loadedResultsHandler()&#8221;);</span></p>
<p>// when the data is fully loaded<br />
<span style="color:#ff0000;"> var urlLoader:URLLoader = URLLoader(e.target);</span><br />
// its made valid xml data to work with in flash<br />
<span style="color:#ff0000;"> var xml:XML = new XML(urlLoader.data);</span></p>
<p>// a for&#8230;each loop is used to look through each item in the xml file<br />
<span style="color:#ff0000;"> for each(var item in xml..photo)<br />
{</span><br />
// makes a new instance of the photoItem movieclip from the library<br />
<span style="color:#ff0000;"> var photoItem:PhotoItem = new PhotoItem();</span><br />
//calls the setValues metod to set title and thumbnail photo<br />
<span style="color:#ff0000;"> photoItem.setValues(item..title, item..thumb);</span><br />
// places the photos on top of each other<br />
<span style="color:#ff0000;"> photoItem.y = (photos.length * (photoItem.height + 50));</span><br />
// adds the photitem to the photos array<br />
<span style="color:#ff0000;"> photos.push(photoItem);</span><br />
// adds photoItem to the photosContainer movieclip on the stage<br />
<span style="color:#ff0000;"> photosContainer.addChild(photoItem);<br />
}<br />
}</span></p>
<p>// removes the old photos<br />
<span style="color:#ff0000;"> private function removeOldPhotos():void<br />
{</span><br />
// only removes photos if there are any<br />
<span style="color:#ff0000;"> if(photos.length &gt; 0)<br />
{</span><br />
// makes new array to clear the old one<br />
<span style="color:#ff0000;"> photos = new Array();</span><br />
// removes the photosContainer movieclip<br />
<span style="color:#ff0000;"> removeChild(photosContainer);</span><br />
// and makes a new on and places and adds it to the stage<br />
<span style="color:#ff0000;"> photosContainer = new MovieClip();<br />
photosContainer.y = 75;<br />
addChild(photosContainer);<br />
}<br />
}<br />
}<br />
}</span><br />
2:<br />
<span style="color:#ff0000;">package<br />
{</span><br />
// imports the nescesary classes<br />
<span style="color:#ff0000;"> import flash.display.MovieClip;<br />
i</span><span style="color:#ff0000;"><span style="color:#ff0000;">mport flash.text.TextField;</span><br />
import flash.display.Loader;<br />
import flash.net.URLRequest;</span></p>
<p><span style="color:#ff0000;"> public class PhotoItem extends MovieClip<br />
{</span><br />
// makes the variables to use later(and gives them the string datatype)<br />
<span style="color:#ff0000;"> private var title:String;<br />
private var thumb:String;</span></p>
<p>// the constuctor function is empty &#8211; doesent mean anything!<br />
<span style="color:#ff0000;"> public function photoItem()</span><br />
<span style="color:#ff0000;"> {</span></p>
<p>}</p>
<p>//This function takes the two argument from (photoItem.setValues(item..title, item..thumb)<br />
// and datatypes them to strings<br />
<span style="color:#ff0000;"> public function setValues(t:String, i:String):void<br />
{</span><br />
// makes the variables private, so they can&#8217;t accidently be changed or modified<br />
<span style="color:#ff0000;"> title = t;<br />
thumb = i;</span></p>
<p>// sets the title retrieved from the xml equal to the titleTxt text<br />
<span style="color:#ff0000;"> titleTxt.text = title;</span><br />
//places it on the stage in the titleTxt textfield component. And moves it out so there are room for the thumbnail<br />
<span style="color:#ff0000;"> titleTxt.x = 100;</span></p>
<p>// calls the loadthumb function<br />
<span style="color:#ff0000;"> loadThumb();<br />
}</span></p>
<p>// this function loads the thumbnail images through the url provided from flikr which was sent to php and sent back to flash as xml<br />
<span style="color:#ff0000;"> public function loadThumb():void<br />
{</span><br />
//this is only visible in the fla file and this way you can follow the process<br />
<span style="color:#ff0000;"> trace(&#8220;load thumb&#8221;);</span><br />
//loads the thumbnail image<br />
<span style="color:#ff0000;"> var thumbLoader:Loader = new Loader();</span><br />
<span style="color:#ff0000;"> var thumbURL:String = thumb;<br />
var thumbURLRequest:URLRequest = new URLRequest(thumbURL);<br />
thumbLoader.load(thumbURLRequest);<br />
thumbLoader.x = 10;</span><br />
<span style="color:#ff0000;"> addChild(thumbLoader);<br />
}</span></p>
<p>// don&#8217;t know what this function does because the application runs perfect without<br />
// but in the book he says: &#8220;this method is for passing back the image information&#8221;.<br />
<span style="color:#ff0000;"> public function getValues():Object<br />
{<br />
return {title:title};<br />
}<br />
}<br />
}</span><br />
Php&#8217;en ser således ud:</p>
<p><span style="color:#0000ff;">&lt;?php</span></p>
<p><span style="color:#0000ff;"><span style="color:#000000;">// first step is to define the flickr API key that is provided from flickr</span><br />
<span style="color:#0000ff;">define(&#8220;FLICKR_ACCESS_KEY&#8221;, &#8220;flickr API key copy in here!&#8221;</span></span><span style="color:#0000ff;">);</span></p>
<p>// flickr har a uniqe way of building image URLs and by later in this php code the use of sprintf function is used to work with that format<br />
<span style="color:#0000ff;">$flickrURLTemplate = &#8220;http://farm%s.static.flickr.com/%s/%s_%s_s.jpg&#8221;</span>;</p>
<p>// if the search tags that comes from flash accidently is empty the php script stops and exits<br />
<span style="color:#0000ff;">if(empty($_GET['tags']))<br />
{<br />
exit();<br />
}</span></p>
<p>// the seach tages from flash is stored in the searchTags variable<br />
<span style="color:#0000ff;">$searchTags = $_GET['tags'];</span></p>
<p>// next step is to pull in the search tags data and make a call to flickr to start the search process<br />
<span style="color:#0000ff;">$apiMethod = &#8220;flickr.photos.search&#8221;;<br />
$request = &#8220;http://api.flickr.com/services/rest/?method=&#8221; . $apiMethod . &#8220;&amp;tags=&#8221; . $searchTags  .&#8221;&amp;api_key=&#8221; . FLICKR_ACCESS_KEY. &#8220;&amp;per_page=5&#8243;;</span></p>
<p>// the XML data returned is stores in the rawXml variable<br />
<span style="color:#0000ff;">$rawXml = file_get_contents($request);</span><br />
// when its fully loaded it is passes along to the simplexml_load_string method which creates a proper object tha php can then parse<br />
<span style="color:#0000ff;">$xmlResponse = simplexml_load_string($rawXml);</span></p>
<p>// how many images to display is determined by loading the value that is located in the XML<br />
<span style="color:#0000ff;">$nodeCount = getAttribute($xmlResponse-&gt;photos, &#8220;perpage&#8221;);</span></p>
<p>// the process of building the custom XML document is done using a for.. each loop that graps each photo node and pulls in the required information<br />
<span style="color:#0000ff;">$xml = &#8220;&lt;?xml version=\&#8221;1.0\&#8221; ?&gt;\n&lt;photos&gt;&#8221;;</span></p>
<p>for($i=0; $i &lt; $nodeCount; $i++)<br />
{<br />
// Flickr vars<br />
// this is for building the image path, which is pased into the sprintf function<br />
<span style="color:#0000ff;"> $farmID = getAttribute($xmlResponse-&gt;photos-&gt;photo[$i], &#8220;farm&#8221;);<br />
$serverID = getAttribute($xmlResponse-&gt;photos-&gt;photo[$i], &#8220;server&#8221;);<br />
$photoID = getAttribute($xmlResponse-&gt;photos-&gt;photo[$i], &#8220;id&#8221;);<br />
$secret = getAttribute($xmlResponse-&gt;photos-&gt;photo[$i], &#8220;secret&#8221;);</span></p>
<p><span style="color:#0000ff;"> $xml .= &#8220;    &lt;photo&gt;&#8221;;<br />
$xml .= &#8220;        &lt;title&gt;&lt;![CDATA[" . getAttribute($xmlResponse-&gt;photos-&gt;photo[$i], &#8220;title&#8221;) . &#8220;]]&gt;&lt;/title&gt;&#8221;;<br />
$xml .= &#8220;        &lt;thumb&gt;&#8221; . sprintf($flickrURLTemplate, $farmID, $serverID, $photoID, $secret) . &#8220;&lt;/thumb&gt;&#8221;;<br />
$xml .= &#8220;    &lt;/photo&gt;&#8221;;</span><br />
<span style="color:#0000ff;">}</span></p>
<p>$xml .= &#8220;&lt;/photos&gt;&#8221;;</p>
<p>// sets the correct header type<br />
<span style="color:#0000ff;">header(&#8220;content-type: text/xml&#8221;);</span></p>
<p>// the data sent back to flash in an XML document<br />
<span style="color:#0000ff;">print $xml;</span></p>
<p>// the    getAttribute function with two arguments taht helps build the right xml document.<br />
<span style="color:#0000ff;">function getAttribute($xml, $name)<br />
{<br />
foreach($xml-&gt;attributes() as $key=&gt;$val)</span><br />
<span style="color:#0000ff;">{<br />
if($key == $name)<br />
{<br />
return (string)$val;<br />
}<br />
}</span><br />
// returns false if this comparison isnt true: ($key == $name)<br />
<span style="color:#0000ff;"> return false;<br />
}</span><br />
<span style="color:#0000ff;">?&gt;</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jesperfriis.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jesperfriis.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jesperfriis.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jesperfriis.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jesperfriis.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jesperfriis.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jesperfriis.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jesperfriis.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jesperfriis.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jesperfriis.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jesperfriis.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jesperfriis.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jesperfriis.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jesperfriis.wordpress.com/77/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=77&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jesperfriis.wordpress.com/2009/03/20/flickr-gallery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c0ef281313c27323cbad18a6446945bc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">jesperfriis</media:title>
		</media:content>
	</item>
		<item>
		<title>Amazon search</title>
		<link>http://jesperfriis.wordpress.com/2009/03/19/amazon-search/</link>
		<comments>http://jesperfriis.wordpress.com/2009/03/19/amazon-search/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 13:27:34 +0000</pubDate>
		<dc:creator>jesperfriis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jesperfriis.wordpress.com/?p=73</guid>
		<description><![CDATA[Så har jeg færdiggjort en applikation, der ved hjælp af Amazon.com&#8217;s AWS (Amazon Web Service) gør det muligt at lave en søge applikation, der bruger Amazon.com som data kilde. Dvs at man gør brug af ECS (Amazon E-Commerce Service), som giver direkte adgang til Amazons fantastiske søgesystem. Det eneste man skal gøre er, at anskaffe [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=73&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Så har jeg færdiggjort en applikation, der ved hjælp af Amazon.com&#8217;s AWS (Amazon Web Service) gør det muligt at lave en søge applikation, der bruger Amazon.com som data kilde. Dvs at man gør brug af ECS (Amazon E-Commerce Service), som giver direkte adgang til Amazons fantastiske søgesystem. Det eneste man skal gøre er, at anskaffe sig en valid Amazon access ID, som man får, når man opretter en&#8221;developer&#8217;s account&#8221; på <a href="www.amazon.com/gp/aws/landing.html" target="_blank">www.amazon.com/gp/aws/landing.html</a>. Det er nemt, hurtigt og koster ikke noget. Man skal bare have en email adresse.</p>
<p>Når man så søger, får man rigtigt meget xml data tilbage fra Amazon, og så er det vigtigt, at man får sorteret i det i sin php fil, så man kun får det data ud, som man skal bruge og derefter kan sende det videre til swf filen og flash.</p>
<p>Min applikation virkede fint på min localhost server, men da jeg uploadede den til min server på nette,t kunne den ikke skabe forbindelse. Jeg tror endnu engang, det har noget med cross domain policy at gøre, da jeg henter data fra en anden web server, som så skal igennem den server, hvor mit domain er. Derfor virker applikationen ikke, men man kan se, hvordan den ser ud her: <a href="http://www.jesperf.dk/flashandphp/amazon_search/index.html" target="_blank">http://www.jesperf.dk/flashandphp/amazon_search/index.html</a></p>
<p>Og hvis man så kunne søge og søgte på flash, så ville der komme 4 eksempler frem med et lille billede a bogen og en tittel samt forfatterens navn.</p>
<p>Jeg synes, det er super at finde ud af de mange muligheder, man har for at lave forskellige applikationer ved hjælp af forskellige servicer, der bliver stillet gratis til rådighed fra andre web firmaer. Det var en god oplevelse at sidde og søge efter forskellige bøger (igennem min localhost), og de så rent faktisk dukkede op i min swf.</p>
<p>Endnu engang fandt jeg en lille fejl i PHP source filen, men denne gang tog det mig ikke så lang tid at finde den. Det er godt, at jeg kan mærke jeg bliver bedre til de forskellige koder, så jeg kan finde en fejl og komme videre i processen. Det siger vel også lidt om, at jeg da heldigvis lærer noget.</p>
<p>Nå men her kommer koden. Først as3 som er 2 filer eller 2 classes:</p>
<p>1:<span style="color:#ff0000;"><br />
package<br />
{</span><br />
// import the nescesarry classes<br />
<span style="color:#ff0000;"> import flash.display.MovieClip;<br />
import flash.events.*;<br />
import flash.net.URLRequest;<br />
import flash.net.URLVariables;<br />
import flash.net.URLLoader;</span></p>
<p>// extends on existing movieclips from the library<br />
<span style="color:#ff0000;"> public class BookSearch extends MovieClip<br />
{</span><br />
// path to the php file on the server<br />
<span style="color:#ff0000;"> public var webServiceURL:String = &#8220;http://jesperf.dk/flashandphp/amazon_search/bookSearch.php&#8221;;</span></p>
<p>//creates an array variable<br />
<span style="color:#ff0000;"> private var bookItems:Array;</span><br />
////creates movieclip variable<br />
<span style="color:#ff0000;"> private var bookItemsContainer:MovieClip;</span></p>
<p>// the constructor method tah runs each time the application starts<br />
// it is used to initialize the array, create a container movieclip and add en event listener to the search button<br />
<span style="color:#ff0000;"> public function BookSearch()<br />
{<br />
bookItems = new Array();<br />
bookItemsContainer = new MovieClip();</span><br />
// the movieclip to hold the book items is placed<br />
<span style="color:#ff0000;"> bookItemsContainer.y = 100;</span><br />
// the search button calls teh serarchHandler function<br />
<span style="color:#ff0000;"> searchBtn.addEventListener(MouseEvent.CLICK, searchHandler);</span><br />
// &#8211; and added to the stage<br />
<span style="color:#ff0000;"> addChild(bookItemsContainer);<br />
}</span></p>
<p>// this functiom handles the seach request<br />
<span style="color:#ff0000;"> public function searchHandler(e:MouseEvent):void<br />
{</span><br />
// if something is entered in the search textfiels then old seach results are removed, otherwise they stay<br />
<span style="color:#ff0000;"> if(searchTxt.text.length &gt; 0)<br />
{</span><br />
// calls the removeOldResults function<br />
<span style="color:#ff0000;"> removeOldResults();</span><br />
// and if somthing is entered a call to the loadSearchResults function is made to connect to php and search for the result<br />
<span style="color:#ff0000;"> loadSearchResults(searchTxt.text);<br />
}<br />
}</span></p>
<p>// this function send a request to the php file which is responsible for interfacing with the AWS<br />
// and it takes one argument that is the string entered in the search button texfield<br />
<span style="color:#ff0000;"> public function loadSearchResults(terms:String):void<br />
{</span><br />
// first set up the variables object<br />
<span style="color:#ff0000;"> var urlVariables:URLVariables = new URLVariables();<br />
urlVariables.terms = terms;</span></p>
<p>// calls the php and assigns that to the URLRequest<br />
<span style="color:#ff0000;"> var urlRequest:URLRequest = new URLRequest(webServiceURL);<br />
urlRequest.data = urlVariables;</span></p>
<p>// Creates a new loader instance<br />
<span style="color:#ff0000;"> var urlLoader:URLLoader = new URLLoader();</span><br />
// assigns an event handler<br />
<span style="color:#ff0000;"> urlLoader.addEventListener(Event.COMPLETE, loadedResultsHandler);<br />
urlLoader.load(urlRequest);<br />
}</span></p>
<p>// Once the Web server returns the data, it is sent to the loadedResultsHandler method<br />
// the responce is sent in XML format and using a for &#8230; each loop each element is pulled out and sent to a unique bookItem instance<br />
<span style="color:#ff0000;"> public function loadedResultsHandler(e:Event):void</span><br />
<span style="color:#ff0000;"> {<br />
var urlLoader:URLLoader = URLLoader(e.target);<br />
var xml:XML = new XML(urlLoader.data);</span></p>
<p>for each(var item in xml..book)<br />
{<br />
// a new instance of the bookitem from the library is made<br />
<span style="color:#ff0000;"> var bookItem:BookItem = new BookItem</span>();<br />
// the new instance gets its unique values<br />
<span style="color:#ff0000;"> bookItem.setValues(item..title, item..author, item..price, item..thumb);</span><br />
// with a little help from the array the item are positioned on top of each other<br />
<span style="color:#ff0000;"> bookItem.y = (bookItems.length * (bookItem.height + 30));</span><br />
// the book items are added to the booItems array<br />
<span style="color:#ff0000;"> bookItems.push(bookItem);</span><br />
// the bookItem movieclip is placed inside the bookItemsContainer movieclip<br />
<span style="color:#ff0000;"> bookItemsContainer.addChild(bookItem);<br />
}<br />
}<br />
</span><br />
// this method is used to remove the existing book item instances<br />
// this metod is called each time a new search begins, to ensure the data dosent accidentially stack up<br />
<span style="color:#ff0000;"> private function removeOldResults():void<br />
{</span><br />
/// checks for valid entries because the first time the application runs there will be no existing products on the stage<br />
<span style="color:#ff0000;"> if(bookItems.length &gt; 0)<br />
{</span><br />
// a new array is created that clears the existing objects<br />
<span style="color:#ff0000;"> bookItems = new Array();</span><br />
// then the old container is cleared and a new is created<br />
<span style="color:#ff0000;"> removeChild(bookItemsContainer);<br />
bookItemsContainer = new MovieClip();<br />
bookItemsContainer.y = 100;</span><br />
// adding the new instance of the container to the stage<br />
<span style="color:#ff0000;"> addChild(bookItemsContainer);<br />
}<br />
}<br />
}<br />
}</span></p>
<p>2:<br />
<span style="color:#ff0000;">package<br />
{</span><br />
// imports the nescesarry classes<br />
<span style="color:#ff0000;"> import flash.display.MovieClip;<br />
import flash.text.TextField;<br />
import flash.display.Loader;<br />
import flash.net.URLRequest;</span></p>
<p>// this class is used for each product that is added to the stage. It is responsible for storing off the product data and loading the book thumbnail<br />
// it also extends on existing movieclips from the library<br />
<span style="color:#ff0000;"> public class BookItem extends MovieClip<br />
{</span></p>
<p>// creates the variables to use in the setValues function<br />
<span style="color:#ff0000;"> private var title:String;<br />
private var author:String;<br />
private var price:String;<br />
private var thumb:String;<br />
</span><br />
// The constuctor method is empty in this class!<br />
<span style="color:#ff0000;"> public function BookItem()<br />
{</span></p>
<p><span style="color:#ff0000;">}</span></p>
<p>// this function is responsible for storing the passed values or book data retrieved from Amazon<br />
<span style="color:#ff0000;"> public function setValues(t:String, a:String, p:String, i:String):void<br />
{<br />
title = t;<br />
author = a;<br />
price = p;<br />
thumb = i;</span></p>
<p><span style="color:#ff0000;">titleTxt.text = title;<br />
authorTxt.text = author;<br />
priceTxt.text = price;</span></p>
<p>// a call to the loadThumb function is made which is responsible for retrieving the thumbnail of the book cover<br />
<span style="color:#ff0000;"> loadThumb();<br />
}</span></p>
<p>// loads the thumbnail of the book cover through the url passes back to php in the XML from Amazone<br />
<span style="color:#ff0000;"> public function loadThumb():void<br />
{<br />
var thumbLoader:Loader = new Loader();</span><br />
<span style="color:#ff0000;"> var thumbURL:String = thumb;<br />
var thumbURLRequest:URLRequest = new URLRequest(thumbURL);<br />
thumbLoader.load(thumbURLRequest);<br />
thumbLoader.x = 10;</span><br />
// when using the loader class you can pass it into the addChild which removes the need for an event listener (because you don&#8217;t need the big cover)<br />
<span style="color:#ff0000;"> addChild(thumbLoader);<br />
}<br />
</span><br />
// the last method is for returning the BookItem data that was populated in the previous methods<br />
// don&#8217;t quite know whats it there fore because the application runs without this function,<br />
// &#8211; but maybe its so that you can use the variables without using the setValues function<br />
<span style="color:#ff0000;"> public function getValues():Object<br />
{<br />
return {title:title, author:author, price:price};<br />
}<br />
}<br />
}</span></p>
<p><span style="color:#ff0000;"><span style="color:#000000;">PHP&#8217;en:</span></span></p>
<p><span style="color:#ff0000;"><span style="color:#000000;"><span style="color:#0000ff;">&lt;?php</span></span></span></p>
<p>// the variable to hold the seach requests<br />
<span style="color:#0000ff;">$terms = &#8220;&#8221;;</span></p>
<p>//<br />
<span style="color:#0000ff;">define(&#8220;AWS_ACCESS_KEY&#8221;, &#8220;</span><span style="color:#00ff00;">AWS_ACCESS_KEY</span><span style="color:#ff0000;"><span style="color:#000000;"><span style="color:#0000ff;">&#8220;);</span></span></span></p>
<p>// checks to see if the search field is empty (or checks for valid tags)<br />
<span style="color:#0000ff;">if(!empty($_GET['terms']))<br />
{</span><br />
// the variable to holdt the search parameters sent with get method<br />
<span style="color:#0000ff;"> $terms = $_GET['terms'];<br />
</span><br />
// the request that will be sent to the AWS passing along the search parameters<br />
<span style="color:#0000ff;">$request = &#8216;http://ecs.amazonaws.com/onca/xml&#8217; .<br />
&#8216;?Service=AWSECommerceService&amp;&#8217; .<br />
&#8216;AWSAccessKeyId=&#8217; . AWS_ACCESS_KEY .<br />
&#8216;&amp;Operation=ItemSearch&#8217; .<br />
&#8216;&amp;SearchIndex=Books&#8217; .<br />
&#8216;&amp;ResponseGroup=Medium&#8217; .<br />
&#8216;&amp;Keywords=&#8217; . $terms;</span></p>
<p>// the response from the AWS is loaded using file_get_contents<br />
// the string is saved to the $rawXml</p>
<p><span style="color:#0000ff;"> $rawXml = file_get_contents($request);</span></p>
<p>// a call to the simplexml library i made to build a properly formatted xml object<br />
<span style="color:#0000ff;"> $xmlResponse = simplexml_load_string($rawXml);</span></p>
<p>// the variable to hold the 4 xml nodes (only 4 book results are saved)<br />
<span style="color:#0000ff;"> $nodeCount = 4;</span></p>
<p>// the XML sent back to flash<br />
// seaches for 4 books through the for loop and gets the title, author, price and thumb by going througt items and items nodes an so on&#8230;<br />
<span style="color:#0000ff;"> $xml = &#8220;&lt;?xml version=\&#8221;1.0\&#8221; ?&gt;\n&lt;books&gt;&#8221;;</span></p>
<p><span style="color:#0000ff;"> for($i=0; $i &lt; $nodeCount; $i++)<br />
{<br />
$xml .= &#8220;    &lt;book&gt;&#8221;;<br />
$xml .= &#8220;        &lt;title&gt;&lt;![CDATA[" . $xmlResponse-&gt;Items-&gt;Item[$i]-&gt;ItemAttributes-&gt;Title . &#8220;]]&gt;&lt;/title&gt;&#8221;;<br />
$xml .= &#8220;        &lt;author&gt;&lt;![CDATA[" . $xmlResponse-&gt;Items-&gt;Item[$i]-&gt;ItemAttributes-&gt;Author . &#8220;]]&gt;&lt;/author&gt;&#8221;;<br />
$xml .= &#8220;        &lt;price&gt;&lt;![CDATA[" . $xmlResponse-&gt;Items-&gt;Item[$i]-&gt;ItemAttributes-&gt;ListPrice-&gt;FormattedPrice . &#8220;]]&gt;&lt;/price&gt;&#8221;;</span><br />
<span style="color:#0000ff;"> $xml .= &#8220;        &lt;thumb&gt;&#8221; . $xmlResponse-&gt;Items-&gt;Item[$i]-&gt;SmallImage-&gt;URL . &#8220;&lt;/thumb&gt;&#8221;;<br />
$xml .= &#8220;    &lt;/book&gt;&#8221;;<br />
}</span></p>
<p>$xml .= &#8220;&lt;/books&gt;&#8221;;</p>
<p>// creates the right header type so XML readers know the format that is being sent<br />
<span style="color:#0000ff;"> header(&#8220;content-type: text/xml&#8221;);</span></p>
<p>// outputs the xml tahts sent to flash<br />
<span style="color:#0000ff;"> print $xml;</span></p>
<p>}</p>
<p>?&gt;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jesperfriis.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jesperfriis.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jesperfriis.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jesperfriis.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jesperfriis.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jesperfriis.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jesperfriis.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jesperfriis.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jesperfriis.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jesperfriis.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jesperfriis.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jesperfriis.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jesperfriis.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jesperfriis.wordpress.com/73/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=73&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jesperfriis.wordpress.com/2009/03/19/amazon-search/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c0ef281313c27323cbad18a6446945bc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">jesperfriis</media:title>
		</media:content>
	</item>
		<item>
		<title>Lidt PHP update</title>
		<link>http://jesperfriis.wordpress.com/2009/03/17/lidt-php-update/</link>
		<comments>http://jesperfriis.wordpress.com/2009/03/17/lidt-php-update/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 14:01:54 +0000</pubDate>
		<dc:creator>jesperfriis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jesperfriis.wordpress.com/?p=71</guid>
		<description><![CDATA[Jeg har de to sidste dage haft behov for at få lidt bedre styr på noget PHP, og jeg har derfor haft gang i en rigtig god tutorial fra Linda.com som hedder PHP &#38; MySQl Essential Training, samt at jeg også har læst et par kapitler i &#8220;Learning PHP&#8221; fra O&#8217;REILLY. Det var primært noget [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=71&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Jeg har de to sidste dage haft behov for at få lidt bedre styr på noget PHP, og jeg har derfor haft gang i en rigtig god tutorial fra Linda.com som hedder PHP &amp; MySQl Essential Training, samt at jeg også har læst et par kapitler i &#8220;Learning PHP&#8221; fra O&#8217;REILLY. Det var primært noget med arrays, funktioner og xml jeg ville have bedre styr på.</p>
<p>Jeg vil også gerne have bedre styr på &#8220;classes&#8221; i PHP, men det må jeg se på lidt senere, da der ikke er så meget om dette, hverken i tutorialen eller i bogen, og samtidig har også behov for at komme videre i processen lige nu.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jesperfriis.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jesperfriis.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jesperfriis.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jesperfriis.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jesperfriis.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jesperfriis.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jesperfriis.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jesperfriis.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jesperfriis.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jesperfriis.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jesperfriis.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jesperfriis.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jesperfriis.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jesperfriis.wordpress.com/71/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=71&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jesperfriis.wordpress.com/2009/03/17/lidt-php-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c0ef281313c27323cbad18a6446945bc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">jesperfriis</media:title>
		</media:content>
	</item>
		<item>
		<title>Shoppingcart afslutning!!!</title>
		<link>http://jesperfriis.wordpress.com/2009/03/17/shoppingcart-afslutning/</link>
		<comments>http://jesperfriis.wordpress.com/2009/03/17/shoppingcart-afslutning/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 13:51:55 +0000</pubDate>
		<dc:creator>jesperfriis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jesperfriis.wordpress.com/?p=67</guid>
		<description><![CDATA[Så lykkedes det mig endelig at finde fejlen. Jeg fik en ny mail tilbage fra forfatteren, og den lød sådan her: Did you merge the code from the two projects or simply run the code from the link I provided? I think something happened with the code for the book, but the link I provided [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=67&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Så lykkedes det mig endelig at finde fejlen.</p>
<p>Jeg fik en ny mail tilbage fra forfatteren, og den lød sådan her:</p>
<div id="message_">
<div class="postbody"><span style="color:#ff0000;">Did you merge the code from the two projects or simply run the code from the link I provided? I think something happened with the code for the book, but the link I provided before does work. As long as my site is online.<br />
Hope that helps,<br />
Matt</span></div>
<div class="postbody">Dette fik mig til at tænke, at der nok var et eller andet galt med kommunikationen mellem koden i fla filen ( the timeline code) og de tre classes. Så det eneste jeg skulle gøre, var selvfølgelig bare at flytte de tre AS filer ind i samme mappe som fla filen. En lidt åndsvag fejl at bruge så meget tid på, men man tror jo at tingene er i den orden, som de skal være, når man downloader nogle source files til en bog. Det viste sig dog også, at der var en lille fejl i koden, men det var ikke i den kode, der var beskrevet i bogen, men kun den i de souce files, jeg havde downloaded, og den var til at regne ud, hvis han ikke havde givet mig linket til den nye source kode.</div>
<div class="postbody">Her er hvad, jeg så skrev tilbage til ham:</div>
<div class="postbody">
<p><span style="color:#ff0000;">Hi again<br />
Finally I managed to make it work.</span></div>
<div class="postbody"><span style="color:#ff0000;">I just had to put the AS files in the same directory as the Fla file! I guess I should have figured it out myself a bit earlier.<br />
There is one error in the code in the source files I downloaded in the first place. It is in the line:<br />
item.setStoreData(id, xmlItem.attribute(&#8216;name&#8217;), xmlItem.attribute(&#8216;desc&#8217;), xmlItem.attribute(&#8216;thumbnail&#8217;), xmlItem.attribute(&#8216;price&#8217;));<br />
where the last argument (xmlItem.attribute(&#8216;price&#8217;) ) was missing,  but I can see its not missing in the source code provided in the book, so I guess i could have figured that out to.<br />
Thanks for the help once again<br />
Jesper</span></div>
<div class="postbody"><span style="color:#ff0000;"><span style="color:#000000;">Eksemplet kan ses her: <a href="http://jesperf.dk/flashandphp/shopping_cart/index.html" target="_blank">http://jesperf.dk/flashandphp/shopping_cart/index.html</a></span></span></div>
<div class="postbody"></div>
<div class="postbody"><span style="color:#ff0000;"><span style="color:#000000;">Man skal være opmærksom på at hvis man trykker på &#8220;checkout&#8221; knappen så får man en fejlmelding. Dette er fordi PHP koden benytter sig af &#8220;SimpleXMLElement&#8221;, som ikke er understøttet af PHP 4, som min webserver desværre kun har.</span></span></div>
<div class="postbody"></div>
<div class="postbody"><span style="color:#ff0000;"><span style="color:#000000;">Koden til denne applikation består af tre seperate classes plus en i fla.filen. Samtidig er der to PHP filer, og så er der jo også databasen, som man skal oprette med noget indhold. Jeg har derfor valgt ikke at poste denne kode, selvom jeg har kommenteret den, da jeg synes det vil komme til at fylde for meget og virke uoverskueligt.<br />
</span></span></div>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jesperfriis.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jesperfriis.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jesperfriis.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jesperfriis.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jesperfriis.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jesperfriis.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jesperfriis.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jesperfriis.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jesperfriis.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jesperfriis.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jesperfriis.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jesperfriis.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jesperfriis.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jesperfriis.wordpress.com/67/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jesperfriis.wordpress.com&amp;blog=6591062&amp;post=67&amp;subd=jesperfriis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jesperfriis.wordpress.com/2009/03/17/shoppingcart-afslutning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c0ef281313c27323cbad18a6446945bc?s=96&#38;d=identicon" medium="image">
			<media:title type="html">jesperfriis</media:title>
		</media:content>
	</item>
	</channel>
</rss>
