A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: How can i display image and text from and external txt file?

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    6

    How can i display image and text from and external txt file?

    Hello i was wondering if anybody could provide me with an example on how can i load one image and text from and external txt file into my flash movie?
    For example load history from data.txt history=blablablabla
    image from data.txt historyimage=/images/history.jpg

    Thanks in advance.
    Last edited by bigbox; 12-20-2012 at 04:01 AM.

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Your textfile has this:
    history=blablablabla&historyimage=/images/history.jpg

    In your fla file you load the textfile and once it's loaded you have this:

    private function completeHandler (e:Event):void
    {
    var myData:Object = e.currentTarget.data;
    var myHistory:String = myData.history;
    }
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    6
    Quote Originally Posted by cancerinform View Post
    Your textfile has this:
    history=blablablabla&historyimage=/images/history.jpg

    In your fla file you load the textfile and once it's loaded you have this:

    private function completeHandler (e:Event):void
    {
    var myData:Object = e.currentTarget.data;
    var myHistory:String = myData.history;
    }
    I'm sorry to bug you but i have not much experience with this can you please correct me cause i really have no idea how to make this work!

    Code:
    var loader:URLLoader = new URLLoader(new URLRequest("http://whatever.com/test.txt"));
    loader.addEventListener(Event.COMPLETE, completeHandler);
    
    function completeHandler(event:Event):void {
        var myData:Object = event.currentTarget.data;
    	var myHistory:String = myData.history;
    	addChild(elderText);
    }

  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Looks all ok to me except this line, which I don't know to what it refers.
    addChild(elderText);
    - The right of the People to create Flash movies shall not be infringed. -

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center