A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Loading text in dynaminc textbox using xml

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    7

    Loading text in dynaminc textbox using xml

    Hey friends, I'm having problem in loading text in dynamic textboxes that I've made in my flash movie using text tool.

    there r four dynamic textboxes in my flash movie.
    they are:
    Class:
    Subject:
    Chapter:
    Description:

    Please help me. write to me the action script of how to load the text using xml in these textboxes.

    I'm uploading my .fla and xml file .>> dynamic text.zipDownload it and edit it and upload it. so that I can see the code.or send the action script (code) to me through e-mail
    My e-mail ID is -----------
    vaibhavkn@gmail.com

    thanks in advance .
    please send message as soon as possible.
    It's urgent

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    do you just want/need one 'group' of data with those values in it?

    or will there be MULTIPLE groups/object (nodes) each with their own class, subject..etc in it?

  3. #3
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    it could be as simple as this (AS2.0)

    Code:
    var total:Number;
    var myXML:XML = new XML();
    myXML.ignoreWhite = true;
    
    myXML.onLoad = function(success){
    	if(!success){
    		trace("XML failed to load");
    	}else{
    		trace("XML LOADED.....parsing data now.");
    		total = +myXML.firstChild.childNodes.length;
    		for(i=0; i<total; i++){
    			var xClass = myXML.firstChild.childNodes[i].attributes.xClass;
    			var xSubject = myXML.firstChild.childNodes[i].attributes.xSubject;
    			var xChapter = myXML.firstChild.childNodes[i].attributes.xChapter;
    			var xDesc = myXML.firstChild.childNodes[i].attributes.xDesc;
    
    			//example for putting the data into a text field
    			eval("classField_"+i).text = xClass;
    			eval("subjectField_"+i).text = xSubject;
    			eval("chapterField_"+i).text = xChapter;
    			eval("descField_"+i).text = xDesc;
    			
    		}
    	}
    }
    myXML.load("data.xml");

    XML:
    PHP Code:
    <data>
        <
    entry xClass="Math" xSubject="Geometry" xChapter="1" xDesc="Intro 101 to shapes" />
        <
    entry xClass="English" xSubject="Nouns" xChapter="5" xDesc="Learning to write" />
        <
    entry xClass="Science" xSubject="Chemistry" xChapter="3" xDesc="Period Table" />
    </
    data

  4. #4
    Junior Member
    Join Date
    Mar 2010
    Posts
    7
    Please send me the action script 2.0 code only for the xml that I have uploaded earlier in dynamic text.zip. I,m uplading It again. Please send me code according to it only.

    dynamic text.zip

    My Xml document is as follows:--------------------------------
    <skof>
    <class>IX</class>
    <subject>Biology</subject>
    <chapter>The Fundamental Unit Of Life</chapter>
    <description>The Smallest biulding block of life</description>
    </skof>
    .................................................. ....................................
    Thanx in advance

  5. #5
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    //var total:Number;
    var myXML:XML = new XML();
    myXML.ignoreWhite = true;
    
    myXML.onLoad = function(success) {
    	if (!success) {
    		trace("XML failed to load");
    	} else {
    		// 'class' is a reserved word, change variable in textfield to 'xclass'
    		xclass = myXML.firstChild.childNodes[0].childNodes[0];
    		subject = myXML.firstChild.childNodes[1].childNodes[0];
    		chapter = myXML.firstChild.childNodes[2].childNodes[0];
    		description = myXML.firstChild.childNodes[3].childNodes[0];
    	}
    };
    myXML.load("skof.xml");
    
    /*<skof>
    <class>IX</class>
    <subject>Biology</subject>
    <chapter>The Fundamental Unit Of Life</chapter>
    <description>The Smallest biulding block of life</description>
    </skof>*/
    Last edited by dawsonk; 06-29-2010 at 02:02 PM.

  6. #6
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    you dont need the: var total:Number; line in there anymore..

    since there is no loop any longer.

  7. #7
    Junior Member
    Join Date
    Mar 2010
    Posts
    7
    thanx It really worked!

  8. #8
    Junior Member
    Join Date
    Mar 2010
    Posts
    7
    I want to create a flash presentation to launch powerpoint presentation through buttons on the flash presentation.

    the presentation contains 2 movies - a). the skin movie with exit button on it.
    b). the menu movie with buttons of various topics on it.

    I want to load them both together (both at one time) such that the menu movie is behind the skin movie.

    The path from where these movies are to be loaded is saved in an XML document.

    Now I want to load these movies together with the help of XML prasing.

    Please help me.

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