Intoduction to Flash and XML

This is the first time I've used flash, and for the life of me and all my google'ing I can't seem to workout
a) How to add ActionScript
b) How to use XML (I've found tutorials but I can't seem to use them because they don't describe where to put the code.
c) What I need to do special for Flashlite (since this is for the Popcorn Hour)
It would be great if you could show me how to make links to webpages from
    <myxml version="1">
        <links>
            <link location="http://www.google.com">Google</a>
            <link location="http://www.google.com.au">Google AU</a>
            <link location="http://www.google.se">Google SE</a>
        </links>
    </myxml>
Just a simple example XML I made.
Also if there are any security tips for Flash I should know about that would be great.
Thanks.

You are attempting an advanced topic before you know the basics of using the tool.  See if lynda.com can help you, or maybe http://tv.adobe.com/product/flash/
While there are a few places you can place code, if you are just starting, code will be entered on the timeline.  What you do is click a keyframe on the timeline to select it and then open the Actions window (Window -> Actions, or F9) to write the code for that frame.

Similar Messages

  • Flash and XML help : (

    Hi all
    bit of a newbie, so probably quite easy if you know how:eek:
    would anyone beable to help with sorting out an XML file, what I have is a tooltip that loads in via XML and exported from flash. the XML loads in 2 text fields,  field and field2.
    what I am trying to do is add a button also to the tooltip so that you can click and go to a url.
    would anyone beable to help with this.
    this is what I have in my XML file;
    <?xml version="1.0" encoding="utf-8"?>
    <data>
        <image name="image 1" path="img/img1.jpg"
        title="Food Fight"
        text="Information here!" />
    </data>
    this loads in 2 text fields.
    this is what I have in my AS;
                  var tooltip:ToolTip = new ToolTip();
          //tooltip.buttonMode = false; 
                    tooltip.field.text = titles;//loads tooltip 1
                    tooltip.field2.text = texts;//loads tool tip 2
                    holder.addChild(tooltip);
    I thought I could do something like this but I seem to be getting errors
    XML
    <?xml version="1.0" encoding="utf-8"?>
    <data>
        <image name="image 1" path="img/img1.jpg"
        title="Food Fight"
        text="Information here!"
                 button="click to view/>
    </data>
    and in my AS
    var tooltip:ToolTip = new ToolTip();
                    //tooltip.buttonMode = false; 
                    tooltip.field.text = titles;//loads tooltip 1
                    tooltip.field2.text = texts;//loads tool tip 2
                    tooltip.field3.text = buttons;//loads tool tip 3
                    holder.addChild(tooltip);
    but just not working, what am I doing wrong:yikes:
    many thanks for any help!

    hi Saransoft
    thanks for that, thats great, yes it seesm to work I now have an extra text field with the menu that is the button, I have put my XML like this, is it correct
    <image name="image 2" path="img/img2.jpg"
      title="Jazz Time"
      text="Information"
      button="Click for URL"  />   //NEW THAT I ADDED FOR THE BUTTON IS THIS CORRECT?
    Now that I have another text for the button my final thing is getting it to be click able and go to a URL when you the text button is clicked. can I do this just in the XML file or is there also more to be added to the AS...aaaaaaaaaaaaarrrrrrrrghhhhh!!!!
    many thanks for your help??

  • Flash and XML

    I am very new to Flash.  I recently came across a tutorial while trying to learn a bit more about using XML with FLASH. I apologize if this question is to open ended. The tutorial was for a simple carousel with a secondary state with a text field. I have 3 questions:
    1) would it be possible for me to build a function into a single XML element with in that secondary state.  For instance, if I wanted to play a mc, in just one of the images released state.
    2) Can i make embedded links (hyperlinks?), that are unique to each xml line?
    3) What is the best file format to maintain scalable vector art in XML
    Here is the as code implemented from the tutorial:
        import flash.display.Stage
        import flash.display.StageAlign;
        import flash.display.StageScaleMode;
                stage.scaleMode = StageScaleMode.NO_SCALE;
                stage.align = StageAlign.TOP;
    import mx.utils.Delegate;
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    var numOfItems:Number;
    var radiusX:Number = 270;
    var radiusY:Number = 70;
    var centerX:Number = Stage.width / 2;
    var centerY:Number = Stage.height / 1.4;
    var speed:Number = .005;
    var perspective:Number = 300;
    var home:MovieClip = this;
    theText._alpha = 0;
    var tooltip:MovieClip = this.attachMovie("tooltip","tooltip",10000);
    tooltip._alpha = 0;
    var xml:XML = new XML();
    xml.ignoreWhite = true;
    xml.onLoad = function()
    var nodes = this.firstChild.childNodes;
    numOfItems = nodes.length;
    for(var i=0;i<numOfItems;i++)
    var t = home.attachMovie("item","item"+i,i+1);
    t.angle = i * ((Math.PI*2)/numOfItems);
    t.onEnterFrame = mover;
    t.toolText = nodes[i].attributes.tooltip;
    t.content = nodes[i].attributes.content;
    t.icon.inner.loadMovie(nodes[i].attributes.image);
    t.r.inner.loadMovie(nodes[i].attributes.image);
    t.icon.onRollOver = over;
    t.icon.onRollOut = out;
    t.icon.onRelease = released;
    function over()
    var sou:Sound = new Sound();
    sou.attachSound("sover");
    sou.start();
    home.tooltip.tipText.text = this._parent.toolText;
    home.tooltip._x = this._parent._x;
    home.tooltip._y = this._parent._y - this._parent._height/2;
    home.tooltip.onEnterFrame = Delegate.create(this,moveTip);
    home.tooltip._alpha = 100;
    function out()
    delete home.tooltip.onEnterFrame;
    home.tooltip._alpha = 0;
    function released()
    var sou:Sound = new Sound();
    sou.attachSound("sdown");
    sou.start();
    home.tooltip._alpha = 0;
    for(var i=0;i<numOfItems;i++)
    var t:MovieClip = home["item"+i];
    t.xPos = t._x;
    t.yPos = t._y;
    t.theScale = t._xscale;
    delete t.icon.onRollOver;
    delete t.icon.onRollOut;
    delete t.icon.onRelease;
    delete t.onEnterFrame;
    if(t != this._parent)
    var tw:Tween = new Tween(t,"_xscale",Strong.easeOut,t._xscale,0,1,true);
    var tw2:Tween = new Tween(t,"_yscale",Strong.easeOut,t._yscale,0,1,true);
    var tw3:Tween = new Tween(t,"_alpha",Strong.easeOut,100,0,1,true);
    else
    var tw:Tween = new Tween(t,"_xscale",Strong.easeOut,t._xscale,100,1,true);
    var tw2:Tween = new Tween(t,"_yscale",Strong.easeOut,t._yscale,100,1,true);
    var tw3:Tween = new Tween(t,"_x",Strong.easeOut,t._x,200,1,true);
    var tw4:Tween = new Tween(t,"_y",Strong.easeOut,t._y,320,1,true);
    var tw5:Tween = new Tween(theText,"_alpha",Strong.easeOut,0,100,1,true);
    theText.text = t.content;
    var s:Object = this;
    tw.onMotionStopped = function()
    s.onRelease = unReleased;
    function unReleased()
    var sou:Sound = new Sound();
    sou.attachSound("sdown");
    sou.start();
    delete this.onRelease;
    var tw:Tween = new Tween(theText,"_alpha",Strong.easeOut,100,0,0.5,true);
    for(var i=0;i<numOfItems;i++)
    var t:MovieClip = home["item"+i];
    if(t != this._parent)
    var tw:Tween = new Tween(t,"_xscale",Strong.easeOut,0,t.theScale,1,true);
    var tw2:Tween = new Tween(t,"_yscale",Strong.easeOut,0,t.theScale,1,true);
    var tw3:Tween = new Tween(t,"_alpha",Strong.easeOut,0,100,1,true);
    else
    var tw:Tween = new Tween(t,"_xscale",Strong.easeOut,100,t.theScale,1,true);
    var tw2:Tween = new Tween(t,"_yscale",Strong.easeOut,100,t.theScale,1,true);
    var tw3:Tween = new Tween(t,"_x",Strong.easeOut,t._x,t.xPos,1,true);
    var tw4:Tween = new Tween(t,"_y",Strong.easeOut,t._y,t.yPos,1,true);
    tw.onMotionStopped = function()
    for(var i=0;i<numOfItems;i++)
    var t:MovieClip = home["item"+i];
    t.icon.onRollOver = Delegate.create(t.icon,over);
    t.icon.onRollOut = Delegate.create(t.icon,out);
    t.icon.onRelease = Delegate.create(t.icon,released);
    t.onEnterFrame = mover;
    function moveTip()
    home.tooltip._x = this._parent._x;
    home.tooltip._y = this._parent._y - this._parent._height/2;
    xml.load("icons.xml");
    function mover()
    this._x = Math.cos(this.angle) * radiusX + centerX;
    this._y = Math.sin(this.angle) * radiusY + centerY;
    var s = (this._y - perspective) /(centerY+radiusY-perspective);
    this._xscale = this._yscale = s*150;
    this.angle += this._parent.speed;
    this.swapDepths(Math.round(this._xscale) + 100);
    this.onMouseMove = function()
    speed = (this._xmouse-centerX)/30500;
    Any help would be much appreciated.  Thanks.

    Thanks for the response on the first two.  I'll give it a shot.  I'll try and make the third question a bit clearer.  I get the first part, I'm referencing images. I started by using png files and the images just were not looking great with the motion.  I than went hunting for some tutorials on whether I could use ai or eps in xml hoping to find improvement (scalable vector art), the general consensus seemed to be no, the suggestion seemed to be to use a SVG file.  Flash seemed to recognize the images but not display them (I showed no compiler errors initially but broke the names got unfound URLS).  I than found a suggestion to use SWF's exported from AI, which worked fine but gave little improvement.  I am looking for a response on the general consensus on the best quality image file format that I can maintain through XML and Flash? A preference I guess.  Thanks Again.

  • Flash and XML data loading issue

    I have this SWF that loads 2 XML files that controls 2 different areas of the SWF.  I am using this code because I have stacked layers and when this was 2 seperate SWFs I couldn't use the SWFObject because of the wmode quirk in FF.  So my issue is when you first load this it seems to only load the slideshow (left side) and part of the right menu and then on refresh it loads the rest of the menu - how do I get it to load everything at once?  I have attacehed all of my files.
    <div id="LargeFlashContainerFlashMenu">     
                            <script language="javascript">
                                  if (AC_FL_RunContent == 0) {
                                       alert("This page requires AC_RunActiveContent.js.");
                                  } else {
                                       AC_FL_RunContent(
                                            'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
                                            'width', '940',
                                            'height', '265',
                                            'src', 'JGSB_HeaderRightNav_v05',
                                            'FlashVars', 'strNavContentXML=BICMenu.xml&strShowContentXML=settings.xml',
                                            'quality', 'high',
                                            'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
                                            'align', 'middle',
                                            'play', 'true',
                                            'loop', 'true',
                                            'scale', 'showall',
                                            'wmode', 'transparent',
                                            'devicefont', 'false',
                                            'id', 'JGSB_HeaderRightNav_v05',
                                            'bgcolor', '#000000',
                                            'name', 'JGSB_HeaderRightNav_v05',
                                            'menu', 'true',
                                            'allowFullScreen', 'false',
                                            'allowScriptAccess','sameDomain',
                                            'movie', 'JGSB_HeaderRightNav_v05',
                                            'salign', ''
                                            ); //end AC code
                             </script>
                             <noscript>
                                       <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="940" height="265" id="JGSB_HeaderRightNav_v05" align="middle">
                                            <param name="allowScriptAccess" value="sameDomain" />
                                            <param name="allowFullScreen" value="false" />
                                            <param name="movie" value="JGSB_HeaderRightNav_v05.swf" />
                                            <param name="FlashVars" value="strNavContentXML=BICMenu.xml&strShowContentXML=settings.xml" />
                                            <param name="quality" value="high" />
                                            <param name="wmode" value="transparent" />
                                            <param name="bgcolor" value="#000000" />
                                            <embed wmode="transparent" src="JGSB_HeaderRightNav_v05.swf" quality="high" bgcolor="#0099cc" width="940" height="265" name="JGSB_HeaderRightNav_v05" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
                                       </object>
                             </noscript>
                   </div>

    ok I couldnt upload the files but I can send anyone who can help the zip with all files in it via email.

  • Flash and XML, looking for new images

    When I make changes to the XML file and haven't cleared my
    browsers cache, it still displays the old information (FF and IE).
    Our banner changes each week so I am constantly adding new stuff. I
    also change a single graphic once a week, but the image name
    doesn't change... So flash doesn't even load a new graphic when I
    just replace an old one...
    I am sure I am missing something easy...
    Here is what the Flash looks like:
    http://www.gracebrethren.org.
    Is there any way to make Flash check for changes and updates each
    time someone refreshes the page (say like an updated XML file
    different than what's in cache, or an updated graphic)?
    Let me know if you need any more information.

    quote:
    Originally posted by:
    kglad
    add a variable with a changing value to the end or your
    urlrequest string.
    Right now the code looks like this:
    var request:URLRequest = new URLRequest("eventTicker.xml");
    loader = new URLLoader(request);
    loader.addEventListener(Event.COMPLETE, loadComplete);
    I am not sure what you mean by adding a variable with a
    changing value.
    If it helps, in the actual Flash document, the "Document
    Class" is set to my class called "LoadEventData" where the code
    above is stored. So I thought by making it that way, each time the
    swf file was loaded it would make a new request to the specified
    XML file. Do I have my theory correct?

  • Java, Flash and Xml, not able to getParent of xml files

    Hi,
    I am using Java as a server, with a macromedia flash front end (using flash remoting to connect the two). I am loading in xml files in my java application, and i am having some problems when i run this from flash.
    Whenever i use any getParent methods from the JDOM library on an Element variable i get an error sent back to my flash document.
    But when i run my java code using NetBeans it is fine, the code runs fine and the getParent methods are called fine.
    Is there somthing I need to know about the getParent methods which make them return exceptions ....
    The error says the service threw an exception during method invocation: null
    What does this mean, my method threw an exception in Java ???
    Any help would be much appreciated
    Thanks

    Hi,
    Cheers for your interest. I think the problem is in the way in which I have mounted my JDOM.jar file. Currently I have just placed the JDOM.jar file into the lib folder on my JRun server.
    Does anyone have any ideas on how to mount the JDOM.jar file properly
    Thanks

  • How to edit bitmap which is imported in flash using xml and save the edited bitmap back to xml in flash.

    hi all
    It would be appreciated if any one let me know how to edit
    bitmap which is imported in flash using xml and save the edited
    bitmap back to xml in flash.
    Is it posible to save the bitmap data in flash?
    thanks in advance

    Yes you can... but like I said before you need to upload the
    data from the changes you make to a server.
    In terms of the solution... its unlikely that you'll find one
    specifically for your needs. You will have to learn whatever you
    don't know how already and maybe adapt some existing examples to
    your needs.
    To change the visual state of a movie clip... you just do all
    the regular things that you want to do to it using flash... scale,
    rotation, drawing API , textfields etc in actionscript. If you
    don't know how to how to do that stuff, then you need to learn that
    first. That's basic actionscript.
    You can capture the visual state of a movieclip using the
    BitmapData class. That includes a loaded jpeg. You can also
    manipulate bimatp data using the same class. You should read up on
    that if you don't know how to use it or check out the examples
    below for uploading info.
    For uploading to the server:
    Here's an as2 solution that took 15 secs to find using
    google:
    http://www.quasimondo.com/archives/000645.php
    If you're using as3, google search for "jpeg encoder as3" and
    look through that info. There are also historical answers in the
    forums here related to this type of thing that might help as
    well.

  • Custom Map in flash using XML data for dynamic map and point of intrest loading...

    Been some time since I have used Flash for anything...
    I'm working on a little project to dynamically build a map
    and set points of interest on the map. At this time I have the
    (mySQL) data being queried and formatted with PHP and pushing the
    data to Flash as XML.
    In starting the project I'm a bit lost... I mean I have my
    data and a good XML format but as it is I'm lost on parsing the
    data in Flash and assigning its values to movie clips or other...
    I've looked at the Loader Component and the XML Connector
    Component and find I can get that to work at all...
    My second though was to create a single movie clip on stage
    and give it an instance name of "Background" and have it load the
    URL of an image given in the attached XML doc... Node "a_zone" and
    the value given to attribute "image"... But this brings me back to
    square one of not quite understanding Flash and parsing XML... With
    this second idea I would use AS to create a movie clip, set it's X
    & Y cords and load an image to it based on the XML attributes
    listed in the "Gatherable" node (one for each node).
    Any suggestions, examples or related info is welcome...
    Thanks in advance!

    Okay, that really wasn't what I was looking for... But I did
    go back and RTM :-)
    Here's what I have... 1st frame:
    2nd Layer: movieclip with the instance name "currentPicture"
    The image loads into "currentPicture" from the URL given in
    the XML "a_zone" node attribute "image" just fine....
    But I'm not able to grab the attributes of each "Gatherable"
    node it seems... am I missing something or just not pointing to the
    right node?
    I keep getting:
    undefined
    undefined
    undefined
    Error opening URL
    "file:///C|/apache2triad/htdocs/gatherer/flash/undefined"
    Error opening URL
    "file:///C|/apache2triad/htdocs/gatherer/flash/undefined"
    Error opening URL
    "file:///C|/apache2triad/htdocs/gatherer/flash/undefined"

  • How to link pdf file in flash by xml ??

    how to link pdf file in flash by xml ??

    try to give <a href="your address">My Pdf</a>
    and your textfield should be html enabled
    mytextField.html=true
    mytextField.htmlText=your xml text

  • Flash Lite XML Driven Gallery Simple Question

    Hello Flash Lite Gurus',
    Someone Named "Mr. Samir K. Dash;" did a wonderful tutorial regarding Flash Lite XML driven Photo Gallery, and I have just a small question:
    1> I changed the attributes schema of the xml as attached and noticed that it is not working, and I wonder what could be the reason (please see the attached XML new attribute schema, I didn't change fields names, I just changed the way the attributes' schema looks like).
    The link to the tutorial is the following:
    http://www.adobe.com/devnet/devices/articles/xml_photo_gallery.html
    Looking forward to your help
    best regards
    Talal

    As I look at your modified XML file, you need to make major changes in the script.
    You have changed the attributes to become child nodes. So, you will need to use firstChild.nodeValue or childNodes[i].nodeValue everywhere.
    Regards,
    Hemanth Sharma
    http://www.flashlitehub.com/blog

  • How to make like Spry Products demo using Flash CS4 / xml?

    hello there!
    i wonder is it possible to make something similar to Spry Products Demo using Flash CS4 for front end and xml for back end data. take a look at this draft image. If it can be done, can someone guide me please. I am super new to AS2/3 - Please. Thanks for your help.

    hello there!
    i wonder is it possible to make something similar to Spry Products Demo using Flash CS4 for front end and xml for back end data. take a look at this draft image. If it can be done, can someone guide me please. I am super new to AS2/3 - Please. Thanks for your help.

  • AS3 and XML, HELP!

    Hi
    I have no idea where to post this, so pls forgive me if im in the wrong place, but I have an Assessment due tomorrow, I'm only 4 weeks knew to AS3 and Flash, and confused as, so pls forgive me if i also look silly asking this question.
    The issue is loading data from an XML file and having it present in a Flash website. Its a book review thing (i've altered the XML and AS3 for posting here so please bare that in mind), so the XML looks a little like this
    <books>
        <book>
            <bookName>The Monsters</bookName>
            <genres>
                <genre>Thriller</genre>
                <genre>Crime</genre>
                <genre>Comedy</genre>
            </genres>
            <description>about the mummies.</description>
            <image>mummies.jpg</image>
            <reviews>
                <review>
                    <date>16/07/2011</date>
                    <name>unnamed</name>
                    <info>
                        <rating>5</rating>
                        <why>blah blah</why>
                        <theGood>it was good...</theGood>
                        <the Bad>it was bad…</theBad>
                    </info>
                </review>
            </reviews>
        </book>
    <books>
    but each Book has multiple reviews, i've just shown you one. Anyway, i need to present this information in 3 dynamic text fields when a book is selected in my ComboBox… after a lot of trouble i got the basics of it. So in the Genre box the genres will display, and in the Description box the description will display, and in the Review box i can get all the information, but only with all the tags. I need it to display without any tags, it would be wonderful if i could figure out how i could put date, name etc in front of that information as well, but I cant even begin to figure that one out.  For the life of me i cannot figure it out. below is the code I have so far:
    //Load XML
    var booksXML:XML = new XML();
    var loader:URLLoader = new URLLoader();
    var request:URLRequest = new URLRequest("gigGuide.xml");
    loader.addEventListener(Event.COMPLETE,loaderOnComplete);
    loader.load(request);
    function loaderOnComplete(event:Event):void
       booksXML = new XML(event.target.data);
       var books:Array = new Array({label:"Select a Book"});
       for each (var book:XML in booksXML.band)
          books.push({label:book.bookName.toString(), data:book.description.toXMLString(),
                     infoLocal:book.genres.genre.toString(), infoDate:book.reviews.review.toString(),
                     infoImage:book.image});
       bandCB.dataProvider = new DataProvider(bands);
    //ComboBox changeable
    bookCB.addEventListener(Event.CHANGE, changeHandler2);
    function changeHandler2(event:Event):void
       genre_txt.text = ComboBox(event.target).selectedItem.infoLocal;
       description_txt.text = ComboBox(event.target).selectedItem.data;
       reviews_txt.text = ComboBox(event.target).selectedItem.infoDate;
       empty_mc.tex = ComboBox(event.target).selectedItem.infoImage; //doesn't work
    any help would be greatly appreciated, and the image doesn't work, i've already faced facts that im not going to get that one to work
    Thank you in advance

    From what I can see you have a few problems. In your loaderOnComplete you set the data provider with 'bands' but create a variable called 'books'.
    Also, you want to be using the XMLList object to parse your data out. It's much simpler.
    Have a look at the following:
    var booksXML:XML;
    function loaderOnComplete(e:Event):void
              booksXML = new XML(e.target.data);
              var books:XMLList = booksXML.book;
              trace(books[0].bookName);
              var bookReviews:XMLList = books[0].reviews.review;
              trace(bookReviews[0].name);
    trace(bookReviews[0].date);
    First we get all the book xml objects in an XML List - the trace traces book number 0's name - The Monsters.
    Next, you can get all the reviews for a book in another XML List. Here we use the first book - book[0] and trace out the review's name and date.
    You can iterate through an XMLList as it has a length() method - (not a length property)
    Also, loading an image for a book would be easy - you just grab the image property of the current book and then use a Loader to load it.
    trace(books[0].image);

  • Load assets and xml

    I am trying to add games to a Flash file. They are in different folders and the assest and xml information is not coming with it? I get the error : "[BulkLoader] Error loading LoadingItem url: images/, type:text, status: error Error #2032: Stream Error. URL: file:///G|/%2D%2DWORK%2D%2D/Gilcrease%20Projects/Kravis/images/
    Here are the files I need to load into the main file. Please help. Thank you in advance!
    Angela

    As mentioned, the very first SWF that is loaded will set the file path. That means every single call to load an external file from that point on will come from the location of the very first SWF.
    If the first SWF loads another SWF, that other SWF needs to know this so it properly requests files in the right location.
    Example file structure:
    Main.swf
    MatchingGame\MatchingGame.swf
    MatchingGame\images\a.png
    Say Main.swf loads MatchingGame\MatchingGame.swf. Now the root is set to the path of Main.swf. If MatchingGame\MatchingGame.swf wants to load the a.png, it cannot do this:
    var img:Loader = new Loader();
    img.load('images/a.png'); // FAIL
    It must be loaded as though it was Main.swf. The full relative path to a.png is MatchingGame\images\a.png. So MatchingGame\MatchingGame.swf must do this:
    var img:Loader = new Loader();
    img.load('MatchingGame/images/a.png'); // SUCCESS
    Hopefully this illustrates that paths will always originate with the first loaded SWF, which was Main.swf in this example.

  • High Score Table: Writing a Simple Text File with Flash and PHP

    I am having a problem getting Flash to work with PHP as I need Flash to read and write to a text file on a server to store simple name/score data for a games hi score table. I can read from the text file into Flash easily enough but also need to write to the file when a new high score is reached, so I need to use PHP to do that. I can send the data from flash to the php file via POST but so far it is not working. The PHP file is confirmed as working as I added an echo to the file which displayed a message so I  could check that the server was running PHP - the files were also uploaded to a remote server so I  could test them properly. Flash code is as follows:
    //php filewriter
    var myLV = new LoadVars();
    function sendData() {
    //sets up variable 'hsdata' to send to php
    myLV.hsdata = myText;
    myLV.send("hiscores.php");
    I believe this sends the variable 'myText' to the php file as a variable called 'hsdata' which I want the php file to write into a text file. The mytext variable is just a long string that has all the scores and names in the hiscore. OK, XML would be better way of doing this but for speed I just want to get basic functionality working, so storing a simple text sting is adequate for now. The PHP code that reads the Flash 'hsdata' variable and writes it to the text file 'scores.txt' follows:
    <?php
    //assigns to variable the data POSTed from flash
    $flashdata = $_POST["hsdata"];
    //file handler opens file and erases all contents with w arg
    $fh = fopen("scores.txt","w");
    //adds data to file
    fwrite ($fh,$flashdata);
    //closes file
    fclose ($fh);
    echo 'php file is working';
    ?>
    Any help with this would be greatly appreciated - once I can get php to write simple text files I should be ok. Thanks.

    Thanks for your help.
    I have got Flash working to a certain extent with PHP using loadVars but have been unable to get flash to receive a variable declared in PHP. Here's my Flash code:
    var outLV = new LoadVars();
    var inLV = new LoadVars();
    function sendData() {
    outLV.hsdata = "Hello from Flash";
    outLV.sendAndLoad("http://www.mysite.com/hiscores/test23.php",inLV,"post");
    inLV.onLoad = function(success) {
    if (success) {
      //sets dynamic text box to show variable sent from php
      statusTxt.text = phpmess;
    } else {
      statusTxt.text = "No Data Received";
    This works ok and the inLV.onLoad function reports that it is receiving data but does not display the variable received from PHP. The PHP file is like this:
    <?php
    $mytxt =$_POST['hsdata'];
    $myfile = "test23.txt";
    $fh = fopen($myfile,'w');
    //adds data to file
    fwrite($fh, $mytxt);
    //closes file
    fclose ($fh);
    $mess = "hello there from php";
    echo ("&phpmess=$mess&");
    ?>
    The PHP file is correctly receiving the hsdata from flash and writing it to a text file, but there seems to be a problem with the final part of the code which is intended to send a variable called 'phpmess' back to Flash, this is the string "hello there from php". How do I set up Flash and PHP so that PHP can send a variable back to Flash using echo? Really have tried everything but am totally baffled. Online tutorials have given numerous different syntax configurations for how the PHP file should be written which has really confused me - any help would be greatly appreciated.

  • Array data between Flash and PHP

    As the title suggests, I'm trying to find a good way of
    getting an ActionScript/Flash dynamic array into PHP, so I can
    serialize it and store it in a DB, then simply give back that same
    array when it's called. Are there any popular techniques? The array
    will always be a different size, containing different values -
    which is why I'd like to keep the array in tact, to minimise the
    amount of parameter transfers. If there's no good solution, I
    suppose I could pass in parameters and read them in, create an
    array and serialize that... but I'd much rather find a way of
    having my flasher serialize his own array and pass me the
    byte-code. Is this possible?
    PHP doesn't need to read the contents of the array, simply
    store it in a DB, so if there's some kind of flash method for
    serializing an array into bytecode that it can unserialize and read
    back later, that would be awesome.
    Thanks. =]
    [edit]
    I found this:
    http://sourceforge.net/projects/serializerclass/
    a serializer class. Is this the best method?

    Sorry, I should have explained, we already use XML for data
    transfers (though I personally find JSON much nicer with less
    overhead). So, in this project, we use XML for data transfer
    between flash and PHP/Database. The reason I wanted this
    functionality, is because the flash array, in this one case, will
    be completely dynamic and the PHP doesn't need to know the contents
    of the array at all. In fact, in this instance, PHP is just the
    mechanism used for storing the data. Becuase of the nature of the
    data, I wanted to serialize the flash array, store it in the
    database as Bytecode, then when the flash needs that information
    again, I can pass back the same bytecode, which can then be
    unserialized back into the original array.
    I think I've found the solution, the one I linked in the
    original post. I should know if it's as effective as I want it to
    be in the next couple of days when my flasher gives it a try. =]
    Thanks for the responses. If anyone has any other ideas,
    please throw them in here.

Maybe you are looking for