Enabling controls on a panel in CS4

General Discussion of Scripting for Flex, Flash & CS SDK

Moderators: Tom, Kukurykus

myranalis

Enabling controls on a panel in CS4

Post by myranalis »

I am having an issue with enabling a button in a panel (built in FlashBuilder 4, using Flex version 3.5). It works perfectly in CS5, but not in CS4. I have put debugging statements in enough to know that the hasDocs function is firing and is returning the correct result in CS4 - it is just setting the 'enabled' property that isn't happening. Suggestions anyone?

In the mxml:
Code: Select all        cmdViewCredits.enabled = hasDocs();

   public function hasDocs():Boolean{
            var reqResult:SyncRequestResult = CSXSInterface.instance.evalScript("hasDocs");            

            if (SyncRequestResult.COMPLETE == reqResult.status) {
                                        //shows true/false (boolean) as expected
               CSXSInterface.instance.evalScript( "notify"," Returning reqResult.data.result " + reqResult.data.result + " (" + typeof(reqResult.data.result) + ")");
               return reqResult.data.result;
            } else {
               return false;
            }         
         }
   


In the jsx:
Code: Select allfunction hasDocs() {
   var xml = "<object>";
   var r;
   if (documents.length)
      r = true;
   else
      r = false;
   
   xml += convertToXML(r, "result");
   xml += "</object>"
   
        //shows correct xml
   alert("returning " + xml + " in hasDocs");
   return xml;
}
Mike Hale

Enabling controls on a panel in CS4

Post by Mike Hale »

This may not help but with Flex Builder 3 I have never been able to access a control's properties outside of a function. It will not compile for me. If you know of a way I would love to see an example.

If I rewrite your code so setting the enabled property is in a function it works for me in CS4.

//cmdViewCredits.enabled = hasDocs();// throws compiler error
public function init():void{
cmdViewCredits.enabled = hasDocs();// works
}
myranalis

Enabling controls on a panel in CS4

Post by myranalis »

Sorry, it is already in a function in the real code, I just shorted it for posting... The full calling code below now. As I said, I can tell the event is being fired fine - hasDocs returned the
correct result. The assignment of the enabled property is trivial - so why in the world is it an issue? BTW, I've also assigned the result to a boolean var before assigning it to cmdViewCredits.enabled and that doesn't help either.

Code: Select allpublic function PhotoshopCallback(eventID:Number, descID:Number):void{
   if( eventID == charToInteger("Opn ") || eventID == charToInteger("Cls ") || eventID == charToInteger("Mk  "))  {
      enableControls();
   }
}

public function enableControls():void{
   cmdViewCredits.enabled = hasDocs();
}

Thanks Mike.

Anna