综合技术

Communication between HTML and Adobe Flex Desktop application using Java Script

微信扫一扫,分享到朋友圈

Communication between HTML and Adobe Flex Desktop application using Java Script
0

This blog is about how to call an actionscript function from a html page using javascript and vice-versa.Here you can exchange data between a flex application and a html file. This will work for only local html files.

In this application, there are two files, FlexJsCommunication.mxml and sample.html . It will load sample.html file inside flex application using HTMLLoader . sample.html file is initially blank. When we browse a folder, it will load all images from that folder to sample.html page.

FlexJsCommunication.mxml

Sample.html

Explanation

In FlexJsCommunication.mxml , we have created an object of HTMLLoader which is htmlLoader . Using htmlLoader we load sample.html file. We can directly access the javascript methods using htmlLoader object.

In this application we call loadImagesFromFlex() by using htmlLoader.window.loadImagesFromFlex(files[i].nativePath);

It is taking image path as parameter and loading the image inside sample.html file.

While loading sample.html file, we have added an eventlistener for Event.HTML_DOM_INITIALIZE event. The HTMLDOMInitialize event is dispatched before any objects are created in the new HTML window or DOM. This gives us opportunity to create and initialize variables that objects in the new window can use. Since objects are not created yet, you can’t access them when this event is dispatched.

In HTMLDOMInitialize listener function, we assign

htmlLoader.window.sendImgPathToFlex = getSelectedImgPath;.

So when we call sendImgPathToFlex function in sample.html file, it will automatically execute getSelectedImgPath method. Here both the methods have same number of parameters. sendImgPathToFlex function is called when we mouseover on any image in sample.html . sendImgPathToFlex calls the getSelectedImgPath and loads the image inside the application.

You can download the example file from thislink.

Article by : Sushil Kumar Sahoo

Team Lead

Linkedin | Stackoverflow

阅读原文...


微信扫一扫,分享到朋友圈

Communication between HTML and Adobe Flex Desktop application using Java Script
0

Riaxe Blog

These Kickstarter earphones deserve to be funded

上一篇

旅游平台Lastminute创始人Brent Hoberman集资完成6000万美元创企基金

下一篇

评论已经被关闭。

插入图片

热门分类

Communication between HTML and Adobe Flex Desktop application using Java Script

长按储存图像,分享给朋友