Actionscript and Javascript conversation - javascript

I am new to actionscript 3.0 and am using Adobe flash CS6. I need to pass the value of a javascript variable to my actionscript code embedded in my timeline (I am not programming in a seperate .as file but the timeline itself.). I need to compute a value using javascript, and then I need to use that value in my actionscript code. How can i do this?
My purpose is to return a String value using a javascript function and then display the same String in a text area in my flash movie. (test1.swf)
But i see nothing in the textarea....
I have attached the code as well as other details in a text file..
plz follow the link
http://share-ideas.in/saurabh/App/test/code.txt

ExternalInterface maybe a bit tricky for beginners. There are quite a few conditions that need to be met for the communication to work:
Either you test on a server, or add the location of the swf/html files as allowed in the Flash Player Security Settings
The AllowScriptAccess is set to "always"
The <object/> tag's name attribute should match the <embed/> tag's id. This should ensure js communcation across different browsers.
Depending on how confortable you are with coding, you can either try the ExternalInterface example and simplify/modify it for your needs or use SWFObject which should make it easier (and cleaner) to work with flash and js

Related

Use Site Property in eSpace Javascript

I included Google Analytics (javascript) in my Outsystems website via de eSpace Javascript. Now I want to place the Analytics Key in my Site Properties so I can update it easily for every environment.
How can I use a Site Property in my Javascript?
You can create a site property to store the Tracking ID.
site Property screenshot
Second, you need to create a webblock with an unescaped expression, and add your javascript this way:
weblock expression screenshot
Finally, you just need to drag you weblock to each webpage you want to track.
cheers,
Vera
As far as I know, you cannot use Site Properties in the eSpace JavaScript window. For that, you have to use an escaped expression on a web screen or web block to add your JavaScript code along with the use of Site Properties.
Since you want the same script on all the web screens, I suggest that you add this expression in the Footer web block, so that it will be automatically added to all the web screens you create.
I can understand your use case. If I read it correctly, you're trying to use some JavaScript in one espace, that would be run in every page load, something like an
onLoad(function(){
// your Google Analytics code, but using the value from the site property
})
And in this way, you would be able to update the site property without the need to republish all consumers. Seems like a nice approach :)
On way to be able to achieve this, would be to have your JavaScript to request the key on the fly to the server side, and maybe cache it.
This can be easier or harder depending on the Platform version you're running... But here's a simple way to achieve it.
Add the site property to the espace. Build a page that has no layout, and in the preparation, add a download widget that only downloads the value of your site property. In the same espace, in the espace JavaScript, add an AJAX request to the page I was referring to before, and when you get the response back, start your Google Analytics code.
To be able to use this in every other espace, and in every page, you still need to reference something from the Google Analytics espace though, so that espace JavaScript is run in every page
Hope it helps :)

Is there a way to get current HTML from browser in Python?

I am currently working on a HTML presentation, that works well, but I need the presentation to be followed simultaneously with a NAO robot who reads a special html tag. I somehow need to let him know, which slide I am on, so that he can choose the correct tag.
I use Beautiful Soup for scraping the HTML, but it does so from a file and not from a browser. The problem is, there is javascript running behind, assigning various classes to specific slides, that tell the current state of the presentation. And I need to be able to access those, but in the default state of the presentation they are not present and are added asynchronously throughout the process of the presentation.
Hopefully, my request is clear.
Thank you for your time
http://www.seleniumhq.org/ (probably webdriver) is your friend. Initialize a browser and call browser.html to get the document in the current state.
There's wget on the robot, you could use it... (though I'm not sure I understand where is really the problem...)

Is it possible get current url with as3 without using javascript/ExternalInterface?

I have a project that i can't use the ExternalInterface to get current url from the browser...
So, someone know how i can get current URL from the browser without using ExternalInterface/JavaScript with the Flash/AS3?
Note: I can only use Javascript, HTML, CSS, AS3.
I asked this before on the Mochi forums: https://www.mochimedia.com/community/forum/topic/reliably-find-the-page-url
Long story short, there's no 100% reliable way unless you have some sort of control over where the SWF is placed - loaderInfo.url gives you the swf url, not the page one, and some of the time this can be the address of the preloader SWF (e.g if you make a game that goes onto game sites). You could try JavaScript, but that only works if it's enabled and sometimes you'll get the address of an iFrame, rather than the main page URL. Ditto for calling a PHP file.
Your best best is JS, but keep in mind that it's not perfect
var url:String = ExternalInterface.call("window.location.href.toString");
Note, you can do the same when you're embedding the SWF and pass the value in as a Flashvar
Maybe use flashvars to pass the url to your root on creation (look into swfobject.js)
Or look into: stage.loaderInfo.url

Get externally referenced class attributes to be local and inline?

I have a webpage that works and all is swell. It is coded using mostly good practises of external css files and minimal inline styles/code. All is well.
Now however, I want to send that page via HTML text only, such as in an email. So there should be no external references to external sites at all. Meaning I now must move my beautiful external references, internally.
I am thinking I can write a javascript function that finds every class of an object, removes it from that class, then gives that object inline "style" attributes equal to what the class has.
But I was wondering if anyone else has other suggestions.
The end goal is to get a wall of text, that when pasted in a non-internet connected browser with no cache or anything, will display exactly what I have on the screen of my "normal operations" page.
There is a perl CPAN module for this:
CSS::Inliner
you can also find the source on github:
https://github.com/kamelkev/CSS-Inliner

Obfuscate file names in webpage

I'm creating a web-application which will be taking survey-type data.
Users are presented with several files and asked a question. The user, in the hope of not skewing data, must not be able to know the file name of the file.
An empty div is created for a JPlayer instance to sit in, and I have added the "location" attribute to the div, so while setting up the JPlayer instance on the client side the JPlayer knows what .wav to play
<div id="jquery_jplayer" class="jp-jplayer" location="sound.wav"></div>
Here is part of the javascript which sets up the sounds to be played and here its easy to see that the file location is simply dragged from the div
$("#jquery_jplayer").jPlayer("setMedia", {
wav: $(this).attr("location")
});
Basically, the intention is to hide "sound.wav" from the HTML document and keep the javascript dynamic.
A translation file between obfuscated and deobfuscated could be possible but it would be nice to keep this dynamic.
If you want to truly hide logic from your viewers, then you need to do it server-side rather than with client-side javascript. You can "complicate" the dissection of what is happening in the client-side code, but you cannot truly hide it.
If you want further help with the obfuscation, you'll have to describe better what you're really trying to do. The current description doesn't seem to offer enough information. What is this file path? What is it being used for? Why do you need to hide it?
If what you really want is just a Javascript function to obfuscate and de-obfuscate the sound filename, you can find lots of options with Google depending upon how elaborate you want to get. My guess here is that the determined cheat won't be fooled (since all the code is there for deobfuscating) so all you're really trying to do is make it non-obvious at first glance. Thus, any simple algorithm will do.
Since you're already using jQuery, here's a jQuery that does simple string obfuscation: http://plugins.jquery.com/project/RotationalStringObfuscator. You'd have to run the obfuscator yourself in some sort of test app to record what the server should set each filename to and then do the reverse in the client when you want to actually use the filename.
If you ask me, a better solution would be to give the filenames non-meaningful names from the beginning. This would be names like 395678264.wav and just use them that way (on both server and client). Then, the name is meaningless to anyone snooping. No deobfuscation or translation table is required because this is the real filename.

Categories