Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

TypeError: Error #1006: value is not a function.

Guest
Jul 07, 2010 Jul 07, 2010

I'm getting this error:

TypeError: Error #1006: value is not a function.
    at project_fla::MainTimeline/createMap()
    at project_fla::MainTimeline/frame1()

heres the actionscript:

function createMap(target:Object, map:Array, tilesize:Number):void {
    for (var ix:Number=0; ix<map[0].length; ix++) {
        for (var iy:Number=0; iy<map.length; iy++) {
            this["t"+String(ix)+"x"+String(iy)] = new Object();
            this["t"+String(ix)+"x"+String(iy)] = new tile();
            this["t"+String(ix)+"x"+String(iy)].gotoAndStop(map[ix][iy]);
            this["t"+String(ix)+"x"+String(iy)].x = Flxy(new Point(ix,iy), tilesize).x;
            this["t"+String(ix)+"x"+String(iy)].y = Flxy(new Point(ix,iy), tilesize).y;
            target.addChild(this["t"+String(ix)+"x"+String(iy)]);
        }
    }
}

{/A]

What's wrong with the code?

TOPICS
ActionScript
14.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Jul 07, 2010 Jul 07, 2010

There ya go. You have to give your clip on stage an instance name -when you select the clip - the instance name is the field above the instance behavior dropdown at the very top of the properties panel...

Translate
Guest
Jul 07, 2010 Jul 07, 2010

oh, heres the other function being used in that function. its in frame1 aswell

function Flxy(p:Point, s:Number):Point {
    return new Point(s*(p.x-p.y)/2,s*(p.x+p.y)/4);
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 07, 2010 Jul 07, 2010

In Publish Settings > Flash Tab in the Advanced section check Permit Debugging - that will tell the line number of the error... I don't see anything at first glance. Although, I'm not sure why you have:

this["t"+String(ix)+"x"+String(iy)] = new Object();
this["t"+String(ix)+"x"+String(iy)] = new tile();

You can omit the new Object line...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 07, 2010 Jul 07, 2010

I forgot to emit that line.  It was a test of mine to try and get rid of the error but it didn't work .

It's gone now.

the line with the error is this:

line 88: target.addChild(this["t"+String(ix)+"x"+String(iy)]);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 07, 2010 Jul 07, 2010

In a quick test that line seems to work OK for me... I think you can much simplify this though - something like so:

function createMap(target:Object, map:Array, tilesize:Number):void {
    var t:tile;
    for (var ix:Number=0; ix<map[0].length; ix++) {
        for (var iy:Number=0; iy<map.length; iy++) {           
            t = new tile();
            t.name = "t" + String(ix) + "x" + String(iy);
            t.gotoAndStop(map[ix][iy]);
            t.x = Flxy(new Point(ix,iy), tilesize).x;
            t.y = Flxy(new Point(ix,iy), tilesize).y;
            target.addChild(t);
        }
    }
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 07, 2010 Jul 07, 2010

I put in your code instead. Thanks for that .  Still getting the error tho.

target.addChild(t);

is giving me an error for some reason.  It's driving me crazy.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 07, 2010 Jul 07, 2010

What is target?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 07, 2010 Jul 07, 2010

target is a movieclip on the stage called "g".

createMap(g, array, 40);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 07, 2010 Jul 07, 2010

Outside of your function can you just do: g.addChild(new tile());  ?


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 07, 2010 Jul 07, 2010

I just found out that it works when i use:

createMap(this, array, 40);

however,

i need to addChild into that g movieclip

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 07, 2010 Jul 07, 2010

when i try that outside the function it says

1061: Call to a possibly undefined method addChild through a reference with static type String.

does it think g is a string?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 07, 2010 Jul 07, 2010

There ya go. You have to give your clip on stage an instance name -when you select the clip - the instance name is the field above the instance behavior dropdown at the very top of the properties panel...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 07, 2010 Jul 07, 2010
LATEST

hm.  it has an instance name g... in-fact all the other functions using that target work

i changed the instance name to "game" instead and used that same name in all the preceding functions and it works fine now.

i didn't define "g" anywhere else so it still confuses me. lol

but as long as it's working.  Thank you

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines