Javascript in Flex
Hello,
I would like to put a hit counter in my flex website. So, I go to www.hitscount.com and create my hit counter and then, I have a javascript script, but how put it in my website... Can you explain to me very easily, I'm a newbie
My script is :
<code>
<div align='center'>...............</div>
</code>
Thank you very much
Chandler
you'll have to do an external call to your javascript in the template file, from your flex application.
here's an example of flex<-> javascript communication
http://www.switchonthecode.com/tutorials/flex-javascript-tutorial-simple-interaction
here's an example of how to do a hit counter using PHP instead of Javascript
http://www.mattlefevre.com/viewExample.php?tut=flexPHP&proj=Hit%20Counter
Similar Messages
-
Passing complex object from JavaScript to Flex
Is it possible to call a Flex function (defined with ExternalInterface.addCallback) and pass a complex object from Javascript? The properties of the object are all simple types, but the object itself is an array of objects. For example:
<script type="text/javascript">
var arrayOfObj = [ { one: "one", two: 2, three: "blah" }, { one: "xyz", two: "abc", three: 3.141 } ];
callSomeFunctionInFlex(arrayOfObj);
</script>
What would I do on the Flex side to make this happen?Complex object passing works as expected in Blazeds.
There are certain cases where you need to write custom bean proxy classes to marshall an object, but your case is very simple and will not require it.
Make sure that you set the full java package and class name in your remote alias statement on your client value object. The class has to be fully qualified. The AS value object also needs the correct import of the nested value object or you will get a compile error.
Make sure that the blazeds server has the full class path set to your java objects.
To debug, you can turn on Blazeds logging in the services-config.xml file like this:
<logging>
<!-- You may also use flex.messaging.log.ServletLogTarget -->
<target class="flex.messaging.log.ConsoleTarget" level="DEBUG">
<properties>
<prefix>[BlazeDS]</prefix>
<includeDate>false</includeDate>
<includeTime>false</includeTime>
<includeLevel>true</includeLevel>
<includeCategory>false</includeCategory>
</properties>
</target>
</logging> -
How to send xml to javascript from flex?
Hello,
I am using Flex Builder......I read blogs and wonderful tutorials on adobe website. But I found that I can only have data from Flex to script placed within main.template.html file.....when i tried to get same data by in my other .html or .aspx page, it did not work. Another thing I noticed in following tutorial
http://blog.flexexamples.com/2008/03/09/calling-javascript-functions-from-your-flex-applic ations-using-the-externalinterface-api/
is that we placed <iframe> in our html page to host flex object instead of using <object> tag etc.
Please just let me know how to do very same thing as defined in tutorial but by hosting out flex object using <object><embed> tags etc and how to get data into our .html or .aspx page rather putting javascript (to receive data) in main.template.html file generated by Flex Builder...???Thanks for replying,
Now I am facing another problem....I have added a script tag in index.template.html file that also contains other useful code used in my aspx page. I wanted to have that reply on my aspx page. So I placed all the script in a Core.js file and also the recieving method from flex in same Core.js file. I thought this way i will be able to access data coming from flex project to my aspx page. But something strange is happening, when i run .html file in bin-debug folder it fires receiving method placed in Core.js........but when I host that flex project .html file in my aspx page, it is not firing method. And also not firing when I run .html in bin-release folder....what am I doing wrong? -
Hi
I have a mxml file that has a button control
<mx:Button id="toggle" label="Test" click="ToggleButton()"
/>
When I click on the button I want to call the javascript
function. So in the mxml script I have
public function ToggleButton(): void
var f:String = "JSToggleButton";
var m:String = "this works";
var check:String;
if(ExternalInterface.available)
ExternalInterface.call(f,m);
check = "true"
else
check="false";
trace(check);
]]>
Now I created a text file by rightclicking on the assets(The
folder i created) folder in project and then new-->File.
I have written my javascript in that file and named it
JavaScriptToggle.html
This file has the following code
<SCRIPT LANGUAGE="JavaScript">
function JSToggleButton(m)
alert(m);
</SCRIPT>
It does not seem to show the alert box but the trace shows
true for ExternalInterface.available.
Am I missing anything important?????
I am completely new to flex. So it might be simple to most of
them. Please bear with me.quote:
If I have a project named Test does this mean that I have to
include my Javascript in the bin folder's Test.html file?
Yes, so somewhere in Test.html you will have to have that
javascript function. But remember that flex builder will recreate
the Test.html file everytime you rebuild and you will lose any
changes you make to that file directly. So make your alterations to
the html-template/index.template.html file and it will always
recreate your Test.html with that code included.
So just open up html-template/index.template.html and place
between the head tags
<script language="javascript"
type="text/javascript">
function JSToggleButton(m)
alert(m);
</script>
Then everything should hopefully be working -
Calling Javascript from Flex through FAB
What's the standard way of calling JavaScript functions from
Flex through the FA Bridge?
i.e. is there a new way other than navigateToURL or
ExternalInterface.call()
Most of the examples I've seen are scripting Flex from
JavaScript, not the other way around.
Thanks.Hello,
You need to register the JavaScript function as a callback to
a Flex action. You can do this from javascript in a function that
gets called when the flash movie has finished loading. Then, when
the Flex event is triggered it will execute the JavaScript
function.
Hope this helps,
Cristian -
When to use Flex Or Flash Or HTML-Javascript
I am Experimenting with Adobe AIR. I know AIR Applications
can be developed either using Html-Javascript Or Flex Or Flash.
But can anybody HELP me understand when do i exactly use Flex
or HTML-JS.
Well i know one of the reason to use Flex is to build
RIA's.What are the other Possible reasons ?? can i draw a Decision
Boundry between them??The best reason to choose one tool over the other is that you
have something working in that language already, and are just
extending it into the AIR world.
If you're starting a new project, you then have to balance
tools you have and know how to use against the strengths of the
tools. A tool you don't know has to have some pretty compelling
strengths to make you take the time to learn it, unless you're just
doing it for fun. If not for fun, the effort has to pay off, yes?
Very generally speaking, here are the strengths of the tools,
as I see it.
For HTML + Javascript, just look at what you see on the web
today. People are pushing browsers pretty hard these days with web
apps, so that gives you a good first-order idea of the power of
this tool set. The AIR environment does give you some more power,
not just in the AIR APIs, but also in having a single modern
browser to develop for, so you don't have to limit yourself to IE6
compatible code. Still, it's not yet the equal of the other tools
in some areas.
Flash's main advantage over the others is in applications
with lots of graphics and animation. The reason for this is purely
because that's what the Flash authoring environment is geared to
produce. It's not got a very good ActionScript editor, and as a
consequence there's a practical limit on how much code you want to
write in a given project. It's not a question of whether you
can write a 20,000 line ActionScript program within the
Flash environment, it's a question of whether it's better done in
another tool.
One of the best "other tools" when you end up with lots of
code is Flex. With the "Builder", you get Ecipse, and without, you
are presumably using some other worthy programming environment.
But, you give up the graphic and animation tools from Flash, and
you give up a lot of the simplicity of HTML + Javascript.
You can combine them, of course. You could build a whizzy GUI
control in Flash to use in a Flex application which is hosted
inside a web page, for instance. -
Can we copy Flex modelLocator to JavaScript?
I have a application developed in both Flex and HTML, JavaScript .. Somescreens will communicate to Javascript and vice versa. I need to transfer the whole Flex ModelLocator object to Javascript. Is it possible.?
I know using ExternalInterface or NatigateToUrl we can implement this. But I want to know like copying modelLocator from Flex to JavaScript is possible and good way?
Tell you with example:
I have a 1st page in Flex, 2nd page in HTML,Javascript and 3rd page is again in Flex.
I need to copy the model variables from Page1 to 2 (flex to Javascript) and If the user do any changes that will be added to the same model variable object then I will navigate to page 3 (javascript to Flex).
another question is: Can we convert our Flex Model into JavaScript Object? Is there any other way to do transfer the model object like this?Execute The Query in The Debug Mode, Then use the sy-repid to get the program name generated by the SAP Query.
Copy the name of the program, go to SE38, and paste the program name.
The press Ctrl + F5 to copy the Program to a zprogram, then click on OK to copy it, and then your query gets copied to a z program
Pablo
Reward Points If Helpful -
Hi,
is it possible to let the user download a text file which is
generated at run time?
I don't want to send it to a server side script to save the
file onto the server.
regards,
myatemright. i want to write the generated string to the filesystem
(the user can select the filename).
I've tryed to call javascript from flex that opens a new
browser window which shows my generated string. But this doesn't
work on my local file system. There is an "sandbox security
violation". I don't want to upload my files on a server before
running them each time.
Now i have written a webservice which i want to call from my
flex app to save the generated string on a server. Then i could
call FileReference.download(URL) to let the user save the generated
file to his local drive.
myatem -
Losing portal context when URL is submitted from flash/flex portlet
Hi, I am losing portal context when URL is submitted from action scripting in Flash/Flex portlet. I have selected the remote webservice portlet to use inline refresh. The jsp page is opening up in complete browser window instead of showing in portlet section.
below is the code snippet i am using.
<mm:mxml>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="200">
<mx:Script><![CDATA[
public function submitToBrowser():void {
var url:String = "formsubmit.jsp";
var u:URLRequest = new URLRequest();
var variables:URLVariables = new URLVariables();
variables.name = fName.text;
u.data = variables;
u.url = url;
u.method = "POST";
navigateToURL(u,"_self");
]]></mx:Script>
<mx:Form id="myForm" defaultButton="{mySubmitButton}">
<mx:FormItem label="User Name">
<mx:TextInput id="fName" name="fName"/>
</mx:FormItem>
<mx:FormItem label="Password">
<mx:TextInput id="password" displayAsPassword="true"/>
</mx:FormItem>
<mx:FormItem>
<mx:Button label="Submit" id="mySubmitButton"
click="submitToBrowser();"/>
</mx:FormItem>
</mx:Form>
</mx:Application>
</mm:mxml>inline refresh modifies javascript, not flex. Maybe try an iframe?
-
AIR JavaScript - Drag and drop to OS
I searched here for an example of how to drag-and-drop from
the AIR application to the OS
with JavaScript, not Flex or Flash. I only need to know
where the element has been dropped in order to start a download.
I only found an example for Flex. I read that you have to use
the clipboard but I didn't understand how to use it.
Does anyone have a simple example of that ?
If a tech from Adobe reads that, you should add this to your
documentation. ;)
Thanks.Sounds you are looking for this documentation:
http://help.adobe.com/en_US/AIR/1.1/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7e8a. html -
How to bring the browser window from background/minimized to on top of all windows in Flex
Hi I have the requireemnt where based on some condition I am opening a JSP in a new window by calling
navigateToURL(myFormData, _MYWINDOW);
Calling this will open a new browser window. My requirement is when the new window if minimized or behind other windows, how can I bring this window(MYWINDOW) infront of all the windows using JavaScript in Flex.
In which file under html-template do I have to write my JavaScript function.
Any help on how to call JS from Flex and handling in JS is very much appreciated.
Someone please share with me if there is any sample code. Thanks in advancehi
to communicate with javascript, use ExternalInterface (see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/External Interface.html for an example)
you can add your JS directly to the index.template file or create a separate JS file and add the link
not sure what JS you would use to bring window to front but i am guessing there is something... -
Removing div with flash/flex from page crushes browser
Hallo to all Flex experts !
For an application based on dojo ( javascript ) we prototype
the migration to flex -
The application is very big, we already work on it more than
2 years, so we try to make the migration smooth by implementing
parts of the application in flex.
To do that, we dynamically open a div with an <object>
/ <embed> in it, and close it on demand, by calling
javascript from flex, and simply remove the div from the document.
Problem is: this results in a browser crash ! (linux, FF 2,
Flash 9.0.31)
So, what is the recommended way to do that ( without crashing
the browser) ? how do we gracefully remove a flash/flex from the
page ?
Cheers,
Ronor [simple typo funonmars ;-) ]
my_vars.send("
http://some.com/file.php","_blank","POST");
I used it a few times today for just the type of thing you're
describing... it should do what you're after. -
Have you used Macromedia Flex?
Have you used Macromedia Flex? What's your opinion of it? My manager is good at
latching onto the flavor-of-the-week, but things I've read about Flex makes it sound
pretty good. Does anyone have any war stories?
Thanks,
LaszloFrom what I understand, Flex can be compared, roughly to JSP:
JSP:mixes html markup (typically) and jsp tags with Java and JavaScript in a text file (*.jsp).
The jsp-engine compiles that and what's delivered to the client's browser is html+JavaScript.
Flex: mixes XML markup with STL-like tags and tags for controls (they claim dozens, including tree
and calendar controls, editable comboxes etc...) and tags for layout (think LayoutManagers).
The event handlers are written in ActionScript which is supposed to be very JavaScript-like (and
in one place I read it was statically typed, hurrah!). Again this goes in a text file (*.wxml).
The Flex engine compile *.wxml files into flash programs (*.swf) and delivers this to Flash running
on the client. Flash, not the browser, executes the dynamic content.
Here are some of my concerns and non-concerns:
The Ubiquity of Penetration (is that an episode of Oz or what?) Flash is on a lot of desktops, but
Macromedia plays Three Card Monty by not pointing out that Flex needs the latest version (7)
to run, and that version is not everywhere, yet. But as their surveys show, it may be everywhere within a year.
This is a non-concern for me. I write apps for gov't employees so I've got a different issue: many of them
work in the boonies where their LAN support is execrable. And on top of that, their desktops are so screwed
down, the only thing they can install are browser plug-ins. So Flash fits.
The cost. Flex retails for $12,000 USD. That's seems a lot to me for something that's just in
the presentation layer.
This is version 1.0. Flash may be stable but how buggy is Flex?
Where's the Java?. ActionScript is supposed to be Java-like, but what would be cool would being
able use a subset of Java and the API for the dynamic content. This could be compiled on the server-side
and something like byte code could be sent to Flash to execute.
How fast and responsive are the Flash programs?
How big are the Flash programs generated by Flex to download? And how good are browsers at
caching flash programs? Do they use the same mechanism as for caching images? I'd hate to
redownload a flash program over a dialup line when bouncing between screens.
How good are the controls that Flex delivers? How does it compare to Swing, say. How comprehensive
Is their set of events?
What do you need on the server-side? Flex communicates to sever apps via (1) Web Services
(2) remote objects or (3) http calls, among other things. The Flex engine itself is a web-app, and
they list their system requirements as WebSphere 5+ (although it runs in Tomcat 5.0). Unfortunately,
our production admins only support WebSphere 4 Server.
Aside: I went to a product demo on Monday, and I have to say salesmanship in software products
creeps me out. Maybe because I came into programming through the back door, from math and logic,
but at demos I feel like I'm being sold a used car. The presenters kept referring to ROI. What do I know
about ROI? I thought they were talking about Le fils do roi... -
How do I set and use a custom time zone?
We're developing a mixed HTML, javascript and Flex application.
In our HTML/Flex application, one of user's settings is the time zone he wishes to use. Since this can be different from the local time zone of the computer he happens to be using, we need to tell flex to interpret all dates as being in a foreign time zone e.g. force it to America/Los_Angeles.
I'm hoping there is a way to specify this in flex, so we don't have to do offset calculations on every single Date object. This would be very complicated, as I'm sure you know (and no, it is not simply UTC + x, where x is a constant, or x is an integer number of hours...)
Is there a way to do this in flex?
Peter
P.S: I've found these related things so far:
asTimeZone: The svn repository is 404, and there seems to be no activity, but looks interesting...
A reference to the system class, but I couldn't find anything interested in the system class.
A comment that player 10 should have something useful, but I didn't find any thing about it elsewhere.
But nothing was really helpful...Oh, perhaps this isn't possible, according to Timezone Issues with remote (Date/Time) data and flash
But if you have knowledge of a way to do it, please let us know here. -
Is it possible to install folder level script automatically by any other application ?
I want to install folder level javascript through flex application .is it possible to do this or by any other technology.
1 way to do is to copy file using file stream of that application but as directory for folder level javascript is protected one therefore file operation give i/o error
any other solution .I do not think any Adobe product will allow you to do this for obvious reasons. '
You can use any installer program the will perform the installation for users if the users decide to allow your request.
Maybe you are looking for
-
I can't open native apps after update to mavericks
i update my macbook air to mavericks and after that i cant open any navite app on my mac i have try to reinstall it from safe mode and that just fix it for a few days now i got the same problem, please help me i need to fix it now please!!
-
Is there a way to keep Text2Speech locked in front on my screen at all times?
I want to be able to access Text2Speech at all times. It would be great to have it locked in the front of my screen at all times, even when I switch spaces. Does anyone know of a way to do this?
-
I am using iphone 4S with sprint carrier with IOS 7 and has error 1394
I am using iphone 4S with sprint carrier. It has IOS 7 and now I want to downgrade to IOS 6 and I have downloaded a firmware it is compatible with 4S. Now it shows error 1394 and I have tried to fix my host file in windows according to other forums i
-
When i go to view my movies and tv shows theres nothing there. they are all under my music folder under my songs lists and artist list. And instead of my movies being under their respected folders, my artist lists are there. Can someone pls help me w
-
I have made a server socket so how do i get the ip address of the client connecting to my server ??