Skip navigation
Currently Being Moderated

Passing Repeater dataProvider info to an AS function showing 1067 error

May 31, 2007 8:15 AM

I'm getting a compiler error 1067: Implicit coercion of a value of type String to an unrelated type Number, with this following code (against the lines x="getRelXPos({wallRepeater.currentItem.x});" and y="getRelYPos({wallRepeater.currentItem.y});"), I haven't a clue what it means though.

The data wallAC comes in from an external XML file with a bunch of thumb nodes, x and y values are 0.0 to 1.0 so I can make up a relative coordinate system regardless of window size.

<mx:Repeater id="wallRepeater" dataProvider="{wallAC.thumb}">

public function getRelXPos(xVal:Number):Number {
var iW:Number = myCanvas.width;
var xPos:Number = xVal * iW;
return xPos;

public function getRelYPos(yVal:Number):Number {
var iH:Number = myCanvas.height;
var yPos:Number = yVal * iH;
return yPos;

My first guess was that Flex was treating the wallRepeater.currentItem.x and y values as strings and so was expecting a string back, so I changed the functions to look like this:

public function getRelXPos(xVal:String):String {
var iW:Number = myCanvas.width;
var xPos:Number = parseFloat(xVal) * iW;
return xPos.toString();

But that still showed the same compiler error.

Any ideas on where I'm going wrong here? I should point out that I'm pretty rubbish at Actionscript!


More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points