TK1979
02-12-2009, 04:13 PM
Hi everyone,
Name is TK, new to the forum, new to AS3 and Flex. So far I'm playing around with the trial version building some test apps. Anyway, I'm building a little slideshow in a title window and I ran into a problem getting the code right for the close button:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" backgroundColor="white"
backgroundGradientColors="[0xFFFFFF,0xFFFFFF]" width="211" height="212">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.managers.PopUpManager;
import mx.events.*
[Bindable]
private var currentImage:int = 0;
[Bindable]
public var images:ArrayCollection = new ArrayCollection(["eatz.jpg", "eatz-02.jpg", "eatz-03.jpg", "eatz-04.jpg", "eatz-05.jpg",
"eatz-06.jpg", "eatz-07.jpg", "eatz-08.jpg", "eatz-09.jpg"]);
private function NextImg( Mouse:Event ) : void {
currentImage ++;
if ( currentImage >= images.length )
currentImage = 0;
}
private function PrevImg( Mouse:Event ) : void {
currentImage --;
if ( currentImage <= 0)
currentImage = images.length;
}
private function removeWindow(event:CloseEvent):void {
PopUpManager.removePopUp(this);
}
]]>
</mx:Script>
<mx:TitleWindow id="window" width="211" height="212"
backgroundAlpha="0.8" backgroundColor="0xffffff" borderAlpha="1" borderColor="0x7ACCC8" layout="absolute" title="DISH NAME" showCloseButton="true" close="removeWindow(event)" >
<mx:Image width="100" height="100" id="flickImg"
source="images2/{images.getItemAt(currentImage)}" x="56.5" y="10"/>
<mx:ControlBar>
<mx:Button label="BACK" click="PrevImg(event)" />
<mx:Button label="NEXT" click="NextImg(event)"/>
</mx:ControlBar>
</mx:TitleWindow>
</mx:Application>
Everytime I click on close button when running the app i get this error alert in my browser:
TypeError: Error #1009: Cannot access a property or method of a null object reference. (with a bunch of other stuff under).
When I read the reference documents and the examples in the help it seems they simply put the removePopUp directly in close="" but that gives me the same problem.
What am I doing wrong?
Name is TK, new to the forum, new to AS3 and Flex. So far I'm playing around with the trial version building some test apps. Anyway, I'm building a little slideshow in a title window and I ran into a problem getting the code right for the close button:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" backgroundColor="white"
backgroundGradientColors="[0xFFFFFF,0xFFFFFF]" width="211" height="212">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.managers.PopUpManager;
import mx.events.*
[Bindable]
private var currentImage:int = 0;
[Bindable]
public var images:ArrayCollection = new ArrayCollection(["eatz.jpg", "eatz-02.jpg", "eatz-03.jpg", "eatz-04.jpg", "eatz-05.jpg",
"eatz-06.jpg", "eatz-07.jpg", "eatz-08.jpg", "eatz-09.jpg"]);
private function NextImg( Mouse:Event ) : void {
currentImage ++;
if ( currentImage >= images.length )
currentImage = 0;
}
private function PrevImg( Mouse:Event ) : void {
currentImage --;
if ( currentImage <= 0)
currentImage = images.length;
}
private function removeWindow(event:CloseEvent):void {
PopUpManager.removePopUp(this);
}
]]>
</mx:Script>
<mx:TitleWindow id="window" width="211" height="212"
backgroundAlpha="0.8" backgroundColor="0xffffff" borderAlpha="1" borderColor="0x7ACCC8" layout="absolute" title="DISH NAME" showCloseButton="true" close="removeWindow(event)" >
<mx:Image width="100" height="100" id="flickImg"
source="images2/{images.getItemAt(currentImage)}" x="56.5" y="10"/>
<mx:ControlBar>
<mx:Button label="BACK" click="PrevImg(event)" />
<mx:Button label="NEXT" click="NextImg(event)"/>
</mx:ControlBar>
</mx:TitleWindow>
</mx:Application>
Everytime I click on close button when running the app i get this error alert in my browser:
TypeError: Error #1009: Cannot access a property or method of a null object reference. (with a bunch of other stuff under).
When I read the reference documents and the examples in the help it seems they simply put the removePopUp directly in close="" but that gives me the same problem.
What am I doing wrong?