Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5966759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:50:44+00:00 2026-05-22T19:50:44+00:00

I’m building an app with Adobe AIR that contains a browsing component with mx:HTML

  • 0

I’m building an app with Adobe AIR that contains a browsing component with mx:HTML. This browser will be used to load external content (publicly-accessible URLs like http://google.com, for example) and after the external content loads, I’m injecting CSS and JS into the HTMLLoader to provide other UI components for my app.

That part works just fine. My JS code is executed by WebKit; my CSS rules are used by WebKit. With the UI components I’m creating with CSS and JS, I’d like to have some images used. So far, I have had success with rendering images in HTMLLoader via the data URI scheme, but this forces me to make base64-encoded copies (added to the CSS rules) of images in assets/ folder.

I’d like to be able to load external URLs with HTMLLoader, and then add CSS, JS, and Images to create UI components in the same HTMLLoader. I am aware of the HTMLLoader property, placeLoadStringContentInApplicationSandbox, but if that what I would use to load local images from my assets/ into HTMLLoader, what would the HTML content of an IMG tag look like, ie how to reference the image?

Any other ideas on how to load local images into the content of an HTMLLoader object?

UPDATE

I’ve tried the first commentator’s idea, using src=”app:/path/to/image.png” with no luck.

Here’s what I did:

<mx:HTML id="browser"/> 
<fx:Script>
<![CDATA[
browser.addEventListener(Event.COMPLETE,browserEventCompleteHandler);    
browser.htmlLoader.placeLoadStringContentInApplicationSandbox = true; // have set to true and false with no difference.
....initiate browser load....
private function browserEventCompleteHandler(event:Event):void 
{
    var img:* = browser.domWindow.document.createElement('IMG');
    img.src = "app:/assets/arrow_refresh.png";
    img.width="300";
    img.height="300";
    browser.domWindow.document.getElementsByTagName('body')[0].appendChild(img);
}
]]>
</fx:Script>

Running the above code, I see that the IMG element is added to the external content with width and height of 300px, but the PNG image itself doesn’t render. Just see an empty 300px square for the IMG element.

FINAL UPDATE

The answer solved my problem, but with one change. I used File and FileStream classes instead of URLRequest to load the png. Here’s what I did:

var f:File = File.applicationDirectory.resolvePath("app:/assets/arrow_refresh.png");
var s:FileStream = new FileStream();
s.open(f, flash.filesystem.FileMode.READ);
var data:ByteArray = new ByteArray();
s.readBytes(data,0,s.bytesAvailable);
var b64Encoder : Base64Encoder = new Base64Encoder;
b64Encoder.encodeBytes(data);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:50:45+00:00Added an answer on May 22, 2026 at 7:50 pm

    Why don’t encode img in base 64 at runtime ?

    package
    {
        import flash.display.Sprite;
        import flash.events.Event;
        import flash.html.HTMLLoader;
        import flash.net.URLLoader;
        import flash.net.URLLoaderDataFormat;
        import flash.net.URLRequest;
    
        // Base64Encoder from as3corelib (https://github.com/mikechambers/as3corelib)
        import mx.utils.Base64Encoder;
    
        public class TestHtml extends Sprite
        {
            private var _htmlLoader : HTMLLoader = new HTMLLoader();
    
            private var _rawImgLoader : URLLoader = new URLLoader; 
    
            public function TestHtml()
            {
                super();
    
                _htmlLoader.width = stage.stageWidth;
                _htmlLoader.height = stage.stageHeight;
    
                // Load google page
                _htmlLoader.load(new URLRequest("http://www.google.fr"));
                _htmlLoader.addEventListener(Event.COMPLETE,   onEvent);
    
                // Load one image
                _rawImgLoader.dataFormat = URLLoaderDataFormat.BINARY;
                _rawImgLoader.addEventListener(Event.COMPLETE, onEvent);
                _rawImgLoader.load(new URLRequest("logo.png"));
    
                addChild(_htmlLoader);
            }
    
            private function onEvent(e:Event) : void
            {
                addImg();
            }
    
            private function addImg() : void
            {
                // Wait for img and html
                if(_htmlLoader.loaded && _rawImgLoader.data)
                {
                    // Encode img
                    var b64Encoder : Base64Encoder = new Base64Encoder;
                    b64Encoder.encodeBytes(_rawImgLoader.data);
    
                    var img:Object = _htmlLoader.window.document.createElement('IMG');
                    img.src = "data:image/png;base64," + b64Encoder.flush();
                    img.width="300";
                    img.height="300";
                    var body :Object = _htmlLoader.window.document.getElementsByTagName('div');
                    body[0].appendChild(img);
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.