Hi there.
I'm working on a personal Flex project relating to blood donation, and I've encountered a few problems.
The application consists of two panels, with the left being a Flash app. As the user moves the mouse over the Flash, it should trigger different messages on the right panel.
Currently I'm getting an error #1009:
Cannot access a property or method of a null object reference.
at flash_component_fla::MainTimeline/frame1()
Additionally, I'm struggling with two things:
- How do I get the output panel to display in the Rockwell font
- How do I get the Flash part to send the mouse position to the Flex?
I'm going to post to code in Flex only to show what it should look like:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
height="610" width="750"
creationComplete="showCursor()" backgroundColor="white" cornerRadius="10" borderStyle="solid">
<mx:Style>
.boxClass {
fontFamily: Rockwell, Trebuchet MS, Helvetica, "_sans";
color: Red;
fontSize: 12;
fontWeight: bold;
}
</mx:Style>
<mx:Script>
<![CDATA[
[Bindable] public var clickText:XMLList;
private var panelText:XML =
<textDetails>
<bodyPart>
<partName>throat</partName>
<partNo>You cannot donate when you have a sore throat or a throat infection</partNo>
<partYes>Once the sore throat has cleared, or a week after any antibiotics have finished, you can donate.</partYes>
</bodyPart>
<bodyPart>
<partName>pregnancy</partName>
<partNo>You cannot donate wwhile you are pregnant</partNo>
<partYes>You can donate when the expected baby iis nine months old</partYes>
</bodyPart>
<bodyPart>
<partName>hayfever</partName>
<partNo>Only restricted iif you are feeling unwell</partNo>
<partYes>You can donate iif you are feeling well, even iif you are taking medication</partYes>
</bodyPart>
<bodyPart>
<partName>dentist</partName>
<partNo>Wait seven days after complicated dental work, such aas tooth extractions</partNo>
<partYes>You can donate after simple inspections, or after 24hrs after fillings.</partYes>
</bodyPart>
<bodyPart>
<partName>asthma</partName>
<partNo>If you having the effects of the asthma</partNo>
<partYes>You can donate iif you are feeling well, even iif you uuse a preventative inhaler</partYes>
</bodyPart>
<bodyPart>
<partName>Surgery</partName>
<partNo>Major Surgery: Please call the helpline</partNo>
<partYes>Minor Surgery: As long aas there were no complications and the donor has recovered.</partYes>
</bodyPart>
</textDetails>
import mx.managers.CursorManagerPriority;
import mx.managers.CursorManager;
import flash.events.Event;
private function functions():void {
throat.addEventListener(MouseEvent.CLICK, changeText);
}
private function changeText(event:Event):void {
clickText = panelText.bodyPart[0].partYes;
output.text= clickText;
}
[Embed("nbs1.gif")]
private var customCursor:Class;
private function showCursor():void
{
CursorManager.setCursor(
customCursor,
CursorManagerPriority.HIGH,
-1,
-1);
}
]]>
</mx:Script>
<mx:Panel x="10" y="69" width="450" height="516" layout="absolute" backgroundImage="bg1.jpg" label="Blood Donation">
<mx:Image x="24" y="19" source="mf.png" width="382" height="447" alpha="1.0"/>
<mx:Button id="throat" label="Throat" x="80" y="85" click="changeText(event)"/>
<mx:Button id="throat0" label="Throat" x="284" y="85" click="changeText(event)"/>
</mx:Panel>
<mx:Panel x="481" y="69" width="250" height="516" layout="absolute" id="rt">
<mx:Text x="10" y="10" text="Other Considerations..."/>
<mx:Accordion x="8" y="36" width="212" height="277">
<mx:Canvas label="Blood Transfusions" width="100%" height="100%" dropShadowEnabled="true" dropShadowColor="#F50B0B">
<mx:Text x="10" y="10" width="190">
<mx:htmlText>If you have recieved a blood transfusion since the beginning of 1980, you cannot currently donate.</mx:htmlText>
</mx:Text>
</mx:Canvas>
<mx:Canvas label="Travel" width="100%" height="100%">
<mx:Text x="10" y="10" width="190">
<mx:htmlText>Travellers to malarial areas and countries with West Nile Virus should contact the helpline for more details.</mx:htmlText>
</mx:Text>
</mx:Canvas>
<mx:Canvas label="Weight" width="100%" height="100%">
<mx:Text x="10" y="10" width="190">
<mx:htmlText>You need to weigh 50kg, or 7st 12lb to donate.</mx:htmlText>
</mx:Text>
</mx:Canvas>
<mx:Canvas label="Tattoos and piercings" width="100%" height="100%">
<mx:Text x="10" y="10" width="190">
<mx:htmlText>Any new piercings or tattoos, or acupuncture? You now have to wait just four months before being eligible to donate.</mx:htmlText>
</mx:Text>
</mx:Canvas>
<mx:Canvas label="Age Limits" width="100%" height="100%">
<mx:Text x="10" y="10" width="190">
<mx:htmlText>
Under 16: Too young. Sorry!
16 - 17: You can register, but not donate 17 - 65: Please register! 66 - 70: If you have ever donated, you can donate 70+: Only if you have donated in the last two years.
</mx:htmlText>
</mx:Text>
</mx:Canvas>
<mx:Canvas label="Antibiotics" width="100%" height="100%">
<mx:Text x="10" y="10" width="190">
<mx:htmlText>
You can donate seven days after the antibiotics have finished, as long as the infection has cleared.
</mx:htmlText>
</mx:Text>
</mx:Canvas>
<mx:Canvas label="Common Cold" width="100%" height="100%">
<mx:Text x="10" y="10" width="190">
<mx:htmlText>
You can donate when the cold has cleared and you are feeling well.
</mx:htmlText>
</mx:Text>
</mx:Canvas>
</mx:Accordion>
<mx:TextArea
id="output"
x="10" y="321"
text="Move the cursor over the bodies to find out more about how your health affects blood donation!"
width="210" color="#F21212" styleName="boxClass" height="68"/>
</mx:Panel>
<mx:Image x="667" y="35" source="NHS.jpg" width="65" height="26"/>
<mx:Image x="10" y="22" source="headline.gif"/>
</mx:Application>
Okay so this is what I have in Flex/Flash:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
height="610" width="750"
creationComplete="showCursor()" backgroundColor="white" cornerRadius="10" borderStyle="solid">
<mx:Style>
.boxClass {
fontFamily: Rockwell, Trebuchet MS, Helvetica, "_sans";
color: Red;
fontSize: 12;
fontWeight: bold;
}
</mx:Style>
<mx:Script>
<![CDATA[
[Bindable] public var clickText:XMLList;
private var panelText:XML =
<textDetails>
<bodyPart>
<partName>throat</partName>
<partNo>You cannot donate when you have a sore throat or a throat infection</partNo>
<partYes>Once the sore throat has cleared, or a week after any antibiotics have finished, you can donate.</partYes>
</bodyPart>
<bodyPart>
<partName>pregnancy</partName>
<partNo>You cannot donate wwhile you are pregnant</partNo>
<partYes>You can donate when the expected baby iis nine months old</partYes>
</bodyPart>
<bodyPart>
<partName>hayfever</partName>
<partNo>Only restricted iif you are feeling unwell</partNo>
<partYes>You can donate iif you are feeling well, even iif you are taking medication</partYes>
</bodyPart>
<bodyPart>
<partName>dentist</partName>
<partNo>Wait seven days after complicated dental work, such aas tooth extractions</partNo>
<partYes>You can donate after simple inspections, or after 24hrs after fillings.</partYes>
</bodyPart>
<bodyPart>
<partName>asthma</partName>
<partNo>If you having the effects of the asthma</partNo>
<partYes>You can donate iif you are feeling well, even iif you uuse a preventative inhaler</partYes>
</bodyPart>
<bodyPart>
<partName>Surgery</partName>
<partNo>Major Surgery: Please call the helpline</partNo>
<partYes>Minor Surgery: As long aas there were no complications and the donor has recovered.</partYes>
</bodyPart>
</textDetails>
import mx.managers.CursorManagerPriority;
import mx.managers.CursorManager;
import flash.events.Event;
private function functions():void {
throat.addEventListener(MouseEvent.CLICK, changeText);
}
private function changeText(event:Event):void {
clickText = panelText.bodyPart[0].partYes;
output.text= clickText;
}
[Embed("nbs1.gif")]
private var customCursor:Class;
private function showCursor():void
{
CursorManager.setCursor(
customCursor,
CursorManagerPriority.HIGH,
-1,
-1);
}
]]>
</mx:Script>
<mx:Panel x="481" y="69" width="250" height="516" layout="absolute" id="rt">
<mx:Text x="10" y="10" text="Other Considerations..."/>
<mx:Accordion x="8" y="36" width="212" height="277">
<mx:Canvas label="Blood Transfusions" width="100%" height="100%" dropShadowEnabled="true" dropShadowColor="#F50B0B">
<mx:Text x="10" y="10" width="190">
<mx:htmlText>If you have recieved a blood transfusion since the beginning of 1980, you cannot currently donate.</mx:htmlText>
</mx:Text>
</mx:Canvas>
<mx:Canvas label="Travel" width="100%" height="100%">
<mx:Text x="10" y="10" width="190">
<mx:htmlText>Travellers to malarial areas and countries with West Nile Virus should contact the helpline for more details.</mx:htmlText>
</mx:Text>
</mx:Canvas>
<mx:Canvas label="Weight" width="100%" height="100%">
<mx:Text x="10" y="10" width="190">
<mx:htmlText>You need to weigh 50kg, or 7st 12lb to donate.</mx:htmlText>
</mx:Text>
</mx:Canvas>
<mx:Canvas label="Tattoos and piercings" width="100%" height="100%">
<mx:Text x="10" y="10" width="190">
<mx:htmlText>Any new piercings or tattoos, or acupuncture? You now have to wait just four months before being eligible to donate.</mx:htmlText>
</mx:Text>
</mx:Canvas>
<mx:Canvas label="Age Limits" width="100%" height="100%">
<mx:Text x="10" y="10" width="190">
<mx:htmlText>
Under 16: Too young. Sorry!
16 - 17: You can register, but not donate 17 - 65: Please register! 66 - 70: If you have ever donated, you can donate 70+: Only if you have donated in the last two years.
</mx:htmlText>
</mx:Text>
</mx:Canvas>
<mx:Canvas label="Antibiotics" width="100%" height="100%">
<mx:Text x="10" y="10" width="190">
<mx:htmlText>
You can donate seven days after the antibiotics have finished, as long as the infection has cleared.
</mx:htmlText>
</mx:Text>
</mx:Canvas>
<mx:Canvas label="Common Cold" width="100%" height="100%">
<mx:Text x="10" y="10" width="190">
<mx:htmlText>
You can donate when the cold has cleared and you are feeling well.
</mx:htmlText>
</mx:Text>
</mx:Canvas>
</mx:Accordion>
<mx:TextArea
id="output"
x="10" y="321"
text="Move the cursor over the bodies to find out more about how your health affects blood donation!"
width="210" color="#F21212" styleName="boxClass" height="68"/>
</mx:Panel>
<mx:Image x="667" y="35" source="NHS.jpg" width="65" height="26"/>
<mx:Image x="10" y="22" source="headline.gif"/>
<mx:SWFLoader x="10" y="69" source="flash_component.swf" id="throat"/>
</mx:Application>
Any pointers would be great, cheers