开发者

Type Coercion in Flash/AS3

This problem is preventing me from continuing on with my project, and I don't know how or why its happening.

I have an app that asks the user for input, then generates graphs and displays images based on said input. The graph file is attached as a document class. Two fields are text, and the other two are sliders. When I try to run the app, I get a

TypeError: Error #1034: Type Coercion failed, cannot convert flash.display.MovieClip to
fl.controls.Slider`
at flash.display::Sprite/constructChildren();
at flash.display::Sprite()
at flash.display::MovieClip

This error pops up with this code:

var graphing:graph= new graph(); //my plot functions

function advance(e:MouseEvent):void{
  continueButton= false;
  displayHelp= ""; //clear the help area <-- debugger triggers errors here
  initInvest= int(initInvest_txt.text);
  lumpSum= int(withdrawal.text);
  graph= new graph();
  graph.setValues(lumpSum, initInvest);
  gotoAndPlay("options");
}

This error only shows when the graph declaration and method calls are in scope. If they are removed or commented out, the flow works. The graph file is

package{
  public class graph extends MovieClip{
    public function graph(){}
  }
}

Everything I've come across suggests that this is a result of of MovieCli开发者_运维问答p not being converted to a Slider component. However, there is no solution to this at all.

First, why is this happening?

Second,


I'm also playing around with components right now and I encountered the same thing. I was able to fix it by only having the external class definition only be visible to the fla/project that will be used in generating the swc. So basically, make sure that the component's external class is not visible to the project that will be using the generated swc, else, the type coercion error occurs. It's probably because the same class is being included in the swc.


Somewhere, you are trying to assign a MovieClip reference to a variable or function parameter that is typed as a Slider. A Slider is a Sprite, but it's not a MovieClip.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜