dcsimg
A Flash Developer Resource Site

Page 2 of 4 FirstFirst 1234 LastLast
Results 21 to 40 of 61

Thread: load XML into Flash Component

  1. #21
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    can't help with lines or accordian, sorry
    for image/text content in a TextArea, use html tags
    PHP Code:
    var my_ta:mx.controls.TextArea;

    var 
    image:String "Seeds.jpg";
    var 
    heading:String "Seeds Enterprise";

    my_ta.setSize(320240);
    my_ta.html true;
    my_ta.text "<img src='"+image+"'>";
    my_ta.text += "<p align='right'><b>"+heading+"</b>"+
    "<br><br><p align='center'>This is a simple example of "+  
    "loading <br><b>text</b> and an <i>image</i> into an html"+
    " enabled <font color='#FF0000'>TextArea</font> Component"

  2. #22
    Member
    Join Date
    Jun 2000
    Posts
    97
    Still no luck with the divider between coloured sections, However, I'm get closer to the accordion effect.... The only snag is, that the menu pops down but looks like it adds another menu option when it opens, goes away though.... And the text doesn't keep up with it .... Oh, and the menu doesn't close the previous section when the new section is selected.

    Anyhoo, here's the code ... What am I doing wrong? I'm almost there with the look and feel of the menu.

    //create a new listener to catch click on tree node
    myTreeListener = new Object();

    // change event handler
    myTreeListener.change = function(eventObject)
    {
    // the selected node
    var theSelectedNode = eventObject.target.selectedNode;

    //if it's a branch (a folder) so the branch is open
    if(my_tree.getIsBranch(theSelectedNode)){

    //Note: remove the last boolean optionnal parameter if you won't have an animated transition
    my_tree.setIsOpen (theSelectedNode, true,true,true);
    }

    }

    // add eventHandler to your listener
    my_tree.addEventListener("change", myTreeListener);
    Stagehand

  3. #23
    Member
    Join Date
    Jun 2000
    Posts
    97
    Quote Originally Posted by a_modified_dog
    can't help with lines or accordian, sorry
    for image/text content in a TextArea, use html tags
    PHP Code:
    var my_ta:mx.controls.TextArea;

    var 
    image:String "Seeds.jpg";
    var 
    heading:String "Seeds Enterprise";

    my_ta.setSize(320240);
    my_ta.html true;
    my_ta.text "<img src='"+image+"'>";
    my_ta.text += "<p align='right'><b>"+heading+"</b>"+
    "<br><br><p align='center'>This is a simple example of "+  
    "loading <br><b>text</b> and an <i>image</i> into an html"+
    " enabled <font color='#FF0000'>TextArea</font> Component"
    Will that work via XML though? I'll give it a shot, but I thought the XML would need to format it for flash to read it.
    Stagehand

  4. #24
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    to write html tags in XML you need to use CDATA elements
    use the Forum Search facility for examples of CDATA usage

  5. #25
    Member
    Join Date
    Jun 2000
    Posts
    97
    Mr Dog Sir,

    Ok, again, thanks for the help so far.

    I've given up on the using text and images together as I just can't find the solution ... So, I'm hoping you can help me out with an alternative.

    OK, it's pretty much the code you've helped me out with already, but I'll try and explain what I need.

    Ok, on the first frame of my movie is a CSS code to style the text loaded into my_ta, which is:

    Code:
    textStyle = new TextField.StyleSheet();
    textStyle.load("distance.css");
    my_ta.styleSheet = textStyle;
    
    _global.styles.TextArea.setStyle("backgroundColor","false");
    
    //init TextArea component
    my_ta.html = true;
    my_ta.wordWrap = true;
    my_ta.multiline = true;
    my_ta.label.condenseWhite=true;
    my_ta.setStyle("borderStyle", "none")
    my_ta.setStyle("fontFamily", "Geneva");
    my_ta.embedFonts = "true";
    my_ta._highquality = 2;
    Which works a treat when I use the following on my first frame also to load the XML:

    Code:
    Content = new XML();
    Content.ignoreWhite = true;
    Content._highquality = 2;
    Content.load("sec2_l.xml");
    Content.onLoad = function(success)
    {
            if(success)
            {
                    my_ta.text = Content;
            }
    }
    NOW!!!!

    Instead of loading the text on the first frame, I need to be able to keep the formating from the code you so kindly gave me earlier. Which was:

    Code:
    var treeDP_xml:XML = new XML(); 
    treeDP_xml.ignoreWhite = true; 
    treeDP_xml.onLoad = function(success:Boolean) { 
    if (success) { 
    my_tree.dataProvider = this.firstChild; 
    } 
    }; 
    
    treeDP_xml.load("Tree.xml"); 
    
    var treeListener:Object = new Object(); 
    treeListener.change = function(evt:Object) { 
    var treeNode:XMLNode = evt.target.selectedItem; 
    if (treeNode.attributes.src != undefined) { 
    trace(treeNode.attributes.src) 
    loadContent(treeNode.attributes.src); 
    } 
    }; 
    my_tree.addEventListener("change", treeListener); 
    
    function loadContent(file){ 
    _xml = new XML(); 
    _xml.ignoreWhite = true; 
    _xml.load(file); 
    _xml.onLoad = function(){ 
    image = this.firstChild.attributes.img; trace(image); 
    txt = this.firstChild.attributes.txt; trace(txt); 
    my_loader.load(image); 
    my_ta.text = txt; 
    }; 
    };

    The code above works a treat for simple XML tags which you've done, using IMG and TXT .... However, when I load the following XML, it doesn't want to know...:

    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    		<page>
    			<header><p>Orographic Triggers</p></header>
    				<spacer><p>-</p></spacer>
    			<section>
    			<sectionhead><li>What are orographic triggers?</li></sectionhead><subsection><p>If the air mass is absolutely unstable any rising ground will trigger immediate convection, which will continue on up, forming cloud, when the rising air cools to its dew point. If the air is very dry, cloud may never form, but the convection will still be present. Glider pilots call this "blue thermals". If the air is absolutely stable, then no matter how high the mountains, the air will sink back down on the lee side, and there will be no convection.</p></subsection></section><spacer><p>-</p></spacer><section><sectionhead><li>How do orographic triggers effect conditionally unstable air?</li>
    			</sectionhead>			
    					<subsection><p>The illustration shows the condition of rising air against an ELR of about 2 degrees C/1000ft.If the air was forced to rise and keep on rising it would cool first at the DALR until it reaches its dew point, and then cloud would begin to form If it is forced to rise further it cools at the SALR. It is not yet unstable</p>
    				</subsection>
    			</section>
    		</page>

    If it's at all possible, could you possible adjust your original code so that I can keep the formatting of the XML .... I figure that if I can get the style looking great by loading the XML on the first frame, there must be a way I can keep the style by clicking a menu option.

    Please help sir, I have just 4 hairs left and would rather just get this out of the way so I can have some kind of life.

    Cheers dog... For everything.
    Stagehand

  6. #26
    Member
    Join Date
    Jun 2000
    Posts
    97
    Sorry, this is the full code of the XML file.... Post was too long I think:

    Code:
    	<page>
    		<header><p>Orographic Triggers</p></header>
    			<spacer><p>-</p></spacer>
    <section>
    <sectionhead><li>What are orographic triggers?</li></sectionhead>
    <subsection><p>If the air mass is absolutely unstable any rising ground will trigger immediate convection, which will continue on up, forming cloud, when the rising air cools to its dew point. If the air is very dry, cloud may never form, but the convection will still be present. Glider pilots call this "blue thermals". If the air is absolutely stable, then no matter how high the mountains, the air will sink back down on the lee side, and there will be no convection.</p></subsection>
    </section>
    <spacer><p>-</p></spacer>
    <section><sectionhead><li>How do orographic triggers effect conditionally unstable air?</li></sectionhead>
    <subsection><p>The illustration shows the condition of rising air against an ELR of about 2 degrees C/1000ft.If the air was forced to rise and keep on rising it would cool first at the DALR until it reaches its dew point, and then cloud would begin to form If it is forced to rise further it cools at the SALR. It is not yet unstable</p></subsection>
    		</section>
    </page>
    Stagehand

  7. #27
    Member
    Join Date
    Jun 2000
    Posts
    97
    Can you bale me out on this please dog?

    If not then can you please let me know, I'm wearing out the refresh button on my browser
    Stagehand

  8. #28
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    Yesterday 5:08 post
    please explain where you wish this xml file to load
    to the Tree ? (not poss. with html tags)
    to the TextArea ? (poss. with code mods)
    you want the <p> and <li> tags maintained ?

  9. #29
    Member
    Join Date
    Jun 2000
    Posts
    97
    Hi dog,

    Yes, in the text area please.... And to keep the formatting if you can .... As I say, the first frame on load works great for the text area with the formatting etc ....

    So, if you get that going and also let me keep control of loading the XML images that would be great ....

    Basically it needs to consist of one XML file loading into my_ta and one xml file loading into my_ldr all from the tree xml menu.....

    Man, if you can sort this out that would be SO cool .....

    Thanks dog .....
    Stagehand

  10. #30
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    i have attached a sample file for you
    the xml file uses CDATA elements
    the .fla pushes the nodes into an array
    the TextArea loads from the array

    test to see it working, then modify your project to suit

    hth
    Attached Files Attached Files

  11. #31
    Member
    Join Date
    Jun 2000
    Posts
    97
    Dog, that works a treat, but as you have already guess, I'm as thick as two short planks ....

    Where would I put this code? In the action keyframe where the tree is loaded? Over the code ou originally gave me?

    You've got the action calling the page.xml, so how would that work in conjunction with the tree I need loaded.

    The styling too is CSS based, which I've called in the first frame, so I'm guessing I can't use that? Which is a bit of a bind as the guy who is writing the XML, is going to be working from the simple XML template I finally provide ...

    Also, how does this effect the image loading into my_ldr ....

    I know I'm a pain dog, but I've been on this 2 weeks now and it really is getting me down.

    I'm tempted just to create a movie clip with 10,000 keyframes and just load the XML files individually via the keyframe , LOL.....

    Sorry for being a pain mate, and for being an idiot ..... I really thought this would be a simple thing to do ...

    Is there not just a script I can use to change the content much like before?

    As I say, when using OnLoad, the XML loads in perfectly ... It's just this bloody tree, which I refuse to work with again.
    Last edited by stagehand; 11-30-2007 at 10:23 AM.
    Stagehand

  12. #32
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    sample file attached
    Attached Files Attached Files

  13. #33
    Member
    Join Date
    Jun 2000
    Posts
    97
    OH, so close, so close.

    OK, here is my project:

    http://rapidshare.com/files/73340774/tree_xml.zip.html

    If you click on section 5-2 and then 5-6, you'll see the problem....

    Getting the image loading back I assume will be easy?????

    Almost there dog, and you'll not have to worry about me for another 6 months when I take on another project I've no clue about what to do ;o)

    Thanks mate, seriously


    1st keyframe ... Loading the XML, I changed it so I could see the new content load .... instead of 5_2_.xml it should be 5_2_l.xml
    Last edited by stagehand; 11-30-2007 at 11:25 AM.
    Stagehand

  14. #34
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    response from your link -
    Network Error (tcp_error)
    A communication error occurred: ""
    The Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests. You may wish to try again at a later time.
    Sorry but i have little time for downloading fix-em-ups
    can you not modify all of the info supplied so far ??

  15. #35
    Member
    Join Date
    Jun 2000
    Posts
    97
    I will try obviously .... But if you could also take a look over the weekend or when you have a little time just in case I can't fix it that'd be great.

    I can smell the finish and it's exciting I can tell you .....
    Stagehand

  16. #36
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    took a quick look in my tea-break
    File cannot find - distance.css
    you have not implemented CDATA in xml files
    to clear previous text - frame#29, line#26

    function loadContent(file){
    my_ta.text = "";
    ....
    };

  17. #37
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    took a quick look in my tea-break
    File cannot find - distance.css
    you have not implemented CDATA in xml files
    to clear previous text - frame#29, line#26

    function loadContent(file){
    my_ta.text = "";
    ....
    };

  18. #38
    Member
    Join Date
    Jun 2000
    Posts
    97
    Sorry, this is the small style for distance.css ..... I included main.cc by mistake, apologies:

    Code:
    header {
    font-family: Geneva;
    font-size: 36px;
    font-weight: bold;
    color: #5A6FA9;
    display: block;
    }
    sectionhead{
    font-family: Geneva;
    font-size: 24px;
    font-weight: bold;
    color: #5A6FA9;
    display: block;
    
    }
    subsection{
    font-family: Geneva;
    font-size: 16px;
    font-weight: bold;
    color: #7D7D7D;
    display: block;
    margin-left:40px;
    }
    spacer{
    font-family: Geneva;
    font-size: 12px;
    color: #ffffff;
    display: block;
    }
    My bad on the CDATA .,... I'm an idiot I know .... Totall forgot about that .... Too tired.

    Yes, still loads in lovely .... However, whenever I click a second file to load into it (just duplicated section1.xml etc ...) It just adds to the textArea instead of replacing it.

    Also, the onload no longer works, but that's not really an issue ... I can work around that with content.....
    Stagehand

  19. #39
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    adds to the textArea instead of replacing it.

    as per prev. post - clear the field first -

    function loadContent(file){
    my_ta.text = "";
    ....
    };

  20. #40
    Member
    Join Date
    Jun 2000
    Posts
    97
    Hey dog, hope you had a good weekend. Sorry for the delay in responding.... Internet connection down all weekend grrrr...

    Ok, I'm getting actionscript error with

    function loadContent(file){
    my_ta.text = "";
    ...
    };

    I've removed the error which was '...'

    Where do I put this code? As wherever it goes in frame 29 it doesn;t work.
    Stagehand

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