So let’s look at what happens. Notice the warning message that appears down below, it says data binding will not be able to detect assignments to prop one. So imagine if this was dynamic data, actually coming from a database and this data would change. This say was a stock code or some type of data would change. It would mean that the control would not be reflected.
The reason for this is because we did not mark this property as actual bindable. We used what’s called a Meta tagged market as bindable. So lets go ahead and examine process and get that error message because if this property changes, we wanted to be updated within our application.
So what I would like you to do is go back to your PropMethod.mxml file. Notice the warning is displayed right here and again that warning is displayed again when you roll over the little warning message. And the reason for this is when we declare this property; we did not specify it as bindable. So to add in this bindable Meta tag, you just use and open brace like this, type in the word bindable and close that brace. So now, this is actually specified as bindable which means all of the great and cool things about data binding will be reflected in this property. So for example, if the data ever changes, it will immediately reflect it in our component.
So again, when we build much more complicated apps, so using this data from a database this is incredibly valuable. So save, once we save this you should see that warning message goes away because we have marked it actually as bindable, okay. And let’s just look at one other thing quickly. Watch what happens if I change this to private. Specifying this as private can be very useful because it means this property can only be used within this component. And that provides a level of security and data integrity that no other component can actually access this data.
However, in our case, this is a bad thing, right, because we are referencing this property from outside of this component. And what I would now like you to do is switch back to Fundamentals_wt5.mxml by clicking on the tab. And I would like you to run the application. So click here under run_fundamentals_wt5 and notice here is our first runtime error. Again, that didn't happen at compile time. But this is a runtime error in the Adobe Flash Player 9 and this is actually my favorite functionality as this gives us all the errors that Flash or the old version of Flex never used to show us.
So this runtime error says exactly what the problem is and it says, Cannot create property Prop1 on components.PropMethod. The reason for that is we marked this as private. When you mark a property or a variable as private, it cannot create that variable because it only be accessed from within that particular component.
So notice the runtime error and our application doesn't work. So close your browser and switch back to PropMethod.mxml and declare this as public instead of private like you see there. So there I have declared this as public. Go ahead and save this and you should see that it works fine and we don't have that error anymore as well.
Let’s confirm that, that is in fact the case. So go back to your Fundamentals_wt5.mxml and click on the Run button and you should see that the value you passed that component appears. And when you close the browser, notice there are no error messages because you have marked that as bindable.
Transcription by:
Scribe4you Transcription Services