How to load external png image via xml?

Can someone help me with the addition of a png image to a mc with an instance name.

I want only to display a single image (no Gallery)

I would like to get the url of the image via an xml.

Here's a copy of my current action script which has already pulled in xml data that includes the node with the url of the photo.

import flash.events.Event;

import flash.events.MouseEvent;

import flash.net.URLLoader;

import flash.net.URLRequest;

var myXML:XML;

var myLoader:URLLoader = new URLLoader();

myLoader.load (new URLRequest ("links.xml"));

myLoader.addEventListener (Event.COMPLETE, processXML);

function processXML(e:Event):void

{

myXML = new XML (e.target.data);

trace (myXML);

menumv.carbtn.addEventListener (MouseEvent.CLICK, openCURL);

menumv.edubtn.addEventListener (MouseEvent.CLICK, openEURL);

menumv.psybtn.addEventListener (MouseEvent.CLICK, openPURL);

menumv.stubtn.addEventListener (MouseEvent.CLICK, openSTURL);

menumv.busbtn.addEventListener (MouseEvent.CLICK, openBURL);

menumv.shabtn.addEventListener (MouseEvent.CLICK, openSURL);

studentmv.stuname.Text = myXML.student.name;

}

function openCURL(e:MouseEvent):void

{

navigateToURL (new URLRequest (myXML.car.url));

}

function openEURL(e:MouseEvent):void

{

navigateToURL (new URLRequest (myXML.edu.url));

}

function openPURL(e:MouseEvent):void

{

navigateToURL (new URLRequest (myXML.psy.url));

}

function openSTURL(e:MouseEvent):void

{

navigateToURL (new URLRequest (myXML.stu.url));

}

function openBURL(e:MouseEvent):void

{

navigateToURL (new URLRequest (myXML.bus.url));

}

function openSURL(e:MouseEvent):void

{

navigateToURL (new URLRequest (myXML.sha.url));

}

And here's a copy of the node that contains the url

<menu>
    <student>
    <name>testnamehere</name>
    <photo>http://10.0.0.2/test/photos/testnamephoto.jpg</photo>
    </student>
</menu>

I saw this tutorial but it was for a gallery, and I couldn't not to hack and slash to do what I want.

http://Tuts.flashmint.com/creating-a-simple-XML-Gallery-in-ActionScript3/

Thanks again in advance for any help.

Check if this gives null if yes it would output menu.student.photo

trace (Student.photo)

var _request:URLRequest = new URLRequest (student.photo);

var _ldr = new Loader();

MC's movieclip where you add your image

mc.addChild (_ldr);

_ldr. Load (_REQUEST);

_ldr.contentLoaderInfo.addEventListener (Event.COMPLETE, load_complete, false, 0, true);

function load_complete (event): void

{

whatever it is may be melted in the image

}

Tags: Adobe Animate

Similar Questions

  • Loading a single Image Via XML

    Hey guys, I'm trying to load an image to step through an xml file.

    Here is my xml file

    <? XML version = "1.0" encoding = "utf-8"? >
    < photos >
    Image1.jpg < pic > < / pic >
    < / photos >

    I am trying to understand the ActionScript 3, but I don't know how to code.

    If someone can tell me please the tutorial or code, it would be much appreciated.

    I said to these last lines in the xmlLoaded function, then all of the code would read as follows:

    var req:URLRequest = new URLRequest ("xmlfilename.xml");
    var ldr:URLLoader = new URLLoader();
    ldr.addEventListener (Event.COMPLETE, xmlLoaded);
    LDR. Load (req);
    function xmlLoaded(e:Event) {}
    var XML = XML (e.target.data);
    var imgreq:URLRequest = new URLRequest(xml.pictures.pic[0]);
    var imgldr:Loader = new Loader();
    imgldr. Load (imgreq);
    addChild (imgldr);

    }
    It's code for e-mail or incidentally, but could well still work! I don't want to have all the fun, you should have some too, by fixing something I spelled wrong.
  • How to load external images and animate it after it is loaded?

    I know how to load external images using xml, but the problem is that if I have a lot of images to load then animate after it is loaded. I know theres a work around to this problem but still I have not understand.

    Thanks for help.

    You will need to use the MovieClipLoader class.  It supports have a headset which allows you to determine when the image has loaded so that you can act on it.

    If you are looking for the MovieClipLoader.addEventListener methoid (), there is an example that will be useful to see how to configure things (it's not your scenario, but a good reference).

  • To load a png image using img_load_file()

    I'm trying to load a png image file in my application to screen_blit later to a window.  I have a few questions:

    1. How can I find the full path to a file in my package?

    2. can I use img_load_file to decompress a png in RGBA8888 fits the image uncompressed bitmap blitting.   Someone at - it a code snippet, I can consult?

    Thanks in advance.

    Hello

    Try the following steps to load the image file in your application.

    First, add your image file in bar - descriptor.xml file in active tag

    and give the path of the file as 'app/native/imagefilename. " I hope it will work for you.

  • How to disable the PNG Images

    How to disable the PNG Images?

    PNG is a format for images (compressed) as JPG format. There is no way to disable this format.

    If you have a problem with images on web pages, then you will need to block images from certain domains.

    You can watch the Adblock Plus extension to block specific content.

    You must subscribe to a list of filters (for example the EasyList).

  • How to load a scanned image to facebook?

    How to load a scanned image to facebook?

    I don't know, but I'm sure that the answer will not associate Adobe Reader.

  • Loading external png with transparency

    Hello

    Im trying to create a system of navigation with a few buttons as3.0.

    Each button is a png image.

    When the import of images to the stage im I don't have problems of transparency, but the problem is that they are enough, not smooth not especially

    because im animating the using TweenLite.

    I thought that the only way to do this correctly is to load all images using as3 in bitmap objects and then use the smoothing property.

    The problem is that whenever I attribute the png to a bitmap object, I lose the transparency of information and get a white background...

    Anyone know how I can keep transparency information of png on the bitmap object?

    Thank you

    Here is a little code that loads a PNG with transparency, it softens and placed on stage.

    var a: Loader = new Loader();
    a.Load (new URLRequest ("spider.png"));
    a.contentLoaderInfo.addEventListener (Event.COMPLETE, done);

    function done (e: Event) {}
    var bit: image Bitmap = e.target.content;
    If (bit! = null) {}
    bit. Smoothing = true;
    }
    addChild (bit);
    }

  • How to load and place images dynamically

    I have a problem with loading images dynamically. I want to import a series of images and the display in the order across the screen. The images will have different widths, so it is important to know the width of each imported image as IM will place an image immediately to the right of the previous image. I thought that the code below would control the presentation, but the event handler seems to work (perhaps partly because the images are different sizes) not well.

    What should I do to control the positioning of the images?

    Thnks a lot.

    XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML "layout ="absolute"creationComplete =" init () "> "
    < mx:Script >
    <! [CDATA]
    Mx.events import. *;
    private var imageLoader:Loader
    private var imageX:Number = 0;
    public void init (): void {}
    for (var i: int = 0; i < 4; i ++) {}
    imageLoader = new Loader();
    var url: String = "images/animal" + i + ".png";
    var urlReq:URLRequest = new URLRequest (url);
    imageLoader.load (urlReq);
    trace ("image =" + URL)
    container.addChild (imageLoader);
    imageLoader.contentLoaderInfo.addEventListener (Event.COMPLETE, imageLoaded);
    }
    }
    public void imageLoaded(e:Event):void {}
    imageLoader.x = imageX;
    trace ("imageloader.x =" + e.Target.Width);
    imageX += e.target.width
    imageLoader.y = 100
    }
    []] >
    < / mx:Script >
    < mx:UIComponent id = "container" / >
    < / mx:Application >

    Unless I'm mistaking completely your goal, you do the way of things too hard on yourself.

    Install a HBox and addChild() to add images to that:

    (I made a few changes to make it work for me locally in order to do not copy/paste).

         
              
         
    
         
    

    In addition, you need to use the charger because it has other ways to load images, e.g., you can create a new Image, as I do above and set the source property to the path of the file, or you can embed images, but I guess that is not an option.

  • using CC 2014 last PS how to take a png image and fade

    Last PS CC 2104, I have a low third title text png file name which is around 2/3 on the bottom screen - I need to disappear the last 1/3 of it... how?

    Assuming you want to fade to transparency, use a layer mask and a black-white gradient.  The luminance values darker on a layer mask make the image more transparent.

    That, once saved as a PNG image looks to...

    -Christmas

  • dynamic load text and image of XML. How?

    Hello

    I have the following code to display text and images on the screen how modify the code to make it more dynamic:

    var xmlData:XML = new XML(MovieClip(this.parent).xmlDocs[3]);
    // Add Title
    rssNews.rss1.title1.text = xmlData.news[0].title;
    rssNews.rss2.title2.text = xmlData.news[1].title;
    rssNews.rss3.title3.text = xmlData.news[2].title;
    rssNews.rss4.title4.text = xmlData.news[3].title;
    rssNews.rss5.title5.text = xmlData.news[4].title;
    rssNews.rss6.title6.text = xmlData.news[5].title;
    rssNews.rss7.title7.text = xmlData.news[6].title;
    rssNews.rss8.title8.text = xmlData.news[7].title;
    rssNews.rss9.title9.text = xmlData.news[8].title;
    rssNews.rss10.title10.text = xmlData.news[9].title;
    
    
    // Add Description
    rssNews.rss1.text1.text = xmlData.news[0].description;
    rssNews.rss2.text2.text = xmlData.news[1].description;
    rssNews.rss3.text3.text = xmlData.news[2].description;
    rssNews.rss4.text4.text = xmlData.news[3].description;
    rssNews.rss5.text5.text = xmlData.news[4].description;
    rssNews.rss6.text6.text = xmlData.news[5].description;
    rssNews.rss7.text7.text = xmlData.news[6].description;
    rssNews.rss8.text8.text = xmlData.news[7].description;
    rssNews.rss9.text9.text = xmlData.news[8].description;
    rssNews.rss10.text10.text = xmlData.news[9].description;
    
    
    // Add Title
    var myLoader:Loader = new Loader();
    var fileRequest:URLRequest = new URLRequest(xmlData.news[0].image);
    myLoader.load(fileRequest);
    rssNews.rss1.image1.addChild(myLoader);
    var myLoader2:Loader = new Loader();
    var fileRequest2:URLRequest = new URLRequest(xmlData.news[1].image);
    myLoader2.load(fileRequest2);
    rssNews.rss2.image2.addChild(myLoader2);
    var myLoader3:Loader = new Loader();
    var fileRequest3:URLRequest = new URLRequest(xmlData.news[2].image);
    myLoader3.load(fileRequest3);
    rssNews.rss3.image3.addChild(myLoader3);
    var myLoader4:Loader = new Loader();
    var fileRequest4:URLRequest = new URLRequest(xmlData.news[3].image);
    myLoader4.load(fileRequest4);
    rssNews.rss4.image4.addChild(myLoader4);
    var myLoader5:Loader = new Loader();
    var fileRequest5:URLRequest = new URLRequest(xmlData.news[4].image);
    myLoader5.load(fileRequest5);
    rssNews.rss5.image5.addChild(myLoader5);
    var myLoader6:Loader = new Loader();
    var fileRequest6:URLRequest = new URLRequest(xmlData.news[5].image);
    myLoader6.load(fileRequest6);
    rssNews.rss6.image6.addChild(myLoader6);
    var myLoader7:Loader = new Loader();
    var fileRequest7:URLRequest = new URLRequest(xmlData.news[6].image);
    myLoader7.load(fileRequest7);
    rssNews.rss7.image7.addChild(myLoader7);
    var myLoader8:Loader = new Loader();
    var fileRequest8:URLRequest = new URLRequest(xmlData.news[7].image);
    myLoader8.load(fileRequest8);
    rssNews.rss8.image8.addChild(myLoader8);
    var myLoader9:Loader = new Loader();
    var fileRequest9:URLRequest = new URLRequest(xmlData.news[8].image);
    myLoader9.load(fileRequest9);
    rssNews.rss9.image9.addChild(myLoader9);
    var myLoader10:Loader = new Loader();
    var fileRequest10:URLRequest = new URLRequest(xmlData.news[9].image);
    myLoader10.load(fileRequest10);
    rssNews.rss10.image10.addChild(myLoader10);
    
    
    // Add URL
    rssNews.rss1.info1.addEventListener(MouseEvent.CLICK, rss01);
    rssNews.rss2.info2.addEventListener(MouseEvent.CLICK, rss02);
    rssNews.rss3.info3.addEventListener(MouseEvent.CLICK, rss03);
    rssNews.rss4.info4.addEventListener(MouseEvent.CLICK, rss04);
    rssNews.rss5.info5.addEventListener(MouseEvent.CLICK, rss05);
    rssNews.rss6.info6.addEventListener(MouseEvent.CLICK, rss06);
    rssNews.rss7.info7.addEventListener(MouseEvent.CLICK, rss07);
    rssNews.rss8.info8.addEventListener(MouseEvent.CLICK, rss08);
    rssNews.rss9.info9.addEventListener(MouseEvent.CLICK, rss09);
    rssNews.rss10.info10.addEventListener(MouseEvent.CLICK, rss10);
    
    
    function rss01(e:MouseEvent):void
    {
              navigateToURL(new URLRequest(xmlData.news[0].url));
    }
    function rss02(e:MouseEvent):void
    {
              navigateToURL(new URLRequest(xmlData.news[1].url));
    }
    function rss03(e:MouseEvent):void
    {
              navigateToURL(new URLRequest(xmlData.news[2].url));
    }
    function rss04(e:MouseEvent):void
    {
              navigateToURL(new URLRequest(xmlData.news[3].url));
    }
    function rss05(e:MouseEvent):void
    {
              navigateToURL(new URLRequest(xmlData.news[4].url));
    }
    function rss06(e:MouseEvent):void
    {
              navigateToURL(new URLRequest(xmlData.news[5].url));
    }
    function rss07(e:MouseEvent):void
    {
              navigateToURL(new URLRequest(xmlData.news[6].url));
    }
    function rss08(e:MouseEvent):void
    {
              navigateToURL(new URLRequest(xmlData.news[7].url));
    }
    function rss09(e:MouseEvent):void
    {
              navigateToURL(new URLRequest(xmlData.news[8].url));
    }
    function rss10(e:MouseEvent):void
    {
              navigateToURL(new URLRequest(xmlData.news[9].url));
    }
    
    

    Kind regards

    use:

    var xmlList:XMLList;

    var xmlData:XML = new XML (MovieClip (this.parent) .xmlDocs [3]);

    xmlList = xmlData.news;

    for (var i: int = 0; i<>

    {

    rssNews ["rss" +(i+1)] ["title" +(i+1)] .text = xmlList [i] .title;

    rssNews ["rss" +(i+1)] ["text" +(i+1)] .text = xmlList [i] .description;

    rssNews ["rss" +(i+1)] ['image' +(i+1)] .loader = new Loader();  If the compiler complains, cast rssNews ["rss" +(i+1)] ['image' +(i+1)] as a movieclip.  IE: MovieClip (rssNews ["rss" +(i+1)] ['image' +(i+1)]) .loader

    rssNews ["rss" +(i+1)] ['image' +(i+1)].loader.load (URLRequest (xmlList [i] .url)) of new;

    }

  • How to display a PNG image according to the response from the Web Service?

    Hello

    I use the web service XML from Weather.com to get the current temperature, temperature 'feels' and the current condition icon number.  Their service provides many (> 20 I think) which represents the current status of PNG files.  How do I install my script AS3 do basically if... then Else instructions based on the returned value icon?  For example, if the value of icon = 20, then view 20. png on stage?  I need match the value of correct PNG icon and then put that PNG (as a clip?) on stage for a predefined timeline section.

    Thank you

    SID

    Hello

    I also used this API, and I only use cases or conditions in order to retrieve the values and turn them into a file name.

    If you do not use all the available conditions and turning them into an icon, then Yes, you need to do a switch condition.

    But if you want to use them all, them you can simply get the condition number and add the '.png' and call the corresponding file directly. Here you can do a test, just in case the condition / icon does not exist (e.g. system failure any)

    uicondition.source = String (resultXML.cc.icon) + ".png";

    The UILoader is an excellent component for this sort of thing. You can accomplish the same thing with a MovieClip and load an image. It is lighter.

    But then again if you want to resize you would code all methods for that.

    I hope this helps.

  • How to load and display Image

    Hello everyone.

    I type with very green fingers, so please excuse the question. Lessons learned from the examples, I tried to load and display an image in ActionScript. This is the original example that I work on:

    ...

    ...

    var bmd2:BitmapData = bmd.clone ();

    var infoBM:Bitmap = new Bitmap (bmd2);

    var back: MovieClip = new MovieClip();

    Back.Name = 'back ';

    back.rotationX = - 90;

    var bSurface:MovieClip = new MovieClip();

    bSurface.y = int (...

    bSurface.z = int (...

    bSurface.addChild (infoBM);

    var overlay: Sprite = new Sprite();

    overlay.graphics.beginFill (...);

    overlay.graphics.drawRect (0, 0, bSurface.width, bSurface.height);

    overlay.graphics.endFill ();

    bSurface.addChild (overlay);

    back.addChild (bSurface);

    var tf:TextField = new TextField();

    TF...

    TF...

    TF...

    bSurface.addChild (tf);

    ...

    ...

    I'm trying to place an image on the bSurface instead of the block of text, as described above. So far, I came with:

    var iSprite:Sprite = new Sprite();

    var iMatrix:Matrix new matrix());

    var bmData:BitmapData;

    bmData = new BitmapData (surface.width, surface.height, true, 123);

    var loader: Loader = new Loader();

    loader.contentLoaderInfo.addEventListener (Event.COMPLETE, onComplete);

    Loader.Load (new URLRequest("c:\pixlr.png"));)

    function onComplete (event: Event): void

    {

    bmData = Bitmap (content LoaderInfo (event.target)) .bitmapData;

    }

    iMatrix.tx = 0;

    iMatrix.ty = 0;

    iSprite.graphics.beginBitmapFill (bmData, iMatrix, false, true);

    iSprite.graphics.drawRect (0, 0, surface.width, surface.height);

    iSprite.graphics.endFill ();

    surface.addChild (iSprite);

    ... and:

    var bmData:BitmapData;

    bmData = new BitmapData (surface.width, surface.height, true, 123);

    var loader: Loader = new Loader();

    var location: URLRequest = new URLRequest ("c:\pixlr.png");

    Loader.Load (rental);

    bmData = Bitmap (loader.content) .bitmapData;

    surface.addChild (bmData);

    but without success. I've been fails miserably for days now and would appreciate help.

    Thanking you in advance,

    Sofia.

    what you trying to do?

    If you just try to load an image (pixlr.png), use a relative path and something like:

    var loader: Loader = new Loader();

    Loader.Load (new URLRequest ("pixlr.png"));  put the png in the same directory with your fla and published files.  You can move after getting this work simpler example

    addChild (loader);

  • Do not load the .png images

    I load the images from RSS feeds, it works perfectly with the images .jpg, but not PNG or any other format. Here is my code:

    function getImgUrl(str:String):String {}

    var model: RegExp = / SRC =------"([^ \"] + \.jpg | gif | tiff | jpeg | png) /ig; "

    can someone help me please.

    Thank you

    Naveen

    Expression is missing brackets - there need to alterations of the group. It should be:

    /src=\"([^\"]+\. (jpg |) gif | TIFF | JPEG | (png ()) / ig;

  • Loading external as file via url

    Hello

    I have external actionscript files that I call like this:

    #include '... / events/allevents.as.

    But if I want to reach inport the full URL that is
    #include " " http://www.essentialeventsmanagement.com/events/AllEvents.as "he locates the file even if it is the correct URL. How can I set this up so he always calls the server and not my local as a file
    Thank you
    Mark

    You can load the dynamically compiled code (by loading a swf file), but you cannot compile dynamically.

  • How can I add PNG image using custom?

    Hi guys,.

    It's my custom component.

    <components:EmployeeDisplay imageFile="abrilliam.png"/>


    Can you help me please how to add png format image.
    when i add png format image that time this image not displayed.
    what can i do?


    Thanks
    JaxNa

    Hi Jaxna,

    In your code below custom component, I could see no imageFile variable declared...


    http://ns.Adobe.com/MXML/2009.
    xmlns:s = "library://ns.adobe.com/flex/spark".
    xmlns:MX = "library://ns.adobe.com/flex/mx" >
          
       
    source = "images / {imageFile}" / > "
        
       

    Have you declared the imageFile variable in your component file above... check it out?

    If it is then declared to declare a variable of datatype Sttring imageFile and make Bindable...

    [Bindable] private var imageFile:String ="";

    Your new component code must therefore:


    http://ns.Adobe.com/MXML/2009.
    xmlns:s = "library://ns.adobe.com/flex/spark".
    xmlns:MX = "library://ns.adobe.com/flex/mx" >

    [Bindable] private var imageFile:String ="";


    source = "images / {imageFile}" / > "
        
       

    Also check the path to the image once... If it is given the correct path of the hierarchy...

    Thank you

    Jean Claude Chari

Maybe you are looking for

  • Equium L20: How to install memory

    I need to install 1 GB memory in my laptop. I had to remove the cover of the memory but cannot figure out how to undo the devices and access/install memory. Can someone give me details... Thank you.

  • Case structure design

    Hi all I am developing a small program. The entries are 3 values (integers): x, y, z How should I design the program to determine: 'Is there any LOWER value to 25% of the HIGHEST value?', if so, exclude this value. Kind regards Adrian

  • Xbox 360 Media Center extender 545 error code

    Hello everyone I thought I'd ask my question here as nowhere else. The problem is, my xbox 360 has benn works fine it's just the media library. Whenever I try to add as an Extender happens to the part where it sets up my xbox and it says error and it

  • Harder and harder to get the machine going. Below error messages.

    My computer was becoming progressively more difficult and harder to go there every day. When I get an error code is as below. I do not always get one. Most of the time it will allow me to make the sign of the screen. However, after that it will freez

  • BlackBerry bold 9700 sd card inside the phone key smartphones

    help put the sd card in the phone and it has gone inside!