3 Replies Latest reply on Jan 19, 2012 7:41 AM by Claudiu Ursica

    addChild or addElement? from swc to flex stage?


      I usually just write applications as Actionscript projects. Now I trying to work with some of the newer flex components so I am working in a Flex Project.


      No issues with the components really but I would like to know how to add a MovieClip from an assets.swc that I created in the Flash IDE to the stage of the flex app. This way I can use the flex components with my own custom MCs.


      As a side question, how do i init a function as soon as the view loads. I tried adding an eventListener for the ADDED_TO_STAGE but that threw an error too.


      I have a feeling that I am just missing the relationship of the stage and how to place on and call things to it.


      Thanks in advance.


      I was trying something simple like this:



      <?xml version="1.0" encoding="utf-8"?>

      <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"


                               actionBarVisible="true" fontSize="17" tabBarVisible="true" title="title">




                                              private var alert:Alert;


                                              protected function btnTester_clickHandler(event:MouseEvent):void


                                                             alert = new Alert();

                                                             alert.title.text = "TEST COMPLETE";





                     <s:Button id="btnTester" x="250" y="0" label="Button" click="btnTester_clickHandler(event)"/>



      Results in:

      Error: addChild() is not available in this class. Instead, use addElement() or modify the skin, if you have one.

                at spark.components.supportClasses::SkinnableComponent/addChild()[E:\dev\4.y\frameworks\proj ects\spark\src\spark\components\supportClasses\SkinnableComponent.as:1123]