Is it possible to dynamically load an image/resources embed in a SWF?

Hi all,
   i have created a flex library project, just containing images (.GIF)...etc.
   And i create another flex application project that merge the .GIF files into the final SWF application.
  based on the current time, i want to display different pictures (e.g. sun.GIF, moon.GIF, star.GIF...etc..there are many images) in the application right-top corner.
  as, i know, <mx:image/> just work with static image reference for embedded resource.
(<mx:image source="@Embed('sun.GIF'))"/>).
  i search by google, it seems that, for embedded image or resource, you can't load it dynamically.
  the following code don't work.
  e.g. var mmm:Image = new Image();
               mmm.source = fileName;
               mmm.load();
  anybody find the solution???
  thank you.
ppk luk

Hi,
  i have tried this method before, but, again, it don't work for embedded resource. IO error will be thrown, with error message.
IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2036: Load Never Completed. URL: file:///E:/Flex/TmpAssetApp/bin-debug/@Embed(source='images/sun.GIF')"]
(the GIF is in a folder called images)
SWFLoader/Loader can only load file dynamically from URL, but not embedded resource?? (by syntax @Embed(source='xxx'))??
my sample code:
=======================================
<mx:Script>
        <![CDATA[
            import mx.controls.Alert;
            [Bindable]
            private var fileName:String = "@Embed(source='images/last.GIF')";
             * Show the image
            private function showImage(event:flash.events.MouseEvent):void{
                fileName = fileTxt.text;
                dynaLoader.source = "@Embed(source='" + fileName + "')";
                //dynaLoader.addEventListener(flash.events.Event.COMPLETE, ss);
                //dynaLoader.addEventListener(flash.events.IOErrorEvent.IO_ERROR, ff); 
                dynaLoader.load();
            private function ss(event:flash.events.Event):void{
                    mx.controls.Alert.show("result1\n" + event);
            private function ff(event:flash.events.IOErrorEvent):void{
                    mx.controls.Alert.show("result2\n" + event);
        ]]>
    </mx:Script>
    <mx:SWFLoader height="305" left="10" right="10" bottom="10" id="dynaLoader" autoLoad="true" source="{fileName}" ioError="ff(event)" complete="ss(event)"/>
=======================================
   Do you know any other solution?
  thank you.
ppk luk

Similar Messages

  • Dynamic load of images in to established Timeline effect

    Is it possible to dynamicly load images in to an already
    established timeline effect?
    Steps I've done.
    Stuffed a JPG in to the library by draging and dropping it in
    to the SWFs library.
    Dropped the JPG on to the main stage
    Right clicked the image then going down to Timeline effects
    and choosing an effect.
    Completing any changes in effects dialogue box and then
    clicking OK.
    Play the movie, and pat myself on the back that it worked.
    So then, how can I get Actionscript to load an image
    dynamically in to that same Timeline effect and have it do the
    effect to that instead of the one found in the library?
    I'm using Flash MX Professional 2004.

    hii
    Can u mention the error message getting while the status become RED??
    As what I understand, this may be the issue of invalid characteristics inPSA Data Records or also there may be records that does not support the lower case or upper case data.
    So just check the data in PSA Level
    Thanks
    Neha

  • Is it possible to dynamically change the image in a Picture Field?

    Is it possible to dynamically change the image in a Picture Field?
    Thank you

    Try using the In Proc RAS SDK.
    [Here are the sample applications.|http://www.sdn.sap.com/irj/boc/samples?rid=/webcontent/uuid/b02c1cac-ad86-2b10-88ae-cb36551bab06] Take a look at the 'Add Image' sample.
    Insert the picture at design or runtime and change the location / name of the image at runtime.
    - Bhushan.

  • How to dynamically load an Image into a TableView when its row/cell becomes visible?

    Hi,
    I am building an application that shows tables with large amounts of data containing columns that should display a thumbnail. However, this thumbnail is supposed to be loaded in the background lazily, when a row becomes visible because it is computationally too expensive to to this when the model data is loaded and typically not necessary to retrieve the thumbnail for all data that is in the table.
    I have done the exact same thing in the past in a Swing application by doing this:
    Whenever the model has changed or the vertical scrollbar has moved:
    - Render a placeholder image in the custom cell renderer for this JTable if no image is available in the model object representing the corresponding row
    - Compute the visible rows by using getVisibleRect and rowAtPoint methods in JTable
    - Start a background thread that retrieves the image for the given rows and sets the resulting BufferedImage in a custom Model Object that was used in the TableModel (if not already there because of an earlier run)
    - Fire a corresponding model change event in the EDT whenever an image has been retrieved in the background thread so the row is rendered again
    Btw. the field in the model class holding the BufferedImage was a weak reference in this case so the memory can be reclaimed as needed by the application.
    What is the best way to achieve this behaviour using a JFX TableView? I have so far failed to find anything in the API to retrieve the visible items/rows. Is there a completely different approach available/required that uses the Cell API? I fail to see it so far.
    Thanks in advance for any hints here.

    Here’s what I have tried so far:
    I have defined a property in my model object that contains a weak reference to the image that is expensive to load. I have modeled that reference as an inner class to the object so I have a reference to its enclosing object. That is necessary because my cell factory otherwise has no access to the enclosing model object, which it needs to trigger loading the image in the background.
    The remaining problems I have is, that I don’t have sufficient control over the loading process, i.e. I need to delay the loading process until scrolling has stopped and abort it as soon as the user starts scrolling again and the visible content changes. Imagine that loading an image for a table row (e.g. a thumbnail for a video) takes 200ms to load and a user quickly scrolls through a few hundred records and then stops. With my current set-up, the user has to wait for all loading processes that were triggered in the cell factories to finish until the thumbnails of the records they are looking at will appear (imagine an application like finder to be implemented like that, it would simply suck UX-wise). In my swing application a background thread that loads images for the visible records is triggered with a delay and stopped as soon as the visible content changes. This works well enough for a good user experience. I don’t see how I can do this based on the cell API. It is nice to have all this abstracted away but in this case I do not see how I can achieve the same user experience as in my swing application.
    I also tried registering a change listener to the TreeCell’s visible property to make that control the image loading but I don’t seem to get any change events at all when I do that.
    I must be missing something.

  • Dynamically loading binary image of report source file

    Post Author: ChristopherZ1
    CA Forum: .NET
    I have stored all my .rpt files as varbinary images in a SQL 2005 DB.  I can retrieve the image write it to disk then load the report. i.e.
    Private m_RptDoc As New ReportDocument()
    m_RptDoc.Load(RptPathName). 
    My question is...is there a way to load the image directly into the ReportDocument without first writting it to disk and using the pathname?

    I would think that this crummy custom Image class hack would work, but surprise surprise -- the width/height in loaderInfo is flat out WRONG when the event fires. It seems to have a hard coded width/height no matter what the file size. Silly!
    <mx:Image xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()">
         <mx:Script>
              <![CDATA[
                   public function init():void {
                        this.addEventListener(Event.COMPLETE, loaded);
                   private function loaded(e:Event):void {
                        this.width = this.loaderInfo.width;
                        this.height = this.loaderInfo.height;
              ]]>
         </mx:Script>
    </mx:Image>
    Turns out, this version DOES work (but it's still a hack fix in my opinion):
    <mx:Image xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()">
         <mx:Script>
              <![CDATA[
                   public function init():void {
                        this.addEventListener(Event.COMPLETE, loaded);
                   private function loaded(e:Event):void {
                        this.width = this.contentWidth;
                        this.height = this.contentHeight;
              ]]>
         </mx:Script>
    </mx:Image>
    You guys at Adobe are so silly.    It would seem to me that Image's width and height should be set (rather than left at 0) once the content's width and height is known.  So now that I've fixed this bug (as far as I'm concerned) for ya Adobe, I take cash, cashier's check, or money orders--thanks!
    But really, if this doesn't work this way in Flex 4, I think it should.

  • HELP!! NEWBIE - Dynamically load jpg images - NEWBIE Question.

    Newbie here.
    Im currently making a flash website. and trying to make it as light as possible.
    so decided to load images dynamically.
    Im using UILoaders.
    I drag the UILoader from components into the main timeline and set the source as 1.jpg, because the image is in the same folder as the .fla file.
    and scale - false
    Tested the movie but nothing shows up. i guess i need some coding? but i dont know where to add the codes. on the same frame? or in frame 1?
    i also need the image to fade-in.
    the end result im looking for is, as i click a button. 3 images show up at the same time, fading in.
    Help, greatly appreciated.
    and thanks in advance

    thanks your the reply,
    the source is set to 1.jpg i put a image file named 1.jpg into the same as the fla. and swf and everything.
    the UILoader is visible in frame 55 or so. and as i click a button the pic is suppose to show , but it doesnt??
    the jpg is also non-progressive..
    any idea why its not working?

  • Dynamic Loading of image-Works in Designer bt fails when viewed in infoview

    Dear All,
    I am trying the display Dynamic Image by setting the property of OLE Object "Format Graphic -> Picture -> Graphic Location Property. I am retrieving the image using  an web application (which is developed in .Net platform). When I set the URL and preiview the report in Crystal Designer it works fine, but when I publish the report to info view it fails. The report displayes the original Image which was used while inserting the object in the report.
    The sample URL to retrieve image is mentioned below;
    http://<Server Name>/getmyimage.aspx??PID=&FID=ac1788f2-40a8-4b93-ae9b-48c2ef7b6287.JPG&W=335&H=145&ZI=0&ratio=1&TIMESTAMP=20101025T110523Z&random=0.9074388616085233
    I searched the forum topic and found several posts.
    One of the resolution I understed was to replace u2018?u2019 with u2018??u2019 so that the parsing of image will be done accurately. I also tried this but it could not resolve issue.
    I am using Crystal 2008 for report development and BOE server version is BO XI 3.1 with SP 1 and FP 1.6. The server is running on Solaris Server.
    Looking forward for any solution/suggestion/clues on this.
    Thank you,
    With Regards,
    Sachin Dalal
    Edited by: SachinDDalal on Nov 13, 2010 1:09 PM
    Edited by: SachinDDalal on Nov 13, 2010 3:01 PM

    Hello Sachin,
    Did you find any solution for this...please let me know, yaar
    Really appreciate it
    Regards,
    Kamal

  • How to resize dynamically loaded Base64 Image?

    Hi all,
    I'm currently writing a flex component which renders a
    formular from a
    xml definition file. I get the image as Base64 and decode it
    whith some
    flex internal methods.
    private function addBgImage(base64Image:String):void{
    var base64Decoder:Base64Decoder = new Base64Decoder();
    base64Decoder.decode(base64Image);
    var byteArray:ByteArray = base64Decoder.flush();
    var loader:Loader = new Loader();
    loader.loadBytes( byteArray );
    var img:Image = new Image();
    img.addChild(loader);
    this.addChild(img);
    This works fine. Now i want to resize the image, but nothing
    works. I
    tried:
    img.width = 100;
    img.maxWidth = 100;
    img.explicitWidth = 100;
    loader.width = 100;
    But nothing works. Can somebody help me? Do I need to wait
    till the
    ByteArray is loaded?
    Best regards,
    Christian

    solved.
    solution:
    I have to wait till the loader finished loading and then i
    can resize the image in this method.
    private var loader:Loader;
    private function addBgImage(base64Image:String):void{
    var base64Decoder:Base64Decoder = new Base64Decoder();
    base64Decoder.decode(base64Image);
    var byteArray:ByteArray = base64Decoder.flush();
    loader = new Loader();
    loader.loadBytes( byteArray );
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
    imgLoaded);
    var img:Image = new Image();
    img.addChild(loader);
    this.addChild(img);
    private function imgLoaded(event:Event):void{
    loader.width = 100;
    }

  • Dynamically loaded images cached?

    We have an xml feed that is refreshed every hour. According
    to the xml file, we dynamically load an image into an html text
    field each time someone hits our page. All of the images have been
    recently updated, but the old ones are still appearing? We use the
    swf?nocache=randomnumber convention to make sure the swf file
    itself isn't cached, but is there anything we can do to clear out
    the cache of dynamically loaded images? If there isn't anything we
    can do, will these all eventually refresh themselves? This is how
    the html is generated where "twcImage[0]" is the image in question.
    Thanks!

    Do the same random number for the images.
    twcImage[0] + randomnumber
    Dan Smith > adobe community expert
    Flash Helps >
    http://www.smithmediafusion.com/blog/?cat=11
    http://www.dsmith.tv
    "Wolli World" <[email protected]> wrote in
    message
    news:fvvcrc$k9o$[email protected]..
    > We have an xml feed that is refreshed every hour.
    According to the xml
    > file,
    > we dynamically load an image into an html text field
    each time someone
    > hits our
    > page. All of the images have been recently updated, but
    the old ones are
    > still
    > appearing? We use the swf?nocache=randomnumber
    convention to make sure
    > the swf
    > file itself isn't cached, but is there anything we can
    do to clear out the
    > cache of dynamically loaded images? If there isn't
    anything we can do,
    > will
    > these all eventually refresh themselves? This is how the
    html is
    > generated
    > where "twcImage[0]" is the image in question. Thanks!
    >
    > twcTarget.text = "<img align='left' hspace='5'
    vspace='0' src='
    http://" +
    > _root.server + "/rss/weather/images/" +
    > twcImage[0] + "'>" + "<condition>" + ... and so
    on
    >

  • Problem displaying dynamically loaded text in Flash CS3

    I created a Flash CS3 application that does not display
    dynamically loaded text (from internal AS3 scripts) on 3/6 of my
    client's computers. All computers run IE 6 and Flash Player 9. I
    cannot replicate the problem on any computer in my department. The
    problem seems to be related to Flash Player 9 or a browser
    setting/IT restriction. Has anyone encountered this? If so, have
    you found a solution?
    If I cannot find a solution, then I will need to almost
    completely redo the application.
    One slightly insane idea I have considered is to, if
    possible, convert dynamically loaded text to an image real-time. Is
    that possible?
    Btw, I have created a font in my library. Should I try
    manually embedding the font from the Properties menu and selecting
    all characters?
    Thanks in advance.

    yes, even though you may be using a font from the library,
    you still have to specify that each text field that uses that font
    embeds the font, and you'll need to select all characters(well not
    all, unless you require all the different scripts of the world -
    upper-case, lower-case, numerals and punctuation usual suffices).
    I bet if you checked, the computers where the font did not
    appear did not have the font on their system.
    Good luck
    Craig

  • Dynamically loading the MathScript Node

    Hi - Is it possible to dynamically load script into the Mathscript Node at Run time. I see that you can use define functions and paths and things . But being a newbie to Mathscript could all this hang together to make dynamic loading a possibility and how?
    thanks dht 

    Hi,
      unfortunately the node doesn't support run-time dynamic loading of scripts. You can load variable values with the load function, but not scripts.
    http://zone.ni.com/reference/en-XX/help/371361A-01/lvtextmath/msfunc_load/
    http://zone.ni.com/reference/en-XX/help/371361A-01/lvhowto/saving_loading_scripts/
    Depending on your application, you could use a case statement to decide between several pre-built (and possibly compiled) mathscript nodes, and acheive the functionality that way.
    Another option might be to use the formula vi's instead, although this will require a more complex architecture to parse the text file you'd generate.
    For more information on MathScript, please see the following link
    http://zone.ni.com/devzone/devzoneweb.nsf/Opendoc?openagent&568C773718B080F286257096005BD314
    Hope that helps
    Sacha Emery
    National Instruments (UK)
    // it takes almost no time to rate an answer

  • Load a image in flash format

    Hi all,
    Does anyone know how to load a image from a file (in .swf format) to the java.awt.Image object. If anybody knows how to do this plzzzz help me to get rid of this damn thing.
    With regards
    Nuwan

    let say you have 20 images file in jpg format, all at the
    same directory with your flash file, with file name as below:
    pic1.jpg
    pic2.jpg
    pic20.jpg
    in your flash, select the frame which you wan to load a
    random image, type script below:
    num = Math.ceil(10*Math.random());
    filename = "pic" + num + ".jpg";
    _root.createEmptyMovieClip("pic_mc", 1);
    loadMovie(filename, "pic_mc");
    //good luck

  • Image resources in Jar file

    Hi all,
    I have a jar file having some image resources. When i run this jar file stand alone, it successfully loads the image resources from within itself. But when i use this jar file as library in some other application (with the class path defined in menifest file) it fails to load these images resources.
    Any idea what's going wrong?
    Regards,
    Ghaznavi
    PS: I am using getClass().getResource() method to locate image resources.

    Just in case you didnt know, when you use file names from with in a JAR, the file names ARE case sensative.
    So in a normall app, if you were linking to a file that was in ThisDirectory/ThatDirectory/filename.txt, could link to like this
    ThisDirECTory/thatdirectory/filename.txt
    or this
    THISDIRECTORY/thatdirectory/filename.txt
    but when your app is coming from a JAR you must specifie the filename exactly how it exists on the hard drive.!
    Graham

  • Is Dynamic Loading of Text from an external file possible in Captivate?

    Hello all,
    I am wondering if Dynamic loading of text is possible in captivate or not.
    As we can load an external file in flash.
    & which is the universal font to be used for the text entry box which will visible on any media?
    Thanks & Regards,
    Chirag

    Hello,
    I'm not a specialist about JavaScript. Have a look at Jim Leichliter's blog:
    http://captivatedev.com/
    Lilybiri

  • Dynamically loading images: UI Loader issue

    I posted this last week, but did not show good examples to get help. Admittedly, I am new to flash, so this may be a bit elementary, so my apologies in advance. I am trying to dynamically load images through the UI Loader component. Attached are the errors I get, and although I think that the coding is close to correct, when I publish, it just flashes up then restarts the movie... any ideas? Thanks in advance.

    there's a problem attaching things to this forum.  so, nothing is attached.
    can you copy and paste your error messages to this forum?

Maybe you are looking for

  • Can no-one help me?

    Hi, I posted this a day or so agao but got no replies and after much messing about still have no answer. I have a fairly complex flex app which works fine. I then created a new mxml component and added some view states to it, at this point I get the

  • Help building an e-commerce site using DreamWeaver MX 2004 and Oracle 10G

    I'm new to using Oracle 10G. After reviewing several rdms's I've picked Oracle 10G as my rdms. I'm trying to build an ecommerce site using DreamWeaver MX 2004 and Oracle 10G. The website will be selling hardware and software products. I have a choice

  • Why can't I open an existing project in Final Cut Pro X?

    I am new to FCP.  There is no "save project" option anywhere.  So I assumed it saves my project automatically, since it always reopens.  So I went and started another project, assuming the first one was saved.  Now I can't find the first project.  I

  • Mouse flicker outside of browser

    Hello Whenever I hide the mouse pointer to replace it with custom made graphic, it causes curors to flicker rapdily outside of the browser window. When you type or move across URL bar, or try to scale the browser window by dragging its corner, the mo

  • World clock doesn't remembers saved locations

    This is a problem with the world clock that has been unaddressed with all the firmware updates I've installed since buying this phone in December. After saving international locations around the world for quick reviews through out the day in the worl