Setting 'source' of Image component programmatically

How do you change the source of an mx:Image component
programmatically in ActionScript?
I have an image like this:
<mx:Image id="myImage"
source="@Embed(source='image1.png')" />
Then I want to change this in my actionscript to image2.png.
Why does not the following code work?
myImage.source = "@Embed(source='image1.png')";
The image won't load, it just displays a small square icon. I
am sure that the path is correct because it works when I use the
Embed statement in the component declaration.
I appreciate your help!

The line:
<mx:Image id="myImage"
source="@Embed(source='image1.png')" />
embeds the image into your SWF file at compile time. To
change the source at run time, you'll try something like:
myImage.source = "images/image1.png";
Where images is your folder on the root of web application
context you're in and image1.png is the image to be loaded.
Here is from image class help from docs:
The URL, object, class or string name of a class to load as
the content. The source property takes the following form:
source="URLOrPathOrClass"
source="@Embed(source='PathOrClass')"
ATTA

Similar Messages

  • Set Source of Image using StorageFile using FilePicker

    I am developing an app in which I have called a filePicker and then the image is set as source of userImage. I am getting image through filepicker but it is not setting as source of userImage. My code is
    private void pickPhoto_Tapped(object sender, TappedRoutedEventArgs e)
                MyPictureImage = true;
                FileOpenPicker photochooser = new FileOpenPicker();
                photochooser.ViewMode = PickerViewMode.Thumbnail;
                photochooser.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
                photochooser.FileTypeFilter.Add(".jpg");
                photochooser.FileTypeFilter.Add(".jpeg");
                photochooser.FileTypeFilter.Add(".png");
                //Launch file open picker and caller app is suspended and may be terminated if required
                photochooser.PickSingleFileAndContinue();            
            public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
                var values = args.ContinuationData;
                if (args.Files.Count > 0)
                    StorageFile sf = args.Files[0];
                    ImageEncodingProperties format = ImageEncodingProperties.CreateJpeg();
                    StorageFile Image = await ApplicationData.Current.LocalFolder.CreateFileAsync(sf.Name, CreationCollisionOption.ReplaceExisting);
                    StorageFile sfa = await ApplicationData.Current.LocalFolder.GetFileAsync(sf.Name);
                    UploadImage(sf);
    try
                        StorageItemThumbnail thumb = await file.GetThumbnailAsync(ThumbnailMode.PicturesView, 250, ThumbnailOptions.UseCurrentScale);
                        userImage.Source = await ImageFromStorageItemAsync(thumb);
                    catch (Exception ex)
    private async static Task<BitmapImage> ImageFromStorageItemAsync(StorageItemThumbnail item)
                BitmapImage image = new BitmapImage();
                await image.SetSourceAsync(item);
                return image;
    Can anybody Help?

    Your code looks good and I wasn't able to reproduce the issue.
    You need to look in your "App.xaml.cs" page and make sure you have modified the "OnActivated" event to be able to navigate to the ContinueFileOpenPicker method.
    protected override void OnActivated(IActivatedEventArgs args)
    var root = Window.Current.Content as Frame;
    var mainPage = root.Content as MainPage;
    if (mainPage != null && args is FileOpenPickerContinuationEventArgs)
    mainPage.ContinueFileOpenPicker(args as FileOpenPickerContinuationEventArgs);
    Let me know if this helps.
    Abdulwahab Suleiman

  • Setting source for image field

    I'm still trying to find a way around my "watermark" issues. It doesn't have to be a watermark, per se. I just need to be able to put the picture on the form based on user submission. Here's what I've done, but it's not working as I expected. Perhaps someone can help?
    The livecycle form has an image object. It also has a dropdown selection. Depending on what the user selects in the dropdown, I change the href of the image. Although the field accepts my input, it doesn't actually SHOW the image that I put referenced.
    Another important point I've left out of my previous posts....
    There is a great deal said about how it is easy to confuse changing the appearance of the document without changing the layout. Actually, this is exactly what I want to do. When I am totally done with everything, I intend to flatten the whole thing and save it as an unchangeable document. (This may require printing to a PDF print driver.) In other words, my application is not about the DATA in the form, but the LOOK of the form when it's filled out.
    So, the question of the day is....
    Given an image field, how do I programatically change the actual image it displays?

    I believe this is one of the security restrictions in Acrobat. You can't redirect to an external source programatically. If you want the user to be able to switch pictures based on a listbox selection, you must embed each picture in the document. There is a sample that covers this technique on http://www.adobe.com/devnet/livecycle/designer_scripting_samples.html
    the link is titled: "Display different images inside the same image field"
    If you want to display an image that is not embedded, you are basically stuck with the "click-and-browse" functionality that is the default behaviour of an image field.

  • Setting source property of Trinidad image component using java script

    Hi,
    Can anyone tell me how to set the source property of Trinidad Image component using javascript.
    i tried document.getElementById("f1:img").source="/images/neha.gif".
    But its not working
    Thanks
    Neha

    Hi,
    Bases on the solution you suggested, i tried the img component to change the image on OnMouseOver and OnMouseOut. Its working fine in a normal browser but doesnt work in Mobile browser. May be because mobile browser supports only trinidad components. I then tried the option of backing bean
    " Or you can expose the component to a backing bean by setting its "binding" attribute. JDeveloper can create a backing bean from the wizard if you don't already have one. This will get you a CoreImage object in the bean, and you can change the source with its setSource method."
    . So i bound the omMouseOver event of the trinidad image component to a backing bean. Inside that i am changing the source and refreshing the component.
    <tr:commandLink id="cl1" action="goAlerts" styleClass="listingLink2">
    <tr:image source="/images/alert.gif" id="i4"
    binding="#{Images.alertOnMouseOver}"
    onmouseover="#{Images.alertOnMouseOver}"/>
    </tr:commandLink>
    Images.java
    public void setAlertOnMouseOver(CoreImage alertOnMouseOver) {
    this.alertOnMouseOver = alertOnMouseOver;
    alertOnMouseOver.setSource("/images/alertSelect.gif");
    RequestContext context = RequestContext.getCurrentInstance();
    context.addPartialTarget(alertOnMouseOver);
    System.out.print("Test");
    So what i found is setAlertOnMouseOver is getting called but not MouseOver event but when the page is loaded. Can you please tell me where i am going wrong?

  • Center Image Component's Source

    In my flex app, I have an image control within a VBOX and I
    set the size to 100%by100%. When an image loads (as usual) it is
    placed in the top left hand corner of the component. How can I keep
    the image component's source centered while still keeping the
    100%by100% size property?

    If you are mainly interested in how things works, one can download the reference implementation of JSF at https://javaserverfaces.dev.java.net/

  • Adding Teradata source component programmatically in SSIS

    Need help to add a Teradata source component programmatically in SSIS . I am able to add the component but the column info and other metadata is not available for subsequent components. Any documentations or suggestion is needed .

    What kind of source is it? ODBC? Column info appears after you set the columns up.
    Arthur My Blog

  • How can  i set a image dinamically in a image component (ADF Mobile)?

    Hello everybody,
    I have to consume a rest service and get a url. This url is redirected to one image. After reading this image, how can i set he in a adf mobile image component?

    Hi,
    bind the mobile image component URL to a managed bean and have the managed bean. Then use the bean setter to set a new URL string and ensure (when creating the Java class for the managed bean) you have JDeveloper creating the property change event handlers.
    Frank

  • Setting Image control source to image in IsolatedStorage.

    Hi. I capture an Image and save it to IsolatedStorage. What's the URI (source for Image control) for IsolatedStorage to automatically display that image if it's available in IsolatedStorage? Thank you in advance.

    Try this code to retrieve the image from isoStore.
    It works for me.
    using (IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication())
    if (iso.FileExists(string.Format("image.png")))
    string fileName = "image.png";
    string filePath = iso.GetType().GetField("m_RootDir", System.Reflection.BindingFlags.NonPublic |
    System.Reflection.BindingFlags.Instance).GetValue(iso).ToString() + fileName;
    You can set the source of the Image to filePath and you won't have any problem accessing it.
    If this doesnt work, then the problem is while you are saving the image. You might have to find a workaround for saving the canvas to png or jpeg.
    If my reply answers your question, please mark this post as answered.

  • Some question about image component

    Hi,
    I encounter two questions when using image component and can't solve it myself after reading online document.
    1. How can I get image source at runtime? I find image.source return an Object class, but not the source image path.
    2. How to ensure image loading image correctly? In my itemRenderer, I set image source with this
    source="{appURL}+{data.picname}"
    I am sure there's no problem with the path, but it shows a broken image. What's the right way?
    Thanks,

    Try adding the images to the container dynamically
    var img : Image = new Image();
    img.load("{appURL}+{data.picname}")
    img.addEventListener(Event.COMPLETE,imageLoaded);
    private function imageLoaded(event:Event):void
                  var img : Image = event.currentTarget as Image;
                   // now add the img to the container
    cheers
    Varun Rathore
    http://www.vrathore.blogspot.com

  • ShortDesc attribute in af:image component doesn't display in IE8

    Hello all,
    As said in the subject, I have an af:image component inside a table column which looks like this :
    <af:column sortProperty="GraphicalSymbol" sortable="false"
                     headerText="#{res.history_vehicle_event}"
                     id="c10" width="60" align="center" headerClass="tableHeader" styleClass="columnData">
            <af:image id="imgIc" source="/images/new_layout/events/symbol_#{fn:toLowerCase(row.GraphicalSymbol)}.png" shortDesc="#{row.EventType}"/>
    </af:column>the tooltip displays successfully in Firefox and chrome, but not in IE8 (version : 8.0.7600.16385) until I active the compatibility view mode.
    Is this mandatory to set the compatibility view for adf applications ? are there other bugs/risks if I don't? Can it be set automatically?
    Thanks for your help
    Stephane

    Hi,
    sound like a bug in ADF Faces to me. Setting the compatibility mode is more a work around than really a solution. You don't mention teh JDeveloper build you use. Did you try 11.1.1.4 ?
    Frank

  • Create an Image Component that has a scale9Grid border

    Hello, I want to start the process of creating a custom Image
    Component that has a property of Scale9GridBorder, which upon
    setting, will use Scale9Grid to create a frame around an image. I
    was wondering if someone has any tips?
    I'm familiar with custom components, all written in
    Actionscript 3.0, and with the common createCHildren,
    commitPorperties, measure, updateDisplayLIst mehtods that Ill have
    to implement. I'm just not sure if classes like RectangleBorder,
    etc. will be of help for me.
    Maybe someone has already created a similar component?
    Thanks,
    Todd

    I guess, where I'm getting stuck is trying to use scale9Grid
    dynamically at runtime. Is this possible, or does scale9Grid only
    work with embeded images? (I can't find any samples of runtime
    setting a background image and then setting the innerRectangle of
    scale9Grid.
    THanks

  • Setting a background image using CSS Designer

    I am trying to set a background image for a page header using the CSS Designer. When I click the browse button the Select Image Source dialog box launches but any time I click on something the dialog box closes and no changes are made. Does anyone know what is causing this?

    Which DW are you using and which platform/OS, please? I am unable to reproduce this with CC2014 on OS10.9.4

  • Setting up 4 images 90 degrees

    I have been racking my brain trying to set up 4 images at 90 degrees to each other on the' floor' so I can rotate an active camera around them to look like an x pattern.
    Can anyone help me figure this out?
    Thanks-working in Motion 4.
    Sandy V.

    Aside from simply placing them, you could place the four images as singe frame clips in a group, one after the other, then clone that layer, click on the clone, then click Replicate. Set the Shape to Circle, the Arrangement to Outline, set the points to 4. Click Align Angle. Turn off Play Frames and set the Source Frame Offset to 1. That will make each point be a new frame. Finally adjust the radius of the circle, then click on your group and adjust the angle and placement to be on the "floor"...
    Took longer to describe that it does to do...
    I put a project using text as an example here.
    Patrick

  • Error while using Image component to display a child flash file

    Hi
    I'm using Xcelsius version 4.5. I used the "Image Component" to import a child flash file(.swf) into the parent flash file.
    I gave the path "D:\246024\Loblaw\Dashboard Docs\New Folder\trend input.swf" in the general tab of the image component.
    After exporting the .xlf into a flash file , it works fine in the system in which i created it. If i open the same flash file in any other system the parent file opens but the child flash file imported through the image component is not displayed.
    Please help me out in solving this issue
    Thanks
    Anitha

    yes, you will face the same problem as its still looking for the path of the swf.
    you need to have the SWF on specific location which is accessable by the Parent SWF
    usually web page or something which is accessable for all.
    good luck

  • How do I set the thumbnail image of my videos that export to my computer?  I'm using Premiere Elements 11 on a windows 8.1 PC 64bit.

    How do I set the thumbnail image of my videos that export to my computer?  I'm using Premiere Elements 11 on a windows 8.1 PC 64bit.
    Or how does Premiere 11 determine where to set the image for the video it is exporting? 
    I already know how to use Freeze frame and save the image to my computer by Publish+Share/Computer/ Immage.
    Thanks,
    Mike

    Mike
    This is not Adobe. Rather user to user. We are all visitors here.
    Just a bit of history....back in the days of Premiere Elements 4, you could set a "poster frame" in what was called the Project area. You did this by right clicking a blank area there and, from the drop down menu that appeared, selecting View/Preview Area, and using the poster frame feature there.
    As I said, when a video imports into Premiere Elements, the thumbnail of the import has been presenting as the first frame of the video. With this Preview area "poster frame" option, you could set the video's thumbnail in the Project area so that the first frame was another frame in the video. But, this "perk" was restricted to thumbnails of the video in Project area.
    If you exported to file with the first frame modified video, the export's thumbnail in Windows Explorer would present with other than the real first frame or the poster frame as the first frame.
    Also, in more recent versions, I have observed that the export to file does not display the real first frame of the video in Windows Explorer. Seems random, but I have not kept track.
    And, remember, at the onset I wrote
    As far as I have ever seen, Premiere Elements Windows uses the first frame of the video for its thumbnail in the program.
    I know of no way within Premiere Elements to control what the program opts to do in this matter. In some compatibility
    issues, it opts to give no image but a generic one.
    I did not say that you can expect to have the Premiere Elements' export file's thumbnail in Windows displaying with its real first frame. And, the more you get into this, depending on the versions, more details need to be added to my comment about "...first frame of video for its thumbnail in the program..."
    I would have to look into all this further to get perspective on the contributing factors.
    ATR
    Add On...The Poster Frame feature appeared in versions 4, 7, 8, and 9 by my count.

Maybe you are looking for