views:

127

answers:

3

hi, this is a part of my code

        [Embed(source='dmr/images/icones/icnPresenceInline.png')];
        [Bindable]
        private var presentAuBureau:Class;

        [Embed(source="dmr/images/icones/icnVacancesInline.png")];
        [Bindable]
        private var enCongeAujourdhui:Class;

        override public function set data (value:Object):void {
            super.data = value
            if(data.onLeaveToday == true) {
                etat.source = new presentAuBureau();
                etat.toolTip = "Présent au bureau";
            }
            if(data.presence == '1') {
                etat.source = new enCongeAujourdhui();
                etat.toolTip = "En congé aujourd'hui";
            }
        }

It doesn't compile .. trouble with "meta data requires an associated definition. I can't find what's missing ... all examples i've googled are somehow the same code.

Any hint please ??

TIA

A: 

Try Project>Clean from the main menu.

Make sure the path dmr/images/icones/icnVacancesInline.png is correct.

Test with other images see if they cause the same problem.

John Isaacks
I've done the project>clean part.And yes I'm sure about the path of the image.Actually, it compiles if i force to compile despite errors and images are there. So I guess i'm only missing a not that important definition. But i still wonder which one !
Kangt_qc
+1  A: 

Remove the ; after the [Embed] meta data tags:

[Embed(source='dmr/images/icones/icnPresenceInline.png')]
[Bindable]
private var presentAuBureau:Class;

[Embed(source="dmr/images/icones/icnVacancesInline.png")]
[Bindable]
private var enCongeAujourdhui:Class;

The [ ] meta data tags are descriptors that describe the following object. In this case the private variables. So they belong together and as such are not separated by a semicolon.

Also you should cast your objects to the correct types when using them. This doesn't matter in your explicit case (as you assign the objects to a generic Object), but it might become a problem later:

etat.source = new presentAuBureau() as BitmapAsset;
poke
Hey thank you !It works ... sometimes it's obvious and i miss it !
Kangt_qc
@Kangt_qc, since this answer solved your problem you should mark it as correct (click the checkmark).
Sam
Casting is not necessary in this case since it's just being assigned to the `source` property which is typed as `Object`.
Sam
+1 I didn't even catch that when I was looking at it!
John Isaacks
@Sam That's what I wrote.
poke
@poke, As I read it you left it very ambiguous. You said you should cast, then said it doesn't matter in this case, and then went ahead and casted anyways. You muddied up an otherwise correct answer with incorrect extra information. Besides, the unnecessary cast could actually break it. Think about a situation where the embed is changed, it's no longer a BitmapAsset, but it's something else source would understand. In that case the code without cast would work, but code with the cast would not (it would get assigned null when the cast fails).
Sam
A: 

Hi there!

  1. sometimes flex is crazy about paths try first to use [Embed(source='/dmr/images/icones/icnPresenceInline.png')] with / at the beginning of the relative path
  2. The error is at the end of the Bindable line. There should be no ";"
  3. Do not use etat.source = new presentAuBureau();

    Instead use etat.source = presentAuBureau;

Adrian Pirvulescu
Well thanks guys !It's been corrected and it works like a charm !
Kangt_qc