AS3 and Set/Get Variable
October 30, 2008 12:00 AM
Someone from Trivantis can correct me if I'm wrong BUT - in my experience using the Lectora actions to set values/control elements in flash can be a little buggy - especially in AS3. To their credit though, there are a lot of ways to do things in flash and alot of whether it will work or not depends on how you build your flash movie. That being said, I tend to control everything from the flash side. So if you want to hide a flash button based on what a user does in Lectora I would set flash up to "listen" to a lectora variable and when it changes, hide the button. In lectora you would create a variable (in this case one called "test") and set it to 0. When the event happens where you want the flash button to hide use some lectora actions to set the variable to 1. In flash you would need the following code:import flash.external.ExternalInterface;var getLectoraVar:String;addEventListener(Event.ENTER_FRAME, varCheck);function varCheck(evt:Event):void{ getLectoraVar = ExternalInterface.call("Vartest.getValue"); if(getLectoraVar != "0"){ //PUT YOUR CODE HERE TO HIDE THE BUTTON }}[/CODE]This just runs a loop to see when that lectora variable changes. You will need to make sure that you set the parameter "allowScriptAccess" to always on your flash movie in Lectora. Hope that helps.Edited By: Hemingway on 2008-10-30 13:28:57[CODE]import flash.external.ExternalInterface;var getLectoraVar:String;addEventListener(Event.ENTER_FRAME, varCheck);function varCheck(evt:Event):void{ getLectoraVar = ExternalInterface.call("Vartest.getValue"); if(getLectoraVar != "0"){ //PUT YOUR CODE HERE TO HIDE THE BUTTON }}[/CODE]This just runs a loop to see when that lectora variable changes. You will need to make sure that you set the parameter "allowScriptAccess" to always on your flash movie in Lectora. Hope that helps.Edited By: Hemingway on 2008-10-30 13:28:57
Discussions have been disabled for this post