Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > Adobe Flash

  • Print
  • + Share This
Like this article? We recommend

JavaScript to Flash

To retrieve the data in Flash, you first need to create the method that JavaScript will be calling with the flashProxy. Because you already defined this method in JavaScript, you are ready to create it in Flash. In the sample, the addItem() method is used to create bars and add them to the chart and a BarCollection class. The parameters that addItem() takes are the lender name and rate, which are the parameters you are already passing from the flashProxy object in JavaScript. The following is the addItem() method in Flash:

public function addItem(lender:String, rate:Number):Void {...}

To work around the bug I described earlier, you can create a method in Flash that accepts arrays of lenders and their corresponding rates. This allows the addItem() method to be accessible by multiple consecutive method calls.

public function addAllItems(lenders:Array, rates:Array):Void
{
  for(var i=0; i<lenders.length; i++)
  {
    this.addItem(lenders[i], rates[i]);
  }
}

The receiving methods in Flash can receive anything that you or your client desires; for instance, the sample could have been a line or pie chart. The best part is that setting it up to receive calls from JavaScript is simple after you build the foundation.

  • + Share This
  • 🔖 Save To Your Account