how to change the flash builder generate HTML to call function in actionscript? - html

I have an actionscript project, and I have provided the function that I want it to be called from HTML(the flash builder generated html file).
ExternalInterface.addCallback("getURL", getURL);
This is the code in actionscript, how can I modify the flash builder generated html file so that it can call getURL()?

Just add your function between <script> tags in index.template.html file that is located in html-template folder of your project.

alternatively, you don't have to use the html template, it's totally possible for you to create your own html and implement your own settings. Just go to the Project properties and uncheck the "Generate HTML..." checkbox.
as for your javascript function , you could have it in an external file and access it like this. it'd be easier to maintain, if the need to add more functions arises
<script type="text/javascript" src="external.js"></script>

Related

Angular app, how to add html & css in the app component?

VScode error screenshotI generated a new component(bmi calc) in my angular app, then downloaded a html/css template of bmi calculator functionality and pasted the html and css content of the template into the bmicalc.component.html & bmicalc.component.css file in my app, but the app is not running?
This is my error(the image of my error)
As code given in your github files , below is working piece of code. I just updated your code.
You can check the updated code here on StackBlitz(Working) -
You can check demo here
Note : =I have just updated your code to make it work only as you got
those Uncaught error of compute function. Not sure about correct
calculation so you need to look on that part.
Just few suggestions
Add code snippet when you ask this type of question
Use appropriate names to variable, Avoid use i, ii, fv, kv type of variables.
.ts file is there to write presentation logic whatever you want to apply on the form.
Your code should be well-formatted. Clean html.
Avoid using inline css, Use .css file for it.

Register a js file independently in Assets

I'm developing a module where I've some custom js functions to be use in a form inside a Dialog.
I successfully loaded as inline script in the view that launch the dialog that include the form with something like:
$script = <<< JS
var scheda=$("table#schedaTable");
var idtum=scheda.attr('idtum');
scheda.find("i.modifica.concessione").on('click', function() {
$("#concessioneDialog").load("/cimiteriale/concessioni/edit-concessione?idtum="+idtum).dialog("open");
});
JS;
$this->registerJs($script, $this::POS_END);
but for several reasons I prefer to use an external file published in assets so my question is:
Is it possible to publish an external js file with MyModuleAssets.php and register it later in the view independently from the other js assets, where needed?
In fact I need to close and reopen the dialog with other ids and so I need to register the js again several time.
Could someone give me an hint and maybe some pieces of the core code?
Thanks in advance
Luca
Assets are published as a package. So if you want some JS/CSS to be registered somewhere and others in another situations, you should create different packages and register each of them when needed.

How does Google Swiffy implement clickTag for HTML5 banner ads?

First, I tried finding an option to prevent Swiffy from compressing/minifying all the data when doing an export to HTML5 from Adobe Flash Pro. But no dice.
Even if I was able to read the unminified Javascript that Swiffy exported, I don't think there would be a simple function call for the "clickTag".
It's likely defining the variable clickTag in the huge haystack of {index: #, type: #}, and then doing processing each operations to eventually call the window.open() method (or something similar).
This is how it currently outputs (minified)
Does anyone have any clue how Swiffy implements clickTag?
Or what would be the Javascript equivalent that does the same job?
Swiffy uses the core API of the environment where the ad is served. If it's a DoubleClick Rich Media ad, it does use Enabler.exit("url").
If you want to have a better control on your output file, I'd suggest having a look at Google Web Designer. The closest experience to flash development in the HTML5 - JS era.
Google instructions are here, for plain HTML5 (non-swiffy) click tags.
At the bottom of the file is a snippet of code like this:
<script>
var stage = new swiffy.Stage(document.getElementById('swiffycontainer'),
swiffyobject, {});
stage.start();
Add this right before stage.start(); to mimic previous flash behavior. Ensure you use the proper capitalization.
stage.setFlashVars("clickTAG=http://stackoverflow.com");
**Note: Ensure to use url encoding if there are parameters...doesn't seem to like it otherwise

dynamically rendering plain .html page on webmatrix

I'm trying to render a .html webpage using #Renderpage() method in Webmatrix but the .html extension is not supported by the method. I guess the method only supports cshtml extensions. Is there a way I can render html pages dynamically on my site (Webmatrix). I dont want to use an iframe because I'll definitely have issues with my jquery files.
I attempted something i feel is safe yet feels unsafe. I resolved to read the html file and inject it to the DOM manually using:
Array html = null;
var mypage = Server.MapPath(page);
if(File.Exists(mypage)){
html = File.ReadAllLines(mypage);
}
After reading the file.....i injected it to the DOM
<div class="s_content s fontfix left s_content2 downdown">
#foreach (var data in html) {
<text>#Html.Raw(data)</text>
}
</div>
All this runs on compilation time before the page is created for rendering.....I attempted some security measures by attempting to inject server-side C# code in the HTML file but was useless. Makes me feel safe atleast. Is this risky? What is the possible threat to this alternative. i wish i can still have an alternative proper solution from the house. Thanks though.
Assuming #Renderpage() doesn't support HTML files, why don't you try Jquery.load or Ajax. There are lots of tutorials based on dynamic loading of html content.
I do something similar but I don't use #Renderpage or an html file. Instead I am using the "onclick" event and a javascript function which opens a cshtml file. You just put this and the java script function in your main cshtml file in the hmtl section. It will open a file in the current directory called my_window.cshtml when clicked
<a onclick=openWin("my_window",700,850);>Open when clicked</a>
<script type="text/javascript">
function openWin(url, width, height)
{
myWindow=window.open(url,'_blank','width='+width+',height='+height);
myWindow.focus();
}
Hope this helps!

Alternative for getDefinitionByName

In the past, there was a simple trick, to include the flex mxmlc module by adding the following line to the flash-cs4 makefile:
-include-libraries “/absolute/path/to/my/assets/assets.swc”
This gave you the ability to use getDefinitionByName, an helper function to access the embedded swc asset-library (instead of creating hand-written classes all assets).
Unfortunately, this has stopped working since flash-cs4. Does anybody know another solution?
Unfortunately, the only workaround I have found is to explicitly refer each of asset classes somewhere in the code. You may create dummy class like this:
public class AssetsExporter extends Sprite
{
public static function export()
{
AssetClass1;
AssetClass2;
//etc
trace( "DEBUG AssetsExporter.export()" );
}
}
Specify this class as Document class in Flash IDE, so it will be compiled into the resulting swc. Then in the main code of your application call
AssetsExporter.export();
After doing this you will be able to use getDefinitionByName().
You can add them to the libraries in the publish settings.
(Image from http://wiki.gigya.com/ via Google Images)
By the way, if you use SWC files, you can also do
new somepackage.SomeClass();
instead of
new getDefinitionByName("somepackage.SomeClass")
where applicable. This is because SWC files are included at compile time, not runtime.
Even though you can change a compiler setting manually, its easy if you are using FlashDevelop as this is very simple to fix.
Right click your included swc from the Project list. Choose options then "include library (complete library)".
..you can now use getDefinitionByName to get an unreferenced class from your swc file.