I’m trying to start using a Flash IDE called FlashDevelop which uses no .FLA editor which is what I’m used to. I’ve found how to embed files from the /lib folder into a project but am unsure how to, as I’ve done before, associate a embedded file (for example a .jpg) with a .as file to provide it with instructions on how to act. Below is the code representing my attempts to figure it out, thanks in advance for any help.
package
{
import flash.display.Bitmap;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
[Frame(factoryClass="Preloader")] //This references an auto generated preloader which I haven't touched
public class Main extends Sprite
{
[Embed(source="../lib/index.jpg")]
public var logo:Class; //I'm attempting to connect the image in the above line to my logo.as file, all that's in there is an empty constructor and a simple update method that moves the image to the right
public var pic:logo;
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
pic:logo = new logo();
addChild(pic);
addEventListener(Event.ENTER_FRAME, update);
}
private function update(e:Event):void
{
pic.update();
}
}
}
You can simply move your index.jpg embed and instantiation into logo.as. (Also, if you stick to naming your classes with capital letters it can help avoid confusion between classes and variables, so for example I would call it Logo.as instead.) Then your main class only needs to add a
new Logo()and Logo.as will take care of creating the actual image.Edit: Also, make sure you’re not doing this by accident:
That should just be: