I’ve embedded an image in my Flex mxml file (script section) using:
<fx:Script>
<![CDATA[
import com.views.myTitleWindowFile;
...
[Embed(source="com/assets/image_error.png")]
public static const IMG_ERROR:Class;
...
and it works fine. Now I want to use the same image in an mxml file named myTitleWindowFile (for a spark TitleWindow component), which was imported as shown above. The myTitleWindowFile.mxml gives an error on this line:
Alert.show("Please enter a value.", "Error",Alert.OK,null,null,IMG_ERROR);
The error states: 1120: Access of undefined property IMG_ERROR. Any idea what I’m doing wrong? Thanks in advance for any comments.
Your
myTitleWindowFileshouldn’t be accessing any resource in its parent. It can easily lead to a situation where you want to reuse thatmyTitleWindowFilein another area of your application that doesn’t haveIMG_ERRORdefined.I would just declare
IMG_ERRORinmyTitleWindowFileand access it locally. It keeps your code cleaner and more portable.