Flex / Example 7

.NET Edition of the F-IN-BOX
fender
Posts: 2
Joined: Sun Jul 06, 2008 8:46 pm

Flex / Example 7

Postby fender » Sun Jul 06, 2008 8:55 pm

Hi

I have just made my first Hello World application. I am using example 7 and I have made a small Flex 3 program instead of the flash .swf file. The program looks like this:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<mx:Application initialize="init();" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
   <mx:Button id="mine" x="10" y="10" label="Button"/>
   <mx:Script>
      <![CDATA[
         import flash.external.*;
         private function init() : void {
            ExternalInterface.addCallback("CallMeFromApplication", InternalFunction);
         }
         public function InternalFunction(str: String): String {
            mine.label = "Hey";
            return ":random" + Math.random();
         }
      ]]>
   </mx:Script>
</mx:Application>


I correctly get a new random number back to the c# application but the label on the button will not change. It seems like I have two instances. One visible - and one invisible which recieves the calls

Does anybody know how to fix this?

Ben

fender
Posts: 2
Joined: Sun Jul 06, 2008 8:46 pm

Problem solved

Postby fender » Thu Jul 17, 2008 6:09 pm

I found the solution to my problem

The line:

Code: Select all

f_in_box__control1.FlashMethod_Play();


Must be removed. For some reason it creates a new instance - and then I have one visible and one invisible.
Both instances can call my C# code, but my C# code can only call the invisible instance.

Maybe the example should be extended with

Code: Select all

// The following line must be removed if the .swf file is created using Flex
f_in_box__control1.FlashMethod_Play();


/Ben

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Fri Jul 18, 2008 11:47 am

Yes, you're right...

Thank you for this information, we will update the samples.

Thank you.
Best regards, Artem A. Razin,
F-IN-BOX support
Ask your question here: http://www.f-in-box.com/support.html


Return to “.NET Edition”

Who is online

Users browsing this forum: Bing [Bot] and 13 guests

cron