4 Replies Latest reply on Aug 6, 2007 4:51 PM by ntsiii


      I wanted to activate a function only when a variable called "refresh" equals "1". I've got the video with this code:
      <?xml version="1.0"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="ac.send(); TimerExample();" layout="absolute" horizontalScrollPolicy="off" verticalScrollPolicy="off" width="151">
      import flash.events.*;
      import mx.events.*;
      import mx.controls.*;
      import flash.utils.Timer;

      private function clickEvt(event:Event):void {
      var theData:String = ""
      if (event.currentTarget.selectedItem.@data) {
      theData = event.currentTarget.selectedItem.@data;
      fscommand("Section", theData);

      public function TimerExample() {
      var myTimer:Timer = new Timer(1000, 0);
      myTimer.addEventListener("timer", timerHandler);
      Alert.show("Timer Started!");

      public function timerHandler(event:TimerEvent):void {
      var refresh:String = this.loaderInfo.parameters.refresh;
      <mx:HTTPService id="ac" url=" http://www.aspergercolony.com/AnimalCrossingMag/GuideFolders.php" resultFormat="xml" useProxy="false" showBusyCursor="true"/>
      <mx:Tree width="100%" height="100%" dataProvider="{ac.lastResult}" labelField="@label" click="clickEvt(event);"/>

      This is my HTML which I've copied directly from sites that it works on:

      The problem is it never seems to notice that "Refresh" equals "1". When I manually set it by adding
      under the <embed tag "FlashVars="refresh=1"" it works. So is it my JS?

      Any help tis GREATLY apprecaited!! :D
        • 1. Re: SetVariable();
          Michael Kraft
          It looks like you only have to states for refresh: 1 and 0. So why don't you use a boolean?


          private var myRefresh:boolean = true;

          if (myRefresh==true){
          • 2. Re: SetVariable();
            chris.huston.t10 Level 3
            The fscommand has been replaced with the ExternalInterface API. Here is a simple example:

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
            import flash.external.ExternalInterface;
            import mx.controls.Alert;

            private function getRefresh():void {
            var jsResult:String;
            if (ExternalInterface.available) {
            jsResult = ExternalInterface.call("getRefresh");
            } else {
            Alert.show("Wrapper not available");

            <mx:Button x="60" y="40" label="Button" click="getRefresh()"/>

            Then in your html you would add:

            <SCRIPT LANGUAGE="JavaScript">
            function getRefresh() {
            return "1";

            The above will show the Alert of 1. However, looking at your example, I am not sure why you need to call a JS function.

            • 3. Re: SetVariable();
              Kai001 Level 1
              Thanks for the help! :D

              ( Well I needed this tree to refresh whenever someone filled out a form in another frame. )
              • 4. Re: SetVariable();
                ntsiii Level 3
                Also, use resultFormat="e4x" instead of resultFormat="xml". "xml" is the old-fashioned AS2 xml object, now called XMLNode. It lacks sooo many of the great features of the new e4x XML class.