Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 321
  • Last Modified:

issue with viewstack

Hi experts,

i have viewstack., i wan to perform something when view is changed,  because the view is not instantiated at the time i click the button  i have to listen for the creation complete event but still i am getting error

TypeError: Error #2007: Parameter listener must be non-null.
at flash.events::EventDispatcher/addEventListener()



//code- part of function called on button click to change the view
		
	viestack.selectedChild = view2;
	viestack.addEventListner(IndexChangedEvent.CHANGE, vchange);
	
                     function vchange():void{
	view2.addEventListner(FlexEvent.CREATION_COMPLETE, startn);
	viestack.removeEventListner(IndexChangedEvent.CHANGE, vchange);
	}
	function startn():void{
	trace("inst view stack here")
	view2.removeEventListner(FlexEvent.CREATION_COMPLETE, startn);
	}

Open in new window

0
rakesh16d
Asked:
rakesh16d
  • 4
  • 3
1 Solution
 
Jones911Commented:
function startn(changeEvent:FlexEvent):void{

Try that
0
 
rakesh16dAuthor Commented:
thanks for reply.. i have tried startn(changeEvent:FlexEvent):void
also, vchange(event:IndexChangedEvent)

i tried debugging but its not getting into the function vchange(),  that is the place where it is breaking.


0
 
Jones911Commented:
This this event is never occuring: IndexChangedEvent.CHANGE
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
rakesh16dAuthor Commented:
more code..
function changeviewnoe():void{
 switch(e.cuttenttarget.id){
 case"button2":
      viestack.selectedChild = view2;
      viestack.addEventListner(IndexChangedEvent.CHANGE, vchange);
      
      function vchange():void{
	view2.addEventListner(FlexEvent.CREATION_COMPLETE, startn);
	viestack.removeEventListner(IndexChangedEvent.CHANGE, change);
      }
      function startn():void{
         trace("inst view stack here")
	view2.removeEventListner(FlexEvent.CREATION_COMPLETE, startn);
      }
 
}
}

Open in new window

0
 
rakesh16dAuthor Commented:
solved myself
0
 
Jones911Commented:
How?  You shoudl post the solution and give yourself the points.
0
 
rakesh16dAuthor Commented:
i was suppose to dispatch custom event on creation on that view. so on creation complete of that view i added the code for dispatching event, which happens only for the first time when view is created.. after that since view is there, no null reference error will come so i had a code to dispatch the same event when user select the same view again,, which happens in switch statement. there should be some efficient way to do it but for now it works for me :)
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now