I don't think you can use D.eval in the way you are trying to.

After reading the documentation, there are a few things you need to do...

Instantiate an object of the type you are trying to use. You don't need to use 
this object but it needs to be created so Flex adds the class to the SWC. For 
example...

import mx.controls.Label;
var xxx:Label = new Label();

To crate a new Label (I think) you would have to do it this way...

var prog:String = 'import mx.controls.Label;\n' + 'new Label()';
var myLabel:Label = D.eval(prog) as Label;

You will probably need to contact the developers of D.eval for further support. 
This API seems very specialized and, it seems, you are the only one using it 
(Other than the developer).


HTH



Steve




--- In flexcoders@yahoogroups.com, Alexandre Demeure <alxd...@...> wrote:
>
> Hi,
> 
> I write you again because I haven't manage to use D.importClass(Label); 
> However, by using personnal classes, I was able to indirectly create labels, 
> here is
> the code:
> I have try to create a personal class which inerit of Label class
> or which have a Label property. The two working examples show how I did :
> 
> Example 1 what it works :
> 
> <?xml version="1.0" encoding="utf-8"?>
>  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
> creationComplete="init()"
> layout="vertical" cornerRadius="0" alpha="1.0" backgroundGradientAlphas="[1.0,
> 1.0]" backgroundGradientColors="[#EF0808, #F6E8E8]" color="#22B21B"
> borderColor="#202FC1">
>      <mx:Script>
>      <![CDATA[ 
>      import r1.deval.D;
>      public function init():void 
>      {
>          import maClasse;
>          D.importClass(maClasse);
>          D.eval("var M:maClasse = new maClasse(\"XXX\") ; 
> C_PM_P_2.addChild(M);",
> Dyna_context);
>      }
>      ]]>
>      ....
>      </mx:Script>
> </mx:Application>
> 
> maClasse.as :
> 
> package 
> {
>     import mx.controls.Label;
>     public class maClasse extends Label
>     {
>         public function maClasse(name:String)
>         {
>             super();
>             super.text = name;
>         }
>     }
> }
> 
> Example 2 what it works (just maClasse changed) : 
> 
> maClasse.as :
> 
> package 
> {
>     import mx.controls.Label;
>     public class maClasse
>     {
>         public var lab:Label;
>         public function maClasse(name:String)
>         {
>             super();
>             lab = new Label();
>             super.text = name;
>         }
>     }
> }
> 
> _____________________________________________________
> These examples work pretty fine. No runtime error.
> However it's still impossible to directly import and use a Label with D.eval,
> following code fails at runtime:
> 
> 
> The error message is :
> 
> Runtime Error: msg.rt.no.class [line:1]
>     at r1.deval.rt::CallExpr/getAny()
>     at r1.deval.rt::ExprStmt/exec()
>     at r1.deval.rt::Block/exec()
>     at r1.deval.rt::Block/run()
>     at r1.deval.rt::Env$/run()
>     at r1.deval::D$/eval()
>     at test/init()
>     at test/___test_Application1_creationComplete()
>     at flash.events::EventDispatcher/dispatchEventFunction()
>     at flash.events::EventDispatcher/dispatchEvent()
>     at mx.core::UIComponent/dispatchEvent()
>     at mx.core::UIComponent/set initialized()
>     at mx.managers::LayoutManager/doPhasedInstantiation()
>     at Function/http://adobe.com/AS3/2006/builtin::apply()
>     at mx.core::UIComponent/callLaterDispatcher2()
>     at mx.core::UIComponent/callLaterDispatcher()
> 
> 
> _____________________________________________________
> We suspect a problem with namespace or something like that (Label is defined 
> under a
> specific namespace)
> But we don't know how to import a namespace in D.eval neither how to use the
> namespace....and neither if it's really the problem ;o)
> 
> Does anyone have an idea about that problem?
> 
> Wishes
>


Reply via email to