Dynamic embed images?

Hi,
Here is one of ways to embed image in Flex:
[Embed (source="img0.jpg")]
public var Img0:Class;
But I want to embed a bunch of images, is there a syntax like this, or a better coding method?
for (var i:int = 0; i<10; i++) {
    var img:Image = new Image();
    img.source = [Embed('img' + i +'.jpg')];
Thanks for reply.

Embed is for compile time, so, it is not possible to do what you are trying to do. But using the same concept, you can load images dynamically as shown below.
for (var i:int = 0; i<10; i++) {
    var img:Image = new Image();
    img.source = "http://someurl.com/path/image"+i+".jpg";

Similar Messages

  • How to embed images dynamically?

    HI all , I'm new to flex.
    Here is what I've already done, I use
    [Bindable]   
    [Embed(source="images/xxx.jpg")]
    private var img:Class;
    to embed several images in an application.
    But the source of these images can not be determined until the run time, I got image's url dynamically, and used some variables to store them. For example, an url may refers to an url
    var url:String = "images/xxx.jpg";
    Then I think it's possible to give its value to an image source by using
    [Bindable]   
    [Embed(source=url)]
    private var img:Class;
    However,it doesn't work. there is a compile error, the description is:
    "url" does not have a recognized extension, and a mime type was not provided
    Unable to transcode url
    So what's the problem here, and could any one give me some advice to embed images dynamically?
    Thanks!

    HI
    I don't think you can embed an image dynamically as you need to know the path of the image when you use the embed tag.  The embedding takes place at compile time, and you app would need to be compiled into a swf before your code loads.
    If you need dynamc images in an application then its usually done by loading them when the app is running.  You do this by using for example a HTTP service to load in the image paths.  You can then view them by assigning them to an image tag through Actionscript.
    I hope that helps and I got the idea of what you were trying to do.
    Heres a quick example I used for someone else on swapping images from an arrayCollection.  You could do something like this and populate the arrayCollection using a HTTP service.  Or just access the xml from the HTTP directly for the image paths
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()" xmlns:local="*">
         <mx:Script>
              <![CDATA[
              import mx.controls.Button;
              import mx.collections.ArrayCollection;
    [Bindable]
    private var ac:ArrayCollection = new ArrayCollection([
    {imageTitle : 'Car 1', imageUrl : 'http://www.geekologie.com/2007/12/07/future-car-1.jpg'},
    {imageTitle : 'Car 2', imageUrl :'http://www.speedace.info/solar_cars/solar_car_images/Solar_Wing_front_Japanese_e lectric_powered_car.jpg'},
    {imageTitle : 'Car 3', imageUrl : 'http://www.dezeen.com/wp-content/uploads/2008/09/gem-peapod-car-by-chrysler-llc- et008_027evsqu.jpg'}
    private function showCar(num:int):void {
    img.source = ac.getItemAt(num).imageUrl;
    imgTitle.text = ac.getItemAt(num).imageTitle;
    ]]>
         </mx:Script>
         <mx:Image id="img" source="{ac.getItemAt(0).imageUrl}" width="426" height="243"/>
         <mx:Label id="imgTitle" text="{ac.getItemAt(0).imageTitle}"/>
         <mx:Button label="Button" click="showCar(0)"/>
         <mx:Button label="Button" click="showCar(1)"/>
         <mx:Button label="Button" click="showCar(2)"/>
    </mx:Application>
    Good luck
    Andrew

  • Embed images in one MovieClip, use in another?

    I apologize if you've already read this message. My question
    isn't only AS, not only Flash, not only Flex. It's in the
    mysterious area where the three come together. I posted this in the
    AS discussion, but think it might be better off here.
    Is it possible to embed images (jpgs) in one MovieClip, then
    load that SWF into another MovieClip and use those images in the
    loader? We are trying to avoid reloading an image each time we need
    it, but still load them dynamically. We'd like to do this:
    Container.swf:
    <mx:Application>
    <mx:Script>
    [Embed(source="images/myimage.jpg")]
    public var img: String;
    </mx:Script>
    </mx:Application>
    Then, load that SWF and use its embedded image:
    Loader.swf:
    <mx:Application>
    <mx:Loader id="container" source="Container.swf" />
    <mx:HBox>
    <mx:Image id="the_image" source="container.content.img"
    />
    </mx:HBox>
    </mx:Application>
    It looks like this should work, and the "resource" string is
    properly being passed to the_image (something like
    __Resource.43234564.myimage_jpg) but it cannot actually load; we
    get a broken image instead.
    I'm guessing I somehow need to register the object library of
    the Container.swf with my Loader.swf? How?
    Or, is this whole enterprise impossible?
    Thank you!
    Greg

    In Flash you may use 'export for runtime sharing' future. In
    Flex there
    must be a way also (look at adobe devnet topics)
    In Flash common problem is you can't control loading progress
    of this
    add-on. Preload first add-on to one movie without "export for
    runtime
    sharing" future with loader progress if you need it, then
    reload common
    movie to 'real' loader - add-on wil be taken from cache
    > I apologize if you've already read this message. My
    question isn't only AS,
    > not only Flash, not only Flex. It's in the mysterious
    area where the three
    > come together. I posted this in the AS discussion, but
    think it might be
    > better off here.
    >
    > Is it possible to embed images (jpgs) in one MovieClip,
    then load that SWF
    > into another MovieClip and use those images in the
    loader? We are trying to
    > avoid reloading an image each time we need it, but still
    load them dynamically.
    > We'd like to do this:
    >
    > Container.swf:
    > <mx:Application>
    > <mx:Script>
    > [Embed(source="images/myimage.jpg")]
    > public var img: String;
    > </mx:Script>
    > </mx:Application>
    >
    > Then, load that SWF and use its embedded image:
    >
    > Loader.swf:
    > <mx:Application>
    > <mx:Loader id="container" source="Container.swf"
    />
    > <mx:HBox>
    > <mx:Image id="the_image"
    source="container.content.img" />
    > </mx:HBox>
    > </mx:Application>
    >
    > It looks like this should work, and the "resource"
    string is properly being
    > passed to the_image (something like
    __Resource.43234564.myimage_jpg) but it
    > cannot actually load; we get a broken image instead.
    >
    > I'm guessing I somehow need to register the object
    library of the
    > Container.swf with my Loader.swf? How?
    >
    > Or, is this whole enterprise impossible?
    >
    > Thank you!
    >
    > Greg
    >
    >
    >
    >

  • MIME Multipart/related to embed images in html files - Servlet

    Hello,
    My goal is to embed images in html/xhtml files to decrease latency when using slow networks. Think about mobile phones, if I have 10 images in one page, I will have 11 requests/responses to get the whole page.
    The solution would be to embed all images using Content-type multipart/related, so I have one request to the whole pack.
    How to do that in java? I mean, I need to set the content-type and build all parts encoding the images to base64.
    I tried JavaMail API, there I can build messages like this and instead of send an e-mail, I can write:
    myMimeMultipart.writeTo(response.getOutputStream());
    The problem is: I am getting everything as text in my browser, including the MIME headers of each part. Another think is that the first header (the main one) doesn't appear too.
    Any thoughts/other ideas?
    Thanks in advance,
    Andr� Carlucci

    If memory serves me right, I believe in the Servlet spec you have access to the Response object. You "should" be able to set any headers you need there. In addition, you can get the output streams just as you described.
    I did a similar thing, although slightly modified, to output dynamically-generated XLS (Excel Spreadsheet) files using a reporting engine called JasperReports. It wasn't a multipart response, however, so you may need to figure out how to handle that part of it, but in my case I set the mime-type header, then grabbed the output and started writing my XLS file too it. Once done, you close the streams and return the response. Worked perfect.

  • Embed image into email (not attachments)

    Hi all,
    i need to embed images into an HTML table of an email.
    Can anyone help me, please?
    Sergio

    I have done this in a prior application.. Are you building an html style message?
    I have attached some ideas for you to try:
    define hidden page variable to get the url and location for the images files:
    p19_SERVER_STRING
    Source or expression:
    SELECT owa_util.get_cgi_env('REQUEST_PROTOCOL')||'://'||owa_util.get_cgi_env('HTTP_HOST')||owa_util.get_cgi_env('SCRIPT_NAME')||'/wwv_flow_file_mgr.get_file?p_security_group_id=4398899520272508996&amp;p_fname='
    FROM dual;
    (Security Group is from YOUR application)!!
    Next:
    In a After Submit process assemble the emial message:
    local variable lvMessage VARCHAR2(7500)
    Define message body in html document (Store in local varchar2 variable)
    <body>
    <p>
    <img height="90" hspace="0" src="'|| V('P19_SERVER_STRING')||'srtt_header.png' || '" " width="778" border="0" style="WIDTH: 931px; HEIGHT: 90px">
    </p>
    <p>
    </p>
    <p>
    Send the mseeage after you assemble the required pieces:
    HTMLDB_MAIL.SEND(
    P_TO => '[email protected]',
    P_FROM => '[email protected]',
    P_BODY => v_message,
    P_BODY_HTML => v_message,
    P_SUBJ => 'Your email with an Image');
    APEX_MAIL.PUSH_QUEUE;
    Thank you,
    Tony Miller
    Webster, TX

  • How to embed images in an INX file using script

    Hi All,
    Kindly help me in embedding images in INX file using Indesign Javascript.
    I have used the following code to embed images in an indd document and exporting that document to inx. But the images in inx are not embedded by default.
    var linksCount = myDocument.links.count();
    var linksOnPage = myDocument.links;
    for(var x=0;x<linksCount;x++){
        var linkedItem = linksOnPage.item(0);
        linkedItem.unlink();
    myDocument.save(new File("filename.indd"));
    myDocument.exportFile(ExportFormat.INDESIGN_INTERCHANGE, File("filename.inx"), app.pdfExportPresets.item("[Press Quality]"));
    Thanks in advance,
    Anitha

    Hi
    I think your script has two mistakes
    you embed only first link image in for loop => set x for linksOnPage
    exporting to inx isnot need PDF export preset => remove app.pdfExportPresets.item("[Press Quality]") from exportFile()
    this work for me.
    myDocument = app.documents[0];
    var linksCount = myDocument.links.count();
    var linksOnPage = myDocument.links;
    for(var x=0;x < linksCount;x++){
        var linkedItem = linksOnPage.item(x);
        linkedItem.unlink();
    myDocument.save(new File("filename.indd"));
    myDocument.exportFile(ExportFormat.INDESIGN_INTERCHANGE, File("filename.inx"));
    thank you

  • How to embed images in e-mail?

    How do you embed images in an e-mail?

    You can either place the cursor where you ant the image, go to the image on the screen, slect it and copy, change back to mail and paste. _OR_
    when composing, place the cursor wher you would like the image and Attach the file to the email.

  • How to embed image in email msg using MAC version of PSE

    I can embed an image as Photo Mail in email msg using WIN version of PSE8 but can only send the image as an attachment in MAC version. Is there a way to embed images in MAC version email msgs?

    Well, it's not complicated at all really. Just put the cursor in a message where you want the image and drop it in, or else click the stationery button in mail, choose a template, drag over the placeholder "greeking" text and replace it with your own, then drag your own photos into the placeholders. Here's a look at one of the templates. You can see that as my mouse is over the right hand image it tells you to put your own photo there in place of the sample. Moving over the other ones does the same thing.

  • How to embed images in long text of PM Notifications/Orders

    Dear Sir,
    How to embed images in long text of PM Notifications/Orders? Kindly help.
    Thanks & Regards
    PM Team.

    Hi,
      Unfortunately, You will not be able to view the graphics within the Long text editor screen.Only Limited word functionality is available on these editors.
      You will have to store these pictures separately as an attachment, through generic object services and then view them through that.
    Regards
    Narasimhan

  • Batch embed image in illustrator CS4

    I am working on about thousands ai files, each file have one image need to embed. My question is: Is there a way to embed the images at once? I usually open one ai files and select "embed image" in the links palette, is there a easy way to do this? Thanks!

    Thx Monika! I try your way on one file, it works! but I was not familiar with actions/script, I found a script named "Save as PDFs.jsx" under "Sample Scripts\JavaScript\Miscellaneous", so I replace PDF to AI in this script, does it works?

  • How to dynamically call image  in PDF for Acrobat ver 8.1 onwards?

    Hi Experts,
    I am using Web Dynpro Java. My requirement is to call the images dynamically on a PDF form. There are no of company code. I have to call different logos for different company codes/
    We are now using Acrobat 8.1.1. Please refer following thread.
    http://kb2.adobe.com/cps/405/kb405270.html
    From Acrobat 8.*, we have to use some different method for dynamically calling the images. Earlier we were using the concept mentioned below to dynamically call images.
    However this method is not applicable for Acrobat Reader 8.* onwards due to security reasons.
    Click on the Layout tab and choose None for the Caption position.
    u2022 Click on the Object, then the Binding tab and choose None for Default Binding.
    u2022 Click on the Field tab, enter $record.SapOnlineShopUrl for the URL entry, and select Use Image Size for the Sizing field.
    u2022 Click on the script editor and enter the following FormCalc script statement, which enables the dynamic integration of the image. Show: initialize Script: this.value.image.href = xfa.resolveNode(this.value.image.href).value; Language: FormCalc Run At: Client
    write following code in wddoinit
    try { String url = WDURLGenerator.getAbsoluteWebResourceURL( wdComponentAPI.getDeployableObjectPart(), "sap_online_shop.jpg"); wdContext.currentDataSourceElement().setSapOnlineShopUrl(url); } catch(Exception e) { throw new WDRuntimeException(e); }
    Please let me know what is the alternate method for Adope ver 8.1.1
    Regards,
    Gary

    Hi Gary,
    First you upload the image in SAP through se78.then write the below code in your adobe form interface.
    data :  v_object type  TDOBJECTGR value 'GRAPHICS',
            v_id  type TDIDGR  value 'BMAP',
            v_btype type TDBTYPE value 'BCOL',
            V_FIELD TYPE XSTRING.
    V_NAME = 'ZW_DEVMAN_LOGO'.
    CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
    EXPORTING
    p_object = v_object " 'GRAPHICS'
    p_name = v_name " Name of the logo as in se78
    p_id = v_id " 'BMAP'
    p_btype = v_btype " 'BCOL' ( whether the image is in color or black and white )
    RECEIVING
    p_bmp = v_field
    EXCEPTIONS
    not_found = 1
    internal_error = 2
    OTHERS = 3.
    g_logo = v_field.
    Declare g_logo as xstring in global data.
    In context of the form make one graphic element with field g_logo and mime type BMP.It will work.
    Regards,
    Simi A M
    Edited by: amsimi on Jan 26, 2011 5:30 AM

  • Trying to embed images from my iWeb site

    Sorry if this has been asked before but I did a search and could not find any answers.
    I upgraded from iLife 06 to 08 and managed to get a seamless transition of my iWeb site. The only problem now is that I seem unable to embed images from my site into other web pages on other sites. It used to be a case of copying and pasting the image address into the other web page. Now however it comes up with a very different looking image address that no longer ends with .jpg(jpeg) I have tried adding the .jpg to the end of the address without any success. Am I simply missing the obvious or is this feature no longer available?
    Thanks for any help

    Disable slideshow or not won't effect the way javascript render photos page images into canvas and anchor links.
    But, You can:
    1) get Safari 3.1.1, and turn on Develop menu. Safari -> Preferences... -> Advanced -> Show Develop menu in menu bar (bottom item). This allows you to see all the elements in the page.
    2) get Firefox, FF has DOM Inspector and Page Info.
    With the above, you will have to wade thru the info and fish out the links. or,
    3) using script to do the heavy lifting (scripting is your friends), there two free scripting languages: AppleScript and JavaScript in every mac.
    Combine the two and with understanding of iweb and DOM and you have the ultimate tools for iweb developing, here is the result of your first three links (I have all of them, but just post three here):
    http://web.mac.com/paullloydroach/Site/Landscapes2files/Media/morc1b%26w.jpg?derivative=web
    http://web.mac.com/paullloydroach/Site/Landscapes2_files/Media/mk26-2_0_22tonemapped.jpg?derivative=web
    http://web.mac.com/paullloydroach/Site/Landscapes2files/Media/Morecambe1.jpg?derivative=web

  • Displaying dynamically changing image: a problem with JLabel.

    Hello! I use NetBeans 5.5 and I develop my GUI with Matisse. I'm rather a beginner in developing GUIs with this editor...
    I'd like to display a dynamically changing image. The idea is: GUI shows the image, that is modified as some computations run in a different thread. App will be run on a single machine.
    I'm trying to display the image as a label's icon. The problem is that my app's frame can be resized - and when it is, the label also resizes. When the label is resized, the image should also be resized - the image should always be of the same size as the label. The problem? I noticed, that it works only when I make my app's bigger. When I try to lower its dimensions, the label's dimensions remain the same. Why the label don't make its size smaller?
    My code works as follows: when app's main frame is resize, the panel (the one, that the label is placed in) is also resized. And, since the label is in the panel, it (should) also be resized. So I wrote all the resize-events handlers (therefore I know that the resize event is sent when my app's frame is resized, and when the panel is resized - but the label is resized only when it grows bigger). In this methods I modify the image displayed in the label (I resize the image).
    Or, perhaps, there is some other way to show a (dynamically changing) image with Swing... I chose JLabel, because I didn't want to write my own JComponent. JLabel can display image and that is all I need. The problem is: when the label grows bigger, I create a new, bigger image (icon). Why my label don't get smaller (the resize event isn't even sent)?

    There is no component that dynamically resizes an image. You need to create your own. Something like this:
    JComponent component = new JComponent()
         protected void paintComponent(Graphics g)
              //  Scale image to size of component
              g.drawImage(yourImage, 0, 0, getWidth(), getHeight(), null);
    };

  • Handling dynamically generated Images

    Hello,
    I have a WDJ application that generates Images dynamically based on certain criterion. The dynamically generated images are put to the server using the code
      BufferedImage image = <rendered image ...>
      File outFile = new File( "Output.jpg") ;
      ImageIO.write( image, "jpg", outFile);
      /** Resource path is not set during the file creation 
       * as ImageIO throws IllegalArgumentException
    It gets saved to the folder <i><drive>\usr\sap\<SID>\JC<InstNo>\j2ee\cluster\server0\output.jpg </i> by default.
    Now, how to show up this dynamically generated image in a Image UI element? I have tried setting the output file name to the attribute that is bound to the "Source" property of the Image UI element but it doosn't show up as WD runtime is doing a look-up in the folder <i>../../../resources/com.test/<projectName>/Components/com.test.<componentName>/</i>
    Any pointers in this regard are highly appreciated.
    Bala

    Hi
    Try this
    Create the alias for the folder (C:\usr\sap\P13\JC00\j2ee\cluster\server0.)
    1.Goto Visual Administrator->Http Provider->Aliases in the Runtime Tab.
    2.Give the Alias Name and Path for the Folder.
    3.The Image sorce like http://<Server>:<Port>/<Alias>/<image>.<ext>
    Kind Regards
    Mukesh

  • Embed image in form not displayed

    I am trying to embed an image in the form i.e., point an image that is in my local workbench.
    While I was testing from my local Workbench/Designer.
    I created a process which receives input xml document and sends the pdf document as response.
    However, when I deploy my process on the EB3 server and try to get the PDF from the java code, here is what happens
    (1) There is a check box in the designer --> Embed Image.
    If I check this check box, then I get pdf damanged error and the pdf will not load in my servlet
    (2) If I don't check the check box, then the pdf come but the image is missing.
    I would appreciate if someone helps me to avoid the error and get the image in the pdf.
    Thanks
    Sudhakar Patnapu

    It should work fine in 5.4 It was known issue in 5.3.  I could not reproduce the issue on 5.4.  Are you encountering the same issue for OOB text image component ?  If so send the content of [1]. 
    [1]   /libs/cq/ui/widgets/source/endorsed/excanvas/excanvas.js

Maybe you are looking for

  • Multiple Apple IDs on one new iMac

    I'm relatively new to the apple world so pease excuse my lack of knowledge. I just bought a Mac and will be syncing an iPhone 5 and an iPhone 5c to it.  The two phones share one apple ID for iTunes, but each has a separate apple ID for the iCloud. I'

  • How can I block all other mail account just to only use the exchange mailbox of our company? This is to prevent the user to setup his on company iPhone.

    How can I block all other mail account just to only use the exchange mailbox of our company? This is to prevent the user to setup his on company iPhone.

  • Add a Page without adding top-level Navigation link

    How do you add a new page to a site without it auto-adding a link at the top of the page navbar? I need to add a link to a page from one of the main pages. One thing I lvoe about iweb is how intuitive and simple it is to make sites but I miss some of

  • Range function in HFR

    Is there a way to get the memeber name of the last member in a Range? I am using the Range function and summing up the range, ie. Range from Prompt for PeriodName to Prompt for PeriodName. So let's say user chooses January through March... in another

  • Access to Interface Adviser

    Dear Experts, I was wondering if someone can tell me where to find the Interface Adviser these days? I know there used to be an web version of the tool on "http://sapnet.sap-ag.de/int-adviser", but it's not there anymore and I can't find it in SDN. D