Hello,

Mon hypothèse:
C'est un problème de nom de classe, non ? (deux classes disposent du  
même nom). Dans le contexte, la conversion ne peut pas fonctionner,  
car le compileur fait une mauvaise interprétation de la classe à  
utiliser .. n'est-il pas ?

la classe DynamicField est dans le package 'custom.component.'
et l'erreur pointe sur la classe DynamicField du package  
'energitim.component.'

Question: Existe-il deux classes avec le même nom ?

Cedric

>
> Bonjour,
>
> J'ai un soucis avec un composant custom (non v3) que je souhaite
> mettre en place dans le cadre d'un projet.
> J'ai un problème de typage que je n'explique pas, à chaque fois que je
> publie une animation contenant ce composant dont je modifie au moins 1
> paramétre (si aucun paramètre n'est modifié, il n'y a pas d'erreurs) :
>
> TypeError: Error #1034: Echec de la contrainte de type : conversion de
> energitim.component::dynamicfi...@26dbc031 en
> energitim.component.DynamicField impossible.
>
> Avec le code suivant :
>
> package custom.component
> {
>       //import custom.text.TextDisplayer;
>
>       import flash.display.DisplayObjectContainer;
>       import flash.display.MovieClip;
>       import flash.events.Event;
>       import flash.events.MouseEvent;
>       import flash.text.Font;
>       import flash.text.TextField;
>       import flash.text.TextFieldAutoSize;
>       import flash.text.TextFormat;
>       import flash.text.TextFormatAlign;
>
>       public class DynamicField extends MovieClip
>       {
>               public  var tText        :TextField;
>               public  var tFormat      :TextFormat;
>               public  var iCustomWidth :Number;
>               public  var iCustomHeight:Number;
>               private var arrFont      :Array = new Array();
>               private var bReady:Boolean = false;
>
>
>               public function DynamicField()
>               {
>                       super();
>                       initComponent();
>                       bReady = true;
>               }
>
>               protected function initComponent():void
>               {
>                       trace("init");
>                       setListener();
>               }
>
>               protected function getDefaultFont():void
>               {
>                       var arrFont:Array=Font.enumerateFonts();
>                       arrFont.sortOn("fontName", Array.CASEINSENSITIVE);
>               }
>
>               protected function setDefaultProperties():void
>               {
>                       tText.width = this.width;
>                       scaleX=scaleY=1;
>                       tText.htmlText="placez votre texte ici";
>                       tText.autoSize = TextFieldAutoSize.LEFT
>                       tText.wordWrap=false;
>               }
>
>               protected function createDefaultTextFormat():void
>               {
>                       tFormat = new TextFormat();
>                       tFormat.color=0x000000;
>               }
>
>               protected function setListener():void
>               {
>                       
> this.addEventListener(Event.ADDED_TO_STAGE,handleOnStage);
>                       this.addEventListener(MouseEvent.CLICK,handleOnSelect);
>               }
>
>               protected function removeListener():void
>               {
>                       
> this.removeEventListener(Event.ADDED_TO_STAGE,handleOnStage);
>                       
> this.removeEventListener(MouseEvent.CLICK,handleOnSelect);
>               }
>
>
>               protected function refreshField():void
>               {
>                       refreshSize();
>                       refreshFormat();
>               }
>
>               protected function refreshSize():void
>               {
>                       if(iCustomWidth != 0 && iCustomHeight != 0)
>                       {
>                               tText.width  = iCustomWidth;
>                               tText.height = iCustomHeight;
>                       }
>               }
>
>               protected function refreshFormat():void
>               {
>                       tText.setTextFormat(tFormat);
>               }
>
>               public function setSize(w:Number,h:Number):void
>               {
>                       iCustomHeight = h;
>                       iCustomWidth  = w;
>                       refreshSize();
>               }
>               /*
>               protected function getText():void
>               {
>                       var oText:* = findTextDisplayer(this.parent);
>                       if(oText)
>                       {
>                               
> tText.htmlText=TextDisplayer(oText).getContent(this.name);
>                               refreshFormat();
>                       }
>                       else
>                       {
>                               trace("[Warning] No TextDisplayer found, the 
> content wont be
> displayed.");
>                       }
>
>               }
>
>               protected function findTextDisplayer(obj:Object):*
>               {
>                       if(obj is TextDisplayer)
>                               return obj;
>                       else if(obj is DisplayObjectContainer)
>                       {
>                               if(DisplayObjectContainer(obj).parent!=null)
>                                       return 
> findTextDisplayer(DisplayObjectContainer(obj).parent)
>                               else
>                                       return false;
>                       }
>               }
>
>               */
>               protected function handleOnStage(e:Event):void
>               {
>                       setDefaultProperties();
>                       createDefaultTextFormat();
>                       tText.defaultTextFormat=tFormat;
>                       getDefaultFont();
>                       //getText();
>               }
>
>               protected function handleOnSelect(e:MouseEvent):void
>               {
>                       trace("texte selectionné");
>               }
>
>
>               [Inspectable(name="1 - Text", defaultValue="placez votre texte 
> ici",
> type="String")]
>               public function set htmlText(value:String)
>               {
>                       if(bReady)
>                       {
>                               tText.htmlText=value;
>                               refreshFormat();
>                       }
>               }
>
>               [Inspectable(name="2 - Size", defaultValue="10", type="Number",
> format="Number")]
>               public function set size(value:Number)
>               {
>                       if(bReady)
>                       {
>                               tFormat.size=value;
>                               refreshFormat();
>                       }
>               }
>
>               [Inspectable(name="3 - Color", defaultValue="0x000000",
> type="Color", format="Color")]
>               public function set color(value:Number)
>               {
>                       if(bReady)
>                       {
>                               tFormat.color=value;
>                               refreshFormat();
>                       }
>               }
>
>               [Inspectable(name="6 - BackGround", defaultValue="false",
> type="Boolean")]
>               public function set background(value:Boolean)
>               {
>                       if(bReady)
>                               tText.background=value;
>               }
>
>               [Inspectable(name="7 - BackGroundColor", 
> defaultValue="0xFFFFFF",
> type="Color", format="Color")]
>               public function set backgroundColor(value:Number)
>               {
>                       if(bReady)
>                               tText.backgroundColor=value;
>               }
>
>               [Inspectable(name="8 - Border", defaultValue="false",
> type="Boolean")]
>               public function set border(value:Boolean)
>               {
>                       if(bReady)
>                               tText.border=value;
>               }
>
>               [Inspectable(name="9 - BorderColor", defaultValue="0xFFFFFF",
> type="Color", format="Color")]
>               public function set borderColor(value:Number)
>               {
>                       if(bReady)
>                               tText.borderColor=value;
>               }
>
>               [Inspectable(name="10 - Largeur fixe", defaultValue="false",
> type="Boolean")]
>               public function set wordwrap(value:Boolean)
>               {
>                       if(bReady)
>                               tText.wordWrap=value;
>               }
>
>               [Inspectable(name="5 - Font", defaultValue="Arial", type="Font
> Name")]
>               public function set font(value:String)
>               {
>                       if(bReady){
>                               if(arrFont.indexOf(value)!=-1)
>                               {
>                                       tFormat.font=value;
>                                       refreshFormat()
>                               }
>                       }
>               }
>
>               [Inspectable(name="4 - Align",
> defaultValue="LEFT",enumeration="LEFT,RIGHT,CENTER,JUSTIFY",
> type="String")]
>               public function set Align(value:String)
>               {
>                       if(bReady)
>                       {
>                               switch(value)
>                               {
>                                       case "LEFT":
>                                               
> tFormat.align=TextFormatAlign.LEFT;
>                                       break;
>                                       case "CENTER":
>                                               
> tFormat.align=TextFormatAlign.CENTER;
>                                       break;
>                                       case "RIGHT":
>                                               
> tFormat.align=TextFormatAlign.RIGHT;
>                                       break;
>                                       case "JUSTIFY":
>                                               
> tFormat.align=TextFormatAlign.JUSTIFY;
>                                       break;
>                               }
>                               refreshFormat();
>                       }
>               }
>       }
> }
>
>
> Merci de vos lumière,
> >


--~--~---------~--~----~------------~-------~--~----~
Vous avez reçu ce message, car vous êtes abonné au groupe Groupe "FCNG" de 
Google Groupes.
 Pour transmettre des messages à ce groupe, envoyez un e-mail à 
l'adresse [email protected]
 Pour résilier votre abonnement à ce groupe, envoyez un e-mail à 
l'adresse [email protected]
 Pour afficher d'autres options, visitez ce groupe à l'adresse 
http://groups.google.com/group/FCNG?hl=fr
-~----------~----~----~----~------~----~------~--~---

Répondre à