开发者

Adding Flash Components to Stage Dynamically from AS3 File

开发者 https://www.devze.com 2022-12-17 09:15 出处:网络
When I attempt to create a new flash list component from my as3 file (FrontEnd.as) and add it to the stage, I get the following error: \"1046: Type was not found or was not a compile-time constant: Li

When I attempt to create a new flash list component from my as3 file (FrontEnd.as) and add it to the stage, I get the following error: "1046: Type was not found or was not a compile-time constant: List". Below is the code:

package {

import flash.display.MovieClip;
import fl.controls.List;

public class FrontEnd extends MovieClip {

    public function FrontEnd():void {
        trace("FrontEnd Here");
        init();
    }

    private function init() {
        var userSelect:List = new List();
        addChild(userSelect);
        userSelect.move(200, 100);
        userSelect.width = 120;
    }
}

}

Someone commented on a livedocs page that you have to drag the component to the .fla library and cannot create it solely from as3. Is this really 开发者_如何学Pythontrue? Hoping someone can set me straight, thanks.


That is true, Think of the UI Components in Flash as made of 2 parts:

  1. The classes that manage the components
  2. The visual assets of the components.

When you import the classes from actionscript alone, they will be missing the visual elements that go hand in hand with that, so just drag the List component to the Library and you should be fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消