dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: insert an image within the xml

  1. #1
    aidanmack.co.uk
    Join Date
    Dec 2001
    Location
    York, UK
    Posts
    400

    insert an image within the xml

    Hi,
    Im very new to this xml stuff.
    Basically i have finished the tutorial over at www.gotoandlearn.com on creating a carousel and using xml to pull the images and code in.
    Works a treat!
    i understand I need to create a empty movieclip for any images i pull in from xml to sit in.
    But what if i wanted an image in the middle of some text?

    i thought about this...

    <content="my coments blar blar blar blar <icon image="driving-t-extra.png" blar blar blar blar blar" />

    but i didnt think that would work either, as flash would need a empty movie clip to put "driving-t-extra-.png" into. unless it was able to create a movieclip on the fly???

    i also thought about insert just a html tag like this....
    <img src="file:///C|/charlotte.gif" width="466" height="691" />

    In the hope that if i put render as html on in flash it might pick it up as a image but that didnt work either.

    can anyone help with that?

  2. #2
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    You're going about it wrong. Post your completed files (from your tutorial build...the .fla) including backend(xml) as a zip and someone will show you how to do it.

  3. #3
    aidanmack.co.uk
    Join Date
    Dec 2001
    Location
    York, UK
    Posts
    400
    Ok so this is everthing, and it works.
    Basically i want to know if theres some way of inserting an image with the main text when a icon is clicked on.

    ...Please excuse my notes within the fla! i was typing that as i was watching the tutorial! lol... they make sense to me!

    cheers
    Aidan
    Attached Files Attached Files

  4. #4
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    http://flashnow.servebbs.com/examples/menu4upload/

    What I did for my example is to reuse your icon images (I'm basically lazy ) to push to the textfield. Feel free to add an attribute to the xml later if you need an image seperate from the icon.

    Added a reference to the image attribute value read from xml

    Code:
    t.image = nodes[i].attributes.image;
    Converted the text push from standard text to htmlText and concatenated (inline combined) the t.image value to the t.content value :

    Code:
    theText.htmlText= "<img src=\""+t.image+"\" width=\"128\" height=\"128\"/><br><br>"+t.content;

    Now...all your icons are 128x128 so I hard coded the value. If your images are of varying sizes you will need to add two attributes to each node in the xml for width/height and add that to the routine where I added the t.image and add that to the concatenation routine in place of the hard coded width/height.

    Code:
    t.width = nodes[i].attributes.width;
    t.height = nodes[i].attributes.height;

    All of this was done to accomodate your attribute flavor of xml. If the xml were setup differently we could wrap the entire content value in a CDATA tag but that is neither here nor there. At least this way you get to use what you coded as is. Hope it helps
    Attached Files Attached Files

  5. #5
    aidanmack.co.uk
    Join Date
    Dec 2001
    Location
    York, UK
    Posts
    400
    Thanks for your time Chris,
    Thats kind of what im after.
    I think what it comes down to is, every time i want a new image, in a new postion within my flash file i am going to do some coding somewhere with in the .fla i caunt just code it in the xml and have that sort out the position.

    but thanks for your help. I like it how u have combined the t.image and t.content. wouldnt of known how to do that.
    so thanks!

    Aidan

  6. #6
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    I like the movie. Using the attribute style is very common and I imagine was perfect for what that movie did. Adding images to the textfield (or as part of the article text) can be accomplished as you see using the attributes and with some creative thinking you can send in image names, widths, heights, x/y values or anything else that would help you direct each image wherever you want. As part of the textfield I just piggybacked (concatenated) it so it would not screw up what you've already coded but definitely look into CDATA tagging which would allow you to code those "content" articles with full html tagging (well...within the limit of tags flash accepts ) right in the xml. Good luck !!

  7. #7
    aidanmack.co.uk
    Join Date
    Dec 2001
    Location
    York, UK
    Posts
    400
    Thanks Chris, You have showed me alot. will defo look in to CDATA. Maybes what i could do is have the x/y/size of image as variables in xml which could them be used to update this line of code
    theText.htmlText= "<img src=\""+t.image+"\" width=\"128\" height=\"128\"/><br><br>"+t.content;

    would b good.

    thanks again.

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