Adobe Dreamweaver Forums



Last 10 THreads :         CLOB datatype in flex (Last Post : run,ryan! - Replies : 4 - Views : 5 )           »          Problem initialising quicktime (Last Post : Sean Wilson - Replies : 1 - Views : 2 )           »          Library documents do not accept SWF objects (Last Post : micdim1 - Replies : 1 - Views : 2 )           »          image looks different in different browsers? (Last Post : patrickpmm - Replies : 4 - Views : 5 )           »          Can't get drop down menu to drop down (Last Post : danoj22 - Replies : 5 - Views : 6 )           »          Need advice on flash efects (Last Post : Sibee_007 - Replies : 0 - Views : 1 )           »          Table cell - text formatting question (Last Post : JRStaf4ord - Replies : 6 - Views : 7 )           »          Adobe Flash 10 kills Wimpy (Last Post : midiwriter - Replies : 106 - Views : 107 )           »          Em Dash (Last Post : David Stiller - Replies : 1 - Views : 2 )           »          button event with transparency (Last Post : Kruc3fix - Replies : 0 - Views : 1 )           »         

test


Color & Font Picker
CSS Validator
CSS Generator
CSS Generator (Advanced)
Drop Down Menu Maker
HTML Validator
Keyword Density Analyzer
Popup Maker
Mouseover Maker
Link Checker
Link Popularity
Meta Tag Creator
Meta Tag Viewer
Table Maker
Table Maker (Advanced)
Link Extractor
HTTP Headers
HTML Optimizer
HTML Encrypter
htaccess URL Rewrite
Spider View
Webpage Analyzer
C Class Checker
Crontab Entry Generator
Domain Name Checker
Dreamweaver Code Cleaner
Frontpage Code Cleaner
Determine Country From IP
Spam List Check
Websafe Color Tool
Whois Lookup
Alexa Rank Comparison
Code To Text Ratio
Advertising ROI Calculator
Email Encrypter
Google Dance Tool
Gradient Image Maker
.htaccess Ban Generator
.htaccess Password Generator
Screen Resolution Tool
Text Diff Tool
Advanced Text Diff Tool
Google banned
Google datacenter search
Index checker
Keyword Suggestion Tool
Link popularity
Ranking tool
Search engine position
Url redirect checker
Visual pagerank
Browser details
Alexa Traffic Rank
Broken link checker
Domain lookup
IP Location
Reverse IP/Look-up
Server status
Website speed test
Link Extractor
Competition Research Tool
Advanced Meta Tag Generator
Robots.txt Syntax Checker
Robots.txt Generator
Broken Link Checker
Color Converter
HTML Converter
Page Rank Predictor
Image Optimizer
Favicon Generator

User Info Statistics
Go Back   Adobe Dreamweaver Forums > Macromedia Software > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 11-04-2008, 09:02 AM
Handycam
 
Posts: n/a
Diggs:
Default Help cancelling an event

I have a component, mentioned in another post (attached here as well), which is
canvas component with a two image components in it: one is the "object"
itself, and the other is a "close" button.

The object has a click handler which brings it to the front of the display
list. The close button has a click handler which removes the whole object from
the parent container's display list. Both of these handlers work fine; the
problem is the debugger is throwing an error because a click on the close
button is apparently trying to bring IT to the front:

TypeError: Error #1009: Cannot access a property or method of a null object
reference.
at
com.taunton.games::GameItem/clickedMe()[/Users/Shared/WORK/CraftStylish/Ultimate
Sewing Room/flex/src/com/taunton/games/GameItem.mxml:50]

"clickedMe" is the handler that's assigned to the main object, it doesn't make
sense on the close button, hence the error. How can I prevent this?

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()"
minWidth="200" minHeight="200" creationPolicy="all">
<mx:Script>
<![CDATA[

private function init():void {
itemImage.source = filePath;
this.addEventListener(MouseEvent.MOUSE_DOWN, dragMe);
this.addEventListener(MouseEvent.MOUSE_UP, dropMe);
this.addEventListener(MouseEvent.CLICK, clickedMe);
this.addEventListener(MouseEvent.MOUSE_OVER, showClose);
this.addEventListener(MouseEvent.MOUSE_OUT, hideClose);
closeBtn.addEventListener(MouseEvent.ROLL_OVER, enableClose);
closeBtn.addEventListener(MouseEvent.MOUSE_OUT, disableClose);

}

private function clickedMe(e:MouseEvent):void {
parent.setChildIndex(this, parent.numChildren-1);
clickSound.play();
}

private function deleteMe(e:MouseEvent):void {
Application.application.furniture.removeChild(e.cu rrentTarget.parent)
deleteSound.play();
}

private function showClose(event:MouseEvent):void {
closeBtn.visible = true;
this.setStyle("borderSize", 3);
}

private function hideClose(event:MouseEvent):void {
closeBtn.visible = false;

}

private function enableClose(e:MouseEvent):void {
closeBtn.addEventListener(MouseEvent.CLICK, deleteMe);
}

private function disableClose(e:MouseEvent):void {
closeBtn.removeEventListener(MouseEvent.CLICK, deleteMe);
}

]]>
</mx:Script>


<mx:Image id="itemImage" />
<mx:Image id="closeBtn" source="@Embed('assets/close.png')" visible="false"
/>

</mx:Canvas>



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-04-2008, 09:02 AM
_funkyboy
 
Posts: n/a
Diggs:
Default Re: Help cancelling an event

You should check what is null via debugging.
Looking at the code a good candidate can be "closeBtn".

Hope this helps,

-c.
Reply With Quote
  #3 (permalink)  
Old 11-04-2008, 09:02 AM
Handycam
 
Posts: n/a
Diggs:
Default Re: Help cancelling an event

Well, it's the line

parent.setChildIndex(this, parent.numChildren-1);

In both cases, "parent" i supposed to be the container that holds this object,
the master container in the app.

However, the close btn is ALSO calling this and these items are null for it --
but ok for ITS parent.

Reply With Quote


  #4 (permalink)  
Old 11-04-2008, 09:02 AM
Amy Blankenship
 
Posts: n/a
Diggs:
Default Re: Help cancelling an event


"Handycam" <webforumsuser@macromedia.com> wrote in message
news:ge7j8a$su4$1@forums.macromedia.com...
> Well, it's the line
>
> parent.setChildIndex(this, parent.numChildren-1);
>
> In both cases, "parent" i supposed to be the container that holds this
> object,
> the master container in the app.
>
> However, the close btn is ALSO calling this and these items are null for
> it --
> but ok for ITS parent.


Try looking at these:
http://www.adobe.com/devnet/flex/art..._coupling.html
http://www.adobe.com/devnet/flex/art...ating_pt1.html


Reply With Quote
  #5 (permalink)  
Old 11-04-2008, 09:02 AM
mhartnett
 
Posts: n/a
Diggs:
Default Re: Help cancelling an event

I am not quite sure of all the logic but it seems as though you need to
identify if the close image has been clicked.

Put a mouseChildren="false" on the close button image and in the clickMe you
can check the event.target to see if it is the image that was clicked. If it
is the image then skip all processing except for cleanup and closing the window.

if(e.target.id == "closeBtn")
close the window
else {
parent.setChildIndex(this, parent.numChildren-1);
clickSound.play();
}

Not having the mouseChildren will not pass the image as the target, I think it
will pass the canvas. Don't check the currentTarget.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 10:11 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk