Is there a way to clone an embedded class? Because otherwise, I can’t directly use my custom methods.
Embedding from within the class doesn’t work.
package {
import flash.display.Sprite;
public class Player {
public var player:Sprite;
[Embed(source = '../lib/player.swf')] private var swf:Class;
public function Player() {
this = new swf(); // doesnt work
}
public function method1():void {
return;
}
}
}
Embedding from outside the class, also doesn’t work.
package {
import flash.display.Sprite;
public class Main {
public var player:Player;
[Embed(source = '../lib/player.swf')] private var swf:Class;
public function Main() {
player = Player(new swf()); // doesn't work
player = new swf() as Player; // doesn't work
}
}
}
Or maybe there is a way to instantiate a class from an embed and convert it to another class? Thanks.
I think what you’re looking for is this:
If the MovieClip you are importing only has 1 frame, you might need to change it to
Player extends Sprite. This snippet of course assumes that you have exported the MovieClip for ActionScript and given it the Class name “Player” from inside the Flash IDE. If you are having trouble you can look here for a step-by-step walkthrough.