Disable cache in google chrome (Mac) for developing in flex/flash - apache-flex

What is the best way to go about disabling the cache in google chrome for mac, so that when I am developing a flash application, it will bring in the new movie every time?
Please advise, I can't figure out how to ensure the version of the .swf I am looking at is the most recent version.
One solution might be to get the flex compiler to append a timestamp to the .swf filenames, is this possible?
Thanks!

Go to the 'View' menu, open Developer Tools. In the bottom right corner of the Developer Tools is a gear icon. Click it, then check the 'Disable Cache' checkbox.

In your embed code where ever you the swf file you have to put a random number or a time stamp of some sort on the query. Whenever there is a query string that changes the browser will not cache the page.
"MySWFName.swf?t=" + new Date().getTime();
Best method would be to embed your SWF using SWFObject with this code.
In the html body tag do this.
<body onLoad="loaded()" onunload"doUnload( )">
<div id="replaceMe">Loading content.</div>
</body>
and for the javascript do this ( obviously changing the stuff wrapped in { } to your needs
<script type="text/javascript" src="swfobject.js">
<script type="text/javascript">
function loaded() {
var flashvars={}, params={}, attributes={}, tmp, version, width, height, container, flashObj;
flashvars.userName = "testvar";
params.menu = "true";
params.quality = "high";
params.bgcolor = "${bgcolor}";
params.allowscriptaccess = "always";
params.allownetworking = "all";
attributes.id = "${application}";
attributes.name = "${application}";
attributes.align = "middle";
attributes.allowscriptaccess = "always";
attributes.allownetworking = "all";
tmp = "expressInstall.swf";
version = "${version_major}.${version_minor}.${version_revision}";
width = "${width}";
height = "${height}";
container = "replaceMe";
flashObj = "${swf}.swf?t=" + new Date().getTime();
swfobject.embedSWF(flashObj, container, width, height, version, tmp, flashvars, params, attributes);
}
</script>
Don't forget to add a copy of SWFobject
You will never have caching issues again
EDIT:
BTW if you replace your code in your html.template.html file with this code it will generate the values for you. :)

Personally, I would never do that. Caching is there for a reason and shouldn't be disabled when you're running it locally. In my experience, the best way to do it is have a 'version' (normally a static properly in a Class) number increment every time you build (by using Ant or Maven; even better if you have an automation engine to do it too) which then attached that version number as a url parameter for the flash movie like Movie.swf?version=1.31 in the html.

Related

Splash won't render all contents of page

I am using Splash v2.3.2 and I am trying to render a page but it is not rendering everything. It won't render images or dynamically loaded content.
I am using my http://localhost:8050/ with script:
function main(splash)
local url = splash.args.url
assert(splash:go(url))
assert(splash:wait(10))
return {
html = splash:html(),
png = splash:png(),
har = splash:har(),
}
end
Here is a browser rendering:
Here is a screenshot of the Splash rendering:
I have tried to change the wait time and also tried to allow plugins. None of this will work. I am assuming that the dynamically loaded content is being restricted but I am unsure. Any help is appreciated.
The problem is with localStorage - site uses it, but Splash uses Private Mode by default, and this disabls localStorage. To fix it, disable private mode (see here). This script works for me (Splash 3.0):
function main(splash)
splash.private_mode_enabled = false
local url = splash.args.url
assert(splash:go(url))
assert(splash:wait(10))
return {
html = splash:html(),
png = splash:png(),
har = splash:har(),
}
end
See also: http://splash.readthedocs.io/en/stable/faq.html#website-is-not-rendered-correctly
I'm assuming that you are trying to scrape property description text. In your code you have just added splash:wait(10), My suggestion is you should try and implement wait for a specific css element. In you case, span#listingpropertydescription.
You can write a function to wait for this particular element and then return the html page.
Note you can find a sample wait-for-element code in http://localhost:8050/
Hope this will help you

How can I inject JavaScript file into a WebEngineView page?

I'm adding a script tag to a web page once it's fully loaded in a WebEngineView, but it's silently failing somehow.
I inject the script by invoking webview.runJavaScript with this code:
var s = document.createElement('script');
s.src = "qrc:/jquery-2.1.4.min.js";
document.body.appendChild(s);
That's perfectly standard and to a certain extent it works as expected, i.e., if I view the html source of the page, the script tag has indeed been appended to the body.
The problem is that the script isn't being downloaded, or isn't being evaluated, or something. All I know is in the above example the jQuery functions aren't available. If I load a small JavaScript test file with one global variable, that variable's not available either. Changing the url to http instead of qrc and pointing it to a web server makes no difference.
Injecting an img tag works fine; the image is loaded and displayed.
But JavaScript is broken somehow. Does anyone know how to fix this?
The problem had to do with the asynchronous nature of QML and JavaScript.
I was inserting a script tag to inject jQuery, and then I was calling a function to de-conflict my inserted version of jQuery from whatever version of jQuery might already be in the original page.
But I believe the webview had not finished parsing the inserted jQuery library before my de-conflicting function was called, so it failed. (I'm not very experienced with browser programming or I might have suspected this from the beginning.)
The solution was to insert a script tag with a small bit of JavaScript that inserts jQuery and then sets a timeout to wait 200ms before calling the de-conflict function. Like so:
function insertAuhJQuery(){
var s = document.createElement("script");
s.src = "qrc:/jquery-2.1.4.min.js";
document.body.appendChild(s);
window.setTimeout(deConflictJQuery, 200);
}
function deConflictJQuery(){
auh = {};
auh.$ = jQuery.noConflict(true);
}
insertAuhJQuery()
That works reliably and is acceptable for my purpose.

Launching a webpage in browser from an Adobe Air app not working

I've got a webpage I want to hook in to my Adobe Air app. It's running JavaScript, so I can't open it in the app, but I'm trying to launch it in the default system browser.
Here's the code that's supposed to be launching the page:
public function beginModule():void {
var loader:HTMLLoader = new HTMLLoader();
var gameURL:URLRequest = new URLRequest("file:///path/to/file.html");
loader.navigateInSystemBrowser = true;
loader.load(gameURL);
}
I've also tried using
flash.net.navigateToURL(gameURL);
but that had no effect.
Every time I hit the above method, that block executes but nothing happens other than a quick cursor change-- no browser opened, no change in the app. What am I missing here?
Before you start, check if the HTML page is properly running in the browser.
To open a HTML page in flex, use the HTML tag: <mx:HTML></mx:HTML>
Something like this: https://snipt.net/anishnair/flex-show-html-page/?key=28838d54ac287180032dee000ce33a74
Thank you.
Regards,
Anish
Simply use :
navigateToURL(url,"_blank");
to navigate to the url in the web-browser.

Want to show Busy Loading message with percentage download when form will load using JQuery

suppose my page content is huge so in my asp.net application i want to show busy icon with percentage downloading the content in client side. i saw many flash and sliver light site that they show busy icon and also they show percentage that means how much content has been loading in client machine. how could i achieve this using JQuery and when page content has been downloaded in client machine the busy icon goes out and actual page content will display.
please me with sample code to achieve it. thanks
You could have a placeholder image, and when the image you want is loaded, you could replace the placeholder with the new source
var img = new Image();
img.src= "largerImage.png";
img.onload = function() { oldImage.src = img.src; };
This could be taken a step further, and the code could be added to the image itself
<img src="http://www.codedigest.com/img/loading.gif"
onload="var t = this; var img = new Image(); img.src ='http://hardgeek.org/wp-content/uploads/2010/07/firefox-logo-1024x969.jpg'; img.onload = function() { t.src = img.src }" />
Which could also be taken a step further, as you might not always have the ability to apply the onload directly like this, just a suggestion.
I would recommend something like Uploadify. It does require a flash plugin. This is by far the easiest way.
http://www.uploadify.com/
Here is an example (ASP.NET MVC):
http://blog.bobcravens.com/2010/02/upload-files-with-progress-using-uploadify/
[Update] If you are trying to lazy load images, then use the jquery lazyload plugin. This only loads images that are in the current viewing area. As you scroll down, it fetches the next images. I use it on my blog page.
http://blog.bobcravens.com
View source and you will see (around line 13) a script that sets lazy loading on all post images.
Bob

How to change img src on document ready before browser downloads images?

On my page I have some images on thisdomain.com/images. on document.ready(), I change the src attribute of images to thatdomain.com/images. Firebug's Net tab shows me that images are downloaded from both thisdomain.com and thatdomain.com. How can I prevent the browser from downloading images from thisdomain.com?
$(document).ready(function(){
$("img").each(function() {
var $img = $(this);
var src = $img.attr("src");
$img.attr("src", src.replace(/thisdomain.com.com\/images/i, "thatdomain.com\/images"));
});
});
EDIT: ASP.NET server-side override of Render() using code "in front" i.e., <script runat="server"> I just added this to the aspx page without recompiling code-behind. It's a bit hack-ish but it works.
<script runat="server">
static Regex rgx = new Regex(#"thisdomain.com/images", RegexOptions.Compiled | RegexOptions.IgnoreCase);
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
using (HtmlTextWriter htmlwriter = new HtmlTextWriter(new System.IO.StringWriter()))
{
base.Render(htmlwriter);
string html = htmlwriter.InnerWriter.ToString();
string newHtml = rgx.Replace(html, "thatdomain.com/images");
writer.Write(newHtml.Trim());
}
}
</script>
This sounds like something that is impossible to achieve reliably, because images will start to load asynchronously as soon as a src has been specified.
I can't think of a workaround. The <base> tag would allow for some kind of "mass redirection" but the URIs would have to be relative ones for that to work.
I'm sure you have your reasons for outputting thisdomain.com in the first place, but I'm pretty sure you'll have to change your code so thatdomain.com gets output instead (or no src gets specified at all so you can add them using jQuery) if you want a 100% watertight solution.
This ain't going to work in the client side. Your best bet is a server side solution. Have the server side script (PHP? JSP? ASP? etc) to read the to-be-included HTML source and replace the src's accordingly with help of a decent DOM parser before it get emitted to the client side.
I don't that is possible at all. To use jQuery functions, the jQuery library needs to be downloaded, which probably means the browser already started downloading other assets, such as images.
You can't be completely sure to prevent downloading by changing the URL after the element has been parsed. The closest possible that you can get is by changing it immediately after the element:
<img id="something" src="http://www.thisdomain.com/images/hello.gif" />
<script type="text/javascript">
var $img = $('#something');
$img.attr("src", $img.attr("src").replace(/thisdomain.com\/images/i, "thatdomain.com\/images"));
</script>
I don't think there is a way to halt GET requests from img elements once the page has loaded. It's difficult to suggest an alternative since I'm not sure what you're trying to achieve.
Can you be more specific?

Resources