View Full Version : calling function from external as file
Radica1Faith
November 25th, 2008, 01:09 PM
Alright, I seem to be having trouble figuring out how to call a function from an external AS file from within a movieclip.
Anyone have any ideas?
Radica1Faith
November 25th, 2008, 01:12 PM
I tried compMain(parent).createOptions(); but I ended up getting this
TypeError: Error #1034: Type Coercion failed: cannot convert intro_mc@3142971 to compMain.
JTF2
November 25th, 2008, 03:14 PM
If it is defined as a public static function in your external class, you can call it simply as SomeClass.someFunction(), otherwise you would have to get a reference to your external class, and call your public function from that reference. I believe you are getting your error because compMain does not contain your MovieClip.
Radica1Faith
November 25th, 2008, 06:21 PM
If it is defined as a public static function in your external class, you can call it simply as SomeClass.someFunction(), otherwise you would have to get a reference to your external class, and call your public function from that reference. I believe you are getting your error because compMain does not contain your MovieClip.
Right compMain is the name of my class and external AS file so it wouldn't contain my movieclip. My movieclip is just on the timeline and within it I want to call a function from my class. So given what you said, I guess I'm going to have to get a reference to it. But to be honest I have no idea how to go about doing that. Could anyone possibly point me in the right direction? Any help is greatly appreciated.
Radica1Faith
November 25th, 2008, 06:44 PM
eh screw it. I figured out how to make an instance of my class within the movie clip but that isn't going to store the variables I need to throughout the game. It was bad programming practice of me to put it inside a movie clip anyway I'm going to redo it and put it on the main timeline.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.