0
problem with external as file
Explorer
,
/t5/animate-discussions/problem-with-external-as-file/td-p/89615
Sep 09, 2008
Sep 09, 2008
Copy link to clipboard
Copied
Hi everyone
Im currently experimenting with AS3 and I’m trying to attach an external actionscript file to a movie clip in the library
but I keep getting error messages, my .as file worked fine in AS2 and I cant figure out what the problem could be
heres the code in my fla file
var mymc:MovieClip = new Block;
this.addChild(mymc);
trace(mymc._framecount);
and heres my as file code
class Block extends MovieClip
{
public var _blocktype:Number;
public var _framecount:Number;
public function Block()
{_blocktype = 0;
_framecount = 6; }}
And I get the following errors when I run the main fla file
1017 the definition of base class movieclip was not found
5000 the class 'block' must subclass flash.display.MovieClip
I find this strange because AS2 never had this problem with my .as file anyway I did a bit of Goggling and changed the code to
package{
import flash.display.MovieClip;
class Block extends MovieClip
{
public var _blocktype:Number;
public var _framecount:Number;
public function Block()
{_blocktype = 0;
_framecount = 6; }}}
and now I get this error
1080 call to a possibly undefined method Block. var mymc:MovieClip = new Block;
I’ve checked the export for actionscript tick box and the class name is the same Block (capital B), its driving me nuts can anybody please put me out of my misery
Im currently experimenting with AS3 and I’m trying to attach an external actionscript file to a movie clip in the library
but I keep getting error messages, my .as file worked fine in AS2 and I cant figure out what the problem could be
heres the code in my fla file
var mymc:MovieClip = new Block;
this.addChild(mymc);
trace(mymc._framecount);
and heres my as file code
class Block extends MovieClip
{
public var _blocktype:Number;
public var _framecount:Number;
public function Block()
{_blocktype = 0;
_framecount = 6; }}
And I get the following errors when I run the main fla file
1017 the definition of base class movieclip was not found
5000 the class 'block' must subclass flash.display.MovieClip
I find this strange because AS2 never had this problem with my .as file anyway I did a bit of Goggling and changed the code to
package{
import flash.display.MovieClip;
class Block extends MovieClip
{
public var _blocktype:Number;
public var _framecount:Number;
public function Block()
{_blocktype = 0;
_framecount = 6; }}}
and now I get this error
1080 call to a possibly undefined method Block. var mymc:MovieClip = new Block;
I’ve checked the export for actionscript tick box and the class name is the same Block (capital B), its driving me nuts can anybody please put me out of my misery
TOPICS
ActionScript
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Engaged
,
/t5/animate-discussions/problem-with-external-as-file/m-p/89616#M1029
Sep 09, 2008
Sep 09, 2008
Copy link to clipboard
Copied
You need to make the Block class public, as in:
public class Block extends MovieClip
public class Block extends MovieClip
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
excelcius
AUTHOR
Explorer
,
/t5/animate-discussions/problem-with-external-as-file/m-p/89617#M1030
Sep 09, 2008
Sep 09, 2008
Copy link to clipboard
Copied
Bingo thanks mate just tried it, funny how the actionscript 2
version didn’t have a problem with it, is AS3 stricter about
public and private declarations
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Engaged
,
/t5/animate-discussions/problem-with-external-as-file/m-p/89618#M1031
Sep 09, 2008
Sep 09, 2008
Copy link to clipboard
Copied
According to 9.1 of the AS 3 spec:
http://livedocs.adobe.com/specs/actionscript/3/wwhelp/wwhimpl/js/html/wwhelp.htm
The default visibility for a class is internal (non-dynamic, and non-final).
The default visibility for a class is internal (non-dynamic, and non-final).
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Engaged
,
/t5/animate-discussions/problem-with-external-as-file/m-p/89619#M1032
Sep 09, 2008
Sep 09, 2008
Copy link to clipboard
Copied
By the way, that really tripped me up when I wrote my first
AS3 class and compiled it with a fla. I would have thought the fla,
if in the same directory as the class file, would also be in the
default package and thus could reference it (even if it was
internal). I guess the fla is not considered to be in the default
package.
In AS2, the default visibility of a class was public. (I don't remember if you even can modify a classes visibility in AS 2.)
By the way, I use FlexBuilder to create my classes, even when they will be compiled with the fla. FlexBuilder can create the class outline for you and it will explicitly add public to the text of the file. (Go FlexBuilder 😉
In AS2, the default visibility of a class was public. (I don't remember if you even can modify a classes visibility in AS 2.)
By the way, I use FlexBuilder to create my classes, even when they will be compiled with the fla. FlexBuilder can create the class outline for you and it will explicitly add public to the text of the file. (Go FlexBuilder 😉
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Guide
,
/t5/animate-discussions/problem-with-external-as-file/m-p/89620#M1033
Sep 10, 2008
Sep 10, 2008
Copy link to clipboard
Copied
quote:
Originally posted by: jpsoul
By the way, I use FlexBuilder to create my classes, even when they will be compiled with the fla. FlexBuilder can create the class outline for you and it will explicitly add public to the text of the file. (Go FlexBuilder ;-)
Why compile with the fla when Flexbuilder can do that for you?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Engaged
,
/t5/animate-discussions/problem-with-external-as-file/m-p/89622#M1035
Sep 10, 2008
Sep 10, 2008
Copy link to clipboard
Copied
LuigiL,
Sometimes I want to use Flash (the IDE) to create custom skins (assets) that often gets controlled by an app I make in FlexBuilder. Because the assets are created in the Flash IDE I need to compile them with the Flash IDE. Essentially, I use Flash to create a document class or other class that extends movieclip and use those classes to define the movieclip instances they contain. This way an artist can modify those movieclip instances (the artwork) and I can refer to them by their class type and class members.
I don't use the Flash IDE for anything other than setting up the artwork. All logic is scripted with FlexBuilder. In my opinion, the Flash IDE is a very crude scripting tool.
-JP
Sometimes I want to use Flash (the IDE) to create custom skins (assets) that often gets controlled by an app I make in FlexBuilder. Because the assets are created in the Flash IDE I need to compile them with the Flash IDE. Essentially, I use Flash to create a document class or other class that extends movieclip and use those classes to define the movieclip instances they contain. This way an artist can modify those movieclip instances (the artwork) and I can refer to them by their class type and class members.
I don't use the Flash IDE for anything other than setting up the artwork. All logic is scripted with FlexBuilder. In my opinion, the Flash IDE is a very crude scripting tool.
-JP
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Guide
,
/t5/animate-discussions/problem-with-external-as-file/m-p/89624#M1037
Sep 10, 2008
Sep 10, 2008
Copy link to clipboard
Copied
Basically you don't need any classes in the Flash IDE. A
designer just needs to give the assets a linkage identifier and
publish a swf. The programmer can then point to the assets in the
compiled swf and you can do compiling in Flexbuilder. Very nice
workflow.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
excelcius
AUTHOR
Explorer
,
/t5/animate-discussions/problem-with-external-as-file/m-p/89621#M1034
Sep 10, 2008
Sep 10, 2008
Copy link to clipboard
Copied
Hi
I’ve just found this whilst looking for info on organizing AS3 projects which kind of explains the reason for the problem
http://www.actionscript.org/forums/showthread.php3?p=787854
now Ive just gota get my head round this document structure thing to really understand it, does anybody know of any good tutorials on the subject?
I’ve just found this whilst looking for info on organizing AS3 projects which kind of explains the reason for the problem
http://www.actionscript.org/forums/showthread.php3?p=787854
now Ive just gota get my head round this document structure thing to really understand it, does anybody know of any good tutorials on the subject?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Engaged
,
/t5/animate-discussions/problem-with-external-as-file/m-p/89623#M1036
Sep 10, 2008
Sep 10, 2008
Copy link to clipboard
Copied
As far as the fla not being able to access classes internal
to the default package, this is what I think is going on:
The fla always has a document class. If you don't create one, Flash automatically creates it for you - in memory. That in memory document class is not in the default package and thus would not have access to internal classes of the default package.
The fla always has a document class. If you don't create one, Flash automatically creates it for you - in memory. That in memory document class is not in the default package and thus would not have access to internal classes of the default package.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Engaged
,
/t5/animate-discussions/problem-with-external-as-file/m-p/89625#M1038
Sep 10, 2008
Sep 10, 2008
Copy link to clipboard
Copied
That's the basic idea. However, I explicitly create the class
files that declare the movieclip instances rather than have flash
automatically create these classes. This is mainly to provide for
substitutable dependencies when doing unit testing. The unit test
can use a subclass of the document class that creates stubs for all
the movieclip instances, while the production code will use the
instances created by Flash. In either case, the test and the
production code refers to the document class type (polymorphism
allows the subclass to be used instead of its parent class the
document class).
I often create a controller class that takes the document class as an argument in the constructor. The controller class provides all the logic and controls the visual assets declared in the document class.
var skin:SomeDocumentClass = loader.content as SomeDocumentClass;
var myController:CustomController = new CustomController(skin);
The controller will do things like add event listeners to movieclips/buttons created in the document class.
This also makes it very easy to change the "skin". I just load a different swf that subclasses the same document class.
I often create a controller class that takes the document class as an argument in the constructor. The controller class provides all the logic and controls the visual assets declared in the document class.
var skin:SomeDocumentClass = loader.content as SomeDocumentClass;
var myController:CustomController = new CustomController(skin);
The controller will do things like add event listeners to movieclips/buttons created in the document class.
This also makes it very easy to change the "skin". I just load a different swf that subclasses the same document class.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Guide
,
/t5/animate-discussions/problem-with-external-as-file/m-p/89626#M1039
Sep 10, 2008
Sep 10, 2008
Copy link to clipboard
Copied
What framework are you using then for unit testing?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Engaged
,
/t5/animate-discussions/problem-with-external-as-file/m-p/89627#M1040
Sep 10, 2008
Sep 10, 2008
Copy link to clipboard
Copied
FlexUnit
I also use mock4as which is an open source mock object library I helped write: http://code.google.com/p/mock4as/
I also use mock4as which is an open source mock object library I helped write: http://code.google.com/p/mock4as/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Guide
,
/t5/animate-discussions/problem-with-external-as-file/m-p/89628#M1041
Sep 10, 2008
Sep 10, 2008
Copy link to clipboard
Copied
Interesting, but mocksamples.org ... I don't get that one
:-)
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Engaged
,
LATEST
/t5/animate-discussions/problem-with-external-as-file/m-p/89629#M1042
Sep 10, 2008
Sep 10, 2008
Copy link to clipboard
Copied
Hmmm... I actually didn't add that link or any content to
that site. I will follow up with the other guy.
I did however add a developer guide to the wiki: http://code.google.com/p/mock4as/wiki/DeveloperGuide
It's a rough draft which I will be editing in the near future. *** Coming soon... ;o)
I did however add a developer guide to the wiki: http://code.google.com/p/mock4as/wiki/DeveloperGuide
It's a rough draft which I will be editing in the near future. *** Coming soon... ;o)
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

