You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Saul Diaz <cr...@gmail.com> on 2015/11/23 01:27:22 UTC

FlexJS and ExternalInterface

Hi

 

Not sure is the right place to ask about this but will make my life super
easy.

 

FlexJS have anything like ExternalInterface that allows to integrate another
js SDK?

 

Regards

Saul


Re: FlexJS and ExternalInterface

Posted by Alex Harui <ah...@adobe.com>.

On 11/23/15, 9:43 AM, "Saul Diaz" <cr...@gmail.com> wrote:

>Hey alex.
>
>I love flexJS so far.
>
>Make sense.. I am starting to check all  the examples.
>
>The question is mostly how the pieces communicate. I need the JS  events
>sent to my code  and my code needs to call functions in the js.
>
>In short words Zoiper send there is a call incoming I should send to my
>code and my code can ask Zoiper to answer the call.  Pretty much
>
>Doing this without ExternalInterface maybe tricky.. there is any way the
>JS section can call something from inside the class that's created? And
>vice versa 

In your AS code for the SWF version you would continue to use
ExternalInterface.  The Zoiper class in AS might, for example, override
addEventListener, and call into the Zoiper JS code via ExternalInterface
to register a listener, and when the ZoiperJS code dispatches an event,
code calls back into the SWF via ExternalInterface and dispatches an event
from the Zioper instance in Flash.  I'm guessing that's how your code
works today.

But in your JS version, the Zoiper class's override of addEventListener
would just find the Zoiper instance and call whatever API it is that
listens for an event.  No need for some sort of ExternalInterface
emulation in the middle.

In the 0.5.0 source, there are two classes in
frameworks/projects/Core/as/src/org/apache/flex/core/BrowserResizeListener.
as and BrowserScroller.as.  Both use ExternalInterface to talk to the
browser.  The js/src/ versions don't use External interface at all.  Those
might serve as an example for you.

>
>I think can be doing using createjs/jquery wrapper will let you know how
>my adventure goes
>
><!-- the CreateJS text button component -->
><createjs:TextButton label="CreateJS" /> so I can get the events this
>baby have right?
>
>So creating a class in jquery and calling the jquery wrapper I can call
>all the methods in my class and receive all the events correct?

Yes, that's the theory.

-Alex


RE: FlexJS and ExternalInterface

Posted by Saul Diaz <cr...@gmail.com>.
Hey alex.

I love flexJS so far. 

Make sense.. I am starting to check all  the examples. 

The question is mostly how the pieces communicate. I need the JS  events sent to my code  and my code needs to call functions in the js. 

In short words Zoiper send there is a call incoming I should send to my code and my code can ask Zoiper to answer the call.  Pretty much 

Doing this without ExternalInterface maybe tricky.. there is any way the JS section can call something from inside the class that's created? And vice versa 

I think can be doing using createjs/jquery wrapper will let you know how my adventure goes

<!-- the CreateJS text button component -->
<createjs:TextButton label="CreateJS" /> so I can get the events this baby have right?

So creating a class in jquery and calling the jquery wrapper I can call all the methods in my class and receive all the events correct?

Interesting :) 
I am using falconJX 0.0.2 right now and I have being able to generate simple applications. going to try to upgrade to 0.0.5 this week. 

--
Saul
-----Original Message-----
From: Alex Harui [mailto:aharui@adobe.com] 
Sent: Monday, November 23, 2015 9:49 AM
To: users@flex.apache.org
Subject: Re: FlexJS and ExternalInterface

Hi Saul,

So in the FlexJS way of thinking, instead of implementing an JS equivalent for ExternalInterface (which is still a reasonable thing to do), I would recommend the following:

Create a Zoiper class in AS.  It would use ExternalInterface to call the below code in the wrapper.
Create a Zoiper class in JS.  It would not use ExternalInterface since it doesn't need to, it would just call the Zoiper code directly.

That way, your JS version will have the most optimal code paths.  Does that make sense?

BTW, the FalconJX compiler has been upgraded to the point where we are working on changing all of our JS code back to AS and using conditional compilation to have platform-specific JS generated from AS.  If you want to find out more about that, ask on the dev@ list.  We're finding that writing AS to output JS is more efficient because the type-checking catches errors.

-Alex

On 11/23/15, 7:11 AM, "Saul Diaz" <cr...@gmail.com> wrote:

>For example this function ,
>
>			<!-- The function "OnZoiperReady" is the entry point for Zoiper Web 
>usage. It is called by Zoiper Web when it is ready for use. It provides 
>a reference to its "Phone" object which we assign to the "Zoiper" variable.
>We use it to make the initial setup -->
>			function OnZoiperReady(phone)
>			{
>				Zoiper = phone;
>				Zoiper.AllowMultipleInstances();
>				
>				var Config = Zoiper.GetConfig();
>				Config.SetSIPIAXPorts("4566", "5060");
>				Config.PopupMenuOnIncomingCall = "false";
>				Config.RingWhenTalking = "false";
>				Config.AutoAnswer = true;
>				Config.UseEchoCancelation = true;
>				Config.RecordCalls = false;
>				Config.RingWhenTalking = false;
>				
>                <!-- Force the browser to set flex app with focus -->
>                var obj = swfobject.getObjectById("WebAgent");
>
>                if (obj) {
>                	obj.ZoiperReady();
>                }
>			}
>
>
>It sends to the swf a notification when the activeX (phone) was loaded
>
>Regards
>Saul
>-----Original Message-----
>From: Alex Harui [mailto:aharui@adobe.com]
>Sent: Sunday, November 22, 2015 9:51 PM
>To: users@flex.apache.org
>Subject: Re: FlexJS and ExternalInterface
>
>
>
>On 11/22/15, 4:27 PM, "Saul Diaz" <cr...@gmail.com> wrote:
>
>>Hi
>>
>> 
>>
>>Not sure is the right place to ask about this but will make my life 
>>super easy.
>>
>> 
>>
>>FlexJS have anything like ExternalInterface that allows to integrate 
>>another js SDK?
>
>We don't have such a thing now.  Simple versions might be easy to create.
>Can you provide another level of detail on what you are trying to do?
>There may be another/better way to do it in FlexJS.  For example, we 
>have wrapped Jquery and CreateJS components so you can work with them 
>more directly than you can with ExternalInterface.
>
>Thanks,
>
>-Alex
>
>



Re: FlexJS and ExternalInterface

Posted by Alex Harui <ah...@adobe.com>.
Hi Saul,

So in the FlexJS way of thinking, instead of implementing an JS equivalent
for ExternalInterface (which is still a reasonable thing to do), I would
recommend the following:

Create a Zoiper class in AS.  It would use ExternalInterface to call the
below code in the wrapper.
Create a Zoiper class in JS.  It would not use ExternalInterface since it
doesn't need to, it would just call the Zoiper code directly.

That way, your JS version will have the most optimal code paths.  Does
that make sense?

BTW, the FalconJX compiler has been upgraded to the point where we are
working on changing all of our JS code back to AS and using conditional
compilation to have platform-specific JS generated from AS.  If you want
to find out more about that, ask on the dev@ list.  We're finding that
writing AS to output JS is more efficient because the type-checking
catches errors.

-Alex

On 11/23/15, 7:11 AM, "Saul Diaz" <cr...@gmail.com> wrote:

>For example this function ,
>
>			<!-- The function "OnZoiperReady" is the entry point for Zoiper Web
>usage. It is called by Zoiper Web when it is ready for use. It provides a
>reference to its "Phone" object which we assign to the "Zoiper" variable.
>We use it to make the initial setup -->
>			function OnZoiperReady(phone)
>			{
>				Zoiper = phone;
>				Zoiper.AllowMultipleInstances();
>				
>				var Config = Zoiper.GetConfig();
>				Config.SetSIPIAXPorts("4566", "5060");
>				Config.PopupMenuOnIncomingCall = "false";
>				Config.RingWhenTalking = "false";
>				Config.AutoAnswer = true;
>				Config.UseEchoCancelation = true;
>				Config.RecordCalls = false;
>				Config.RingWhenTalking = false;
>				
>                <!-- Force the browser to set flex app with focus -->
>                var obj = swfobject.getObjectById("WebAgent");
>
>                if (obj) {
>                	obj.ZoiperReady();
>                }
>			}
>
>
>It sends to the swf a notification when the activeX (phone) was loaded
>
>Regards
>Saul
>-----Original Message-----
>From: Alex Harui [mailto:aharui@adobe.com]
>Sent: Sunday, November 22, 2015 9:51 PM
>To: users@flex.apache.org
>Subject: Re: FlexJS and ExternalInterface
>
>
>
>On 11/22/15, 4:27 PM, "Saul Diaz" <cr...@gmail.com> wrote:
>
>>Hi
>>
>> 
>>
>>Not sure is the right place to ask about this but will make my life
>>super easy.
>>
>> 
>>
>>FlexJS have anything like ExternalInterface that allows to integrate
>>another js SDK?
>
>We don't have such a thing now.  Simple versions might be easy to create.
>Can you provide another level of detail on what you are trying to do?
>There may be another/better way to do it in FlexJS.  For example, we have
>wrapped Jquery and CreateJS components so you can work with them more
>directly than you can with ExternalInterface.
>
>Thanks,
>
>-Alex
>
>


RE: FlexJS and ExternalInterface

Posted by Saul Diaz <cr...@gmail.com>.
For example this function ,

			<!-- The function "OnZoiperReady" is the entry point for Zoiper Web usage. It is called by Zoiper Web when it is ready for use. It provides a reference to its "Phone" object which we assign to the "Zoiper" variable. We use it to make the initial setup -->          
			function OnZoiperReady(phone)
			{
				Zoiper = phone;
				Zoiper.AllowMultipleInstances();
				
				var Config = Zoiper.GetConfig();
				Config.SetSIPIAXPorts("4566", "5060");
				Config.PopupMenuOnIncomingCall = "false";
				Config.RingWhenTalking = "false";
				Config.AutoAnswer = true;
				Config.UseEchoCancelation = true;
				Config.RecordCalls = false;
				Config.RingWhenTalking = false;
				
                <!-- Force the browser to set flex app with focus -->
                var obj = swfobject.getObjectById("WebAgent");

                if (obj) {
                	obj.ZoiperReady();
                }
			}


It sends to the swf a notification when the activeX (phone) was loaded  

Regards
Saul
-----Original Message-----
From: Alex Harui [mailto:aharui@adobe.com] 
Sent: Sunday, November 22, 2015 9:51 PM
To: users@flex.apache.org
Subject: Re: FlexJS and ExternalInterface



On 11/22/15, 4:27 PM, "Saul Diaz" <cr...@gmail.com> wrote:

>Hi
>
> 
>
>Not sure is the right place to ask about this but will make my life 
>super easy.
>
> 
>
>FlexJS have anything like ExternalInterface that allows to integrate 
>another js SDK?

We don't have such a thing now.  Simple versions might be easy to create.
Can you provide another level of detail on what you are trying to do?
There may be another/better way to do it in FlexJS.  For example, we have wrapped Jquery and CreateJS components so you can work with them more directly than you can with ExternalInterface.

Thanks,

-Alex



Re: FlexJS and ExternalInterface

Posted by Alex Harui <ah...@adobe.com>.

On 11/22/15, 4:27 PM, "Saul Diaz" <cr...@gmail.com> wrote:

>Hi
>
> 
>
>Not sure is the right place to ask about this but will make my life super
>easy.
>
> 
>
>FlexJS have anything like ExternalInterface that allows to integrate
>another
>js SDK?

We don't have such a thing now.  Simple versions might be easy to create.
Can you provide another level of detail on what you are trying to do?
There may be another/better way to do it in FlexJS.  For example, we have
wrapped Jquery and CreateJS components so you can work with them more
directly than you can with ExternalInterface.

Thanks,

-Alex