In my flash 4.6 Air project, I have several thousands of html files in assets folder which are generated from some other software. Some html files having images.
Now to secure the html files I encrypt all of them. But when I decrypt them to a string and load to via:
html.htmlLoader.loadString(decryptedString.toString());
or
html.htmlText = decryptedString.toString();
The images are not showing and a blank bordered box is showing with ALT text. These html files have javascript() and it is working. The content of ("samople.htm") html file is like:
<P>Some Text</P>
<IMG SRC="../assets/sample/images/image.GIF" ALT="IMAGE.GIF" WIDTH="203"HEIGHT="105">
<P>Some Text</P>
To check the working When I load html by:
html.location = "/assets/sample/sample.htm";
Then it is showing the image. But when I use string by:
html.htmlText = '<p>some text</P><img src="../assets/sample/images/image.GIF" width="203" height="105"><p>some text</p>';
Then it is not showing image. I have tried to change from src="../assets/ . . ." to src="./assets/ . . ." or src="/assets/ . . ." or src="assets/ . . ."
My motto is to secure the html files in assets folder. Currently I can encrypt/decrypt them all but images are not showing.
I'm new in flex and air. Thanks in advance for any help.
EDIT
Here is my full sample code: Flex/ActionScript
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="initiate()">
<fx:Script>
<![CDATA[
public static var stream:FileStream;
public static var stream2:FileStream;
public static var file:File;
public var readFile:ByteArray;
public function initiate():void
{
file = File.applicationDirectory.resolvePath("assets/sample/sample.htm");
readFile = new ByteArray;
stream = new FileStream();
stream.open(file, FileMode.READ);
stream.readBytes(readFile);
stream.close();
html.htmlText = readFile.toString();//Not showing image.
}
]]>
</fx:Script>
<mx:HTML id="html" left="10" top="10" width="220" height="250"/>
<mx:HTML id="html2" left="240" top="10" width="220" height="250"
location="assets/sample/sample.htm"/><!--Showing Image-->
</s:WindowedApplication>
And HTML:
<HTML>
<HEAD>
<TITLE>title</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function someFunction(someValue)
{
//some code;
}
</SCRIPT>
</HEAD>
<BODY>
<P>This is image</P>
<P><IMG SRC="/assets/sample/images/myimage.gif" ALT="myimage.gif" WIDTH="203" HEIGHT="105"></P>
</BODY>
</HTML>
myimage.gif is located at: assets/sample/images/myimage.gif