
|
If you were logged in you would be able to see more operations.
|
|
|
Flash Player
Created: 05/08/08 04:52 PM
Updated: 02/12/09 07:00 PM
|
|
| Component/s: |
None
|
|
Security Level:
|
Public
(All JIRA Users
)
|
|
|
Consider this simple class attempting to instantiate the class "Foo" using getDefinitionByName. Both Foo.as and Document.as (the document class) are located in the same directory:
Foo.as:
package {
import flash.display.MovieClip;
public class Foo extends MovieClip {
}
}
Document.as:
package {
import flash.display.MovieClip;
import flash.utils.getDefinitionByName;
public class Bar extends MovieClip {
public var foobar:*;
public function Bar():void {
var classRef:Class = getDefinitionByName("Foo") as Class;
foobar = new classRef();
}
}
}
result: ReferenceError: Error #1065: Variable Foo is not defined.
The compiler clearly isn't loading Foo.as since it hasn't been explicitly declared or imported anywhere in Document.as. Even if you explicitly declare the entire package classpath to a custom class, you still get the same compiler error, e.g.:
Document.as:
package {
import flash.display.MovieClip;
import flash.utils.getDefinitionByName;
public class Bar extends MovieClip {
public var foobar:*;
public function Bar():void {
var classRef:Class = getDefinitionByName("com.example.Foo") as Class;
foobar = new classRef();
}
}
}
result: ReferenceError: Error #1065: Variable Foo is not defined.
However, if you attempt to instantiate a class in the flash.* packages, the SWF will compile whether or not you import the necessary package:
Document.as:
package {
import flash.display.MovieClip;
import flash.utils.getDefinitionByName;
public class Bar extends MovieClip {
public var foobar:*;
public function Bar():void {
var classRef:Class = getDefinitionByName("flash.geom.Point") as Class;
foobar = new classRef();
}
}
}
Expected result: Variable Point is not defined.
Actual result: no errors
I realize this is probably because the Flash CS3 probably loads all flash.* classes when you compile from the IDE. But it still seems like a double standard that Flash CS3 allows you to forgo importing classes in flash.* (contrary to what's stated in the online documentation), but it does require you to import or explicitly declare custom classes, especially since getDefinitionByName is most likely to be primarily used to instantiate classes outside of the flash.* core.
Requested feature: getDefinitionByName should be able to dynamically load classes not explicitly declared or imported, as long as they're in the correct classpath set in Flash CS3 preferences
|
|
Description
|
Consider this simple class attempting to instantiate the class "Foo" using getDefinitionByName. Both Foo.as and Document.as (the document class) are located in the same directory:
Foo.as:
package {
import flash.display.MovieClip;
public class Foo extends MovieClip {
}
}
Document.as:
package {
import flash.display.MovieClip;
import flash.utils.getDefinitionByName;
public class Bar extends MovieClip {
public var foobar:*;
public function Bar():void {
var classRef:Class = getDefinitionByName("Foo") as Class;
foobar = new classRef();
}
}
}
result: ReferenceError: Error #1065: Variable Foo is not defined.
The compiler clearly isn't loading Foo.as since it hasn't been explicitly declared or imported anywhere in Document.as. Even if you explicitly declare the entire package classpath to a custom class, you still get the same compiler error, e.g.:
Document.as:
package {
import flash.display.MovieClip;
import flash.utils.getDefinitionByName;
public class Bar extends MovieClip {
public var foobar:*;
public function Bar():void {
var classRef:Class = getDefinitionByName("com.example.Foo") as Class;
foobar = new classRef();
}
}
}
result: ReferenceError: Error #1065: Variable Foo is not defined.
However, if you attempt to instantiate a class in the flash.* packages, the SWF will compile whether or not you import the necessary package:
Document.as:
package {
import flash.display.MovieClip;
import flash.utils.getDefinitionByName;
public class Bar extends MovieClip {
public var foobar:*;
public function Bar():void {
var classRef:Class = getDefinitionByName("flash.geom.Point") as Class;
foobar = new classRef();
}
}
}
Expected result: Variable Point is not defined.
Actual result: no errors
I realize this is probably because the Flash CS3 probably loads all flash.* classes when you compile from the IDE. But it still seems like a double standard that Flash CS3 allows you to forgo importing classes in flash.* (contrary to what's stated in the online documentation), but it does require you to import or explicitly declare custom classes, especially since getDefinitionByName is most likely to be primarily used to instantiate classes outside of the flash.* core.
Requested feature: getDefinitionByName should be able to dynamically load classes not explicitly declared or imported, as long as they're in the correct classpath set in Flash CS3 preferences |
Show » |
|
All
|
Comments
|
|
Sort Order:
|
| There are no comments yet on this issue.
|
|