RE: [Flashcoders] Custom eventListener

2008-12-19 Thread Lehr, Ross (N-SGIS)
Ok. I think I got it thanks.  

-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com 
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason
Sent: Friday, December 19, 2008 10:01 AM
To: Flash Coders List
Subject: RE: [Flashcoders] Custom eventListener

Ross,

The addEventListener would be on the instance of your "different class than the 
HTMLLoader".

myOtheraClass.addEventListener(MyCustomEventClass.MYCUSTOMEVENT, 
onMyCustomEvent)

Make sense?


Jason Merrill
Bank of America Instructional Technology & Media   ·   GCIB & Staff Support 
L&LD

Interested in Flash Platform technologies?  Join the Bank of America Flash 
Platform Developer Community 
Interested in innovative ideas in Learning?  Check out the Innovative Learning 
Blog and subscribe.






-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com 
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Lehr, Ross 
(N-SGIS)
Sent: Friday, December 19, 2008 9:04 AM
To: Flash Coders List
Subject: RE: [Flashcoders] Custom eventListener

Thanks Jason... Let me ask one question to try to clarify this for me.  If I 
have the dispatchEvent that broadcasts the URL of my HTLMLoader in a 
onLoadComplete function and I want to listen for that event in a different 
class (for example I want to put the URL in a textbox that is created in a 
different class than the HTMLLoader) where would I put the addEventListener?  
I'm not sure why my head is not wrapping around this, but thanks for all your 
help.

Ross

-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com 
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason
Sent: Thursday, December 18, 2008 5:20 PM
To: Flash Coders List
Subject: RE: [Flashcoders] Custom eventListener

To add on to David's fine reply, Ross, you're close, but not quite - this is 
how I write custom events, I think you'll want to do something like this 
instead - this works great for me:

To write the event:

package events
{
import flash.events.Event;

public class MyEvent extends Event
{
public static var MYEVENT1:String = "myEvent1";  
public static var MYEVENT2:String = "myEvent2";

public function MyEvent(type:String, bubbles:Boolean = false, 
cancellable:Boolean = false ) 
{
super(type, bubbles, cancelable);
}

}

}

Then to dispatch:

import events.MyEvent;

dispatchEvent(new MyEvent(MyEvent.MYEVENT2, false, true));


Then to listen and react to dispatch:

myObject.addEventListener(MyEvent.MYEVENT2, onMyEvent2)

public function onMyEvent2(event:MyEvent):void
{
Trace("myEvent2 heard!");
}


Jason Merrill
Bank of America Instructional Technology & Media   ·   GCIB & Staff Support 
L&LD

Interested in Flash Platform technologies?  Join the Bank of America Flash 
Platform Developer Community 
Interested in innovative ideas in Learning?  Check out the Innovative Learning 
Blog and subscribe.





-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com 
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of David 
Hershberger
Sent: Thursday, December 18, 2008 4:58 PM
To: Flash Coders List
Subject: Re: [Flashcoders] Custom eventListener

An event is just a message object.  Just because one gets created
successfully does not mean it is being delivered.  dispatchEvent() is a
method of the EventDispatcher class, which is a superclass of many classes,
including DisplayObject.  You need to listen for the event (with
addEventListener()) on the same EventDispatcher where the event was
dispatched. (Except in the case of events that bubble, but that's another
topic.)

For example:

public class MyWindowHolder extends Sprite {
  public function init(): void {
var a: MyWindow = new MyWindow();
a.addEventListener( MyEvent.EXCLAMATION, onExclamation );
  }

  private function onExclamation( event: MyEvent ): void {
trace("ouch!");
  }
}

public class MyWindow extends Sprite {
  private function injury(): void {
this.dispatchEvent( new MyEvent( MyEvent.EXCLAMATION ));
  }
}

Hope this helps,
Dave

On 12/18/08, Lehr, Ross (N-SGIS)  wrote:
>
> Hey All...
>
>  I'm having trouble with a custom event listener.  I'm working on
> experiment browser project trying to learn as3, OOP, and AIR.  I
> broadcasting the URL after a web page is loaded and I need a text box to
> listen for it.  I've added a trace to me urlLoadedEvent class and I know
> the URL is getting there (so, I think it's getting broadcasted ok), but
> it's not getting to the text box.  I think I have my listener in the
> wrong place, but not sure where to put it.  I don't have my exact code
> here, but below are some code snippets.  Thanks for any and all help.
>
> Ross
>
>
>
> -- DISPACTING  EVEN
>
> In a loadComplete function urlLocat

Re: [Flashcoders] conversion avi to flv

2008-12-19 Thread Meinte van't Kruis
actually, you can encode to on2 with ffmpeg, it takes a bit of tweaking, but
it does work(with the help of some other programs), here's the link(actually
not sure it's legal, it depends on the on2 codec which used to be
distributed):

http://sh0dan.blogspot.com/2006/09/command-line-flash-8-flv-encoding.html

On Fri, Dec 19, 2008 at 7:45 AM, Latcho  wrote:

> Mind the gap:
>
> ffmpeg will not encode the better video codec on2VP6 but only the old
> Sorenson Spark.
> With flash player  > v9.1 you can load mp4's which you can batch with
> ffmpeg serverside.
> For settings and batch examples check my post "Re: [Flash_Tiger] Fast FLV
> encoding, ease of use" from 07-dec-'08 18:06 on the emailing list
> Flash_tiger @ yahoogroups.com
>
> Latcho
>
>
>
> Ian Thomas wrote:
>
>> ffmpeg
>>
>> http://ffmpeg.mplayerhq.hu/
>>
>> HTH,
>>   Ian
>>
>> On Thu, Dec 18, 2008 at 3:37 AM, 2lakes <2la...@ianhobbs.net> wrote:
>>
>>
>>> Hi, Any quick tips on a Windows .avi to .flv converter app?
>>> Also if any server based app would be appreciated.
>>>
>>> Cheers Ian
>>>
>>> Ian Hobbs Media
>>> ___
>>> Flashcoders mailing list
>>> Flashcoders@chattyfig.figleaf.com
>>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>
>>>
>>>
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>>
>>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>



-- 
M.A. van't Kruis
http://www.malatze.nl/
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Custom eventListener

2008-12-19 Thread John McCormack

Ross,

I'm no expert but I think this is correct:
As long as your object is decended from the EventDispatcher class (all 
display objects) you can attach a listener to it.
Let's say you have a Text field called myObject in another file/class 
then you can specify the event name, as explained, with something like:


myObject.addEventListener(MyEvent.MYEVENT2, onMyEvent2)

public function onMyEvent2(event:MyEvent):void
{
Trace("myEvent2 heard!");
}

I used to have problems specifying what to listen for, i.e. the event's 
name.
The MYEVENT2 above is actually a string but you are supposed to use this 
capitalized version.

The string is defined in the MyEvent class as
public var static const MYEVENT2:String = "SomeNameIdentifier";

Jason's example has "import events.MyEvent;" and so any public static 
variablesin MyEvent.as are visible.
If the MYEVENT2 string is defined as "var public static" in the a class, 
it is visible to other files that import the class.
If it had been defined without the "static" keyword then the variable 
would belong to instances of the class, not the class, and would not be 
visible outside of the file.


I liked Jason's lamp and switch example and would like to know more 
about using it more effectively in design patterns.


John

I hope I am not being a pain about the threads being kept sorted, but 
this information resource you are creating is really precious.


Lehr, Ross (N-SGIS) wrote:

Thanks Jason... Let me ask one question to try to clarify this for me.  If I 
have the dispatchEvent that broadcasts the URL of my HTLMLoader in a 
onLoadComplete function and I want to listen for that event in a different 
class (for example I want to put the URL in a textbox that is created in a 
different class than the HTMLLoader) where would I put the addEventListener?  
I'm not sure why my head is not wrapping around this, but thanks for all your 
help.

Ross

-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com 
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason
Sent: Thursday, December 18, 2008 5:20 PM
To: Flash Coders List
Subject: RE: [Flashcoders] Custom eventListener

To add on to David's fine reply, Ross, you're close, but not quite - this is 
how I write custom events, I think you'll want to do something like this 
instead - this works great for me:

To write the event:

package events
{
import flash.events.Event;

public class MyEvent extends Event
{
		public static var MYEVENT1:String = "myEvent1";  
		public static var MYEVENT2:String = "myEvent2";


		public function MyEvent(type:String, bubbles:Boolean = false, cancellable:Boolean = false ) 
		{

super(type, bubbles, cancelable);
}

}

}

Then to dispatch:

import events.MyEvent;

dispatchEvent(new MyEvent(MyEvent.MYEVENT2, false, true));


Then to listen and react to dispatch:

myObject.addEventListener(MyEvent.MYEVENT2, onMyEvent2)

public function onMyEvent2(event:MyEvent):void
{
Trace("myEvent2 heard!");
}


Jason Merrill
Bank of America Instructional Technology & Media   ·   GCIB & Staff Support 
L&LD

Interested in Flash Platform technologies?  Join the Bank of America Flash Platform Developer Community 
Interested in innovative ideas in Learning?  Check out the Innovative Learning Blog and subscribe.






-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com 
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of David 
Hershberger
Sent: Thursday, December 18, 2008 4:58 PM
To: Flash Coders List
Subject: Re: [Flashcoders] Custom eventListener

An event is just a message object.  Just because one gets created
successfully does not mean it is being delivered.  dispatchEvent() is a
method of the EventDispatcher class, which is a superclass of many classes,
including DisplayObject.  You need to listen for the event (with
addEventListener()) on the same EventDispatcher where the event was
dispatched. (Except in the case of events that bubble, but that's another
topic.)

For example:

public class MyWindowHolder extends Sprite {
  public function init(): void {
var a: MyWindow = new MyWindow();
a.addEventListener( MyEvent.EXCLAMATION, onExclamation );
  }

  private function onExclamation( event: MyEvent ): void {
trace("ouch!");
  }
}

public class MyWindow extends Sprite {
  private function injury(): void {
this.dispatchEvent( new MyEvent( MyEvent.EXCLAMATION ));
  }
}

Hope this helps,
Dave

On 12/18/08, Lehr, Ross (N-SGIS)  wrote:
  

Hey All...

 I'm having trouble with a custom event listener.  I'm working on
experiment browser project trying to learn as3, OOP, and AIR.  I
broadcasting the URL after a web page is loaded and I need a text box to
listen for it.  I've added a trace to me urlLoadedEvent class and I know
the URL is getting there (so, I think it's getting broadcasted ok), but
it'

RE: [Flashcoders] Custom eventListener

2008-12-19 Thread Merrill, Jason
Ross,

The addEventListener would be on the instance of your "different class than the 
HTMLLoader".

myOtheraClass.addEventListener(MyCustomEventClass.MYCUSTOMEVENT, 
onMyCustomEvent)

Make sense?


Jason Merrill
Bank of America Instructional Technology & Media   ·   GCIB & Staff Support 
L&LD

Interested in Flash Platform technologies?  Join the Bank of America Flash 
Platform Developer Community 
Interested in innovative ideas in Learning?  Check out the Innovative Learning 
Blog and subscribe.






-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com 
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Lehr, Ross 
(N-SGIS)
Sent: Friday, December 19, 2008 9:04 AM
To: Flash Coders List
Subject: RE: [Flashcoders] Custom eventListener

Thanks Jason... Let me ask one question to try to clarify this for me.  If I 
have the dispatchEvent that broadcasts the URL of my HTLMLoader in a 
onLoadComplete function and I want to listen for that event in a different 
class (for example I want to put the URL in a textbox that is created in a 
different class than the HTMLLoader) where would I put the addEventListener?  
I'm not sure why my head is not wrapping around this, but thanks for all your 
help.

Ross

-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com 
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason
Sent: Thursday, December 18, 2008 5:20 PM
To: Flash Coders List
Subject: RE: [Flashcoders] Custom eventListener

To add on to David's fine reply, Ross, you're close, but not quite - this is 
how I write custom events, I think you'll want to do something like this 
instead - this works great for me:

To write the event:

package events
{
import flash.events.Event;

public class MyEvent extends Event
{
public static var MYEVENT1:String = "myEvent1";  
public static var MYEVENT2:String = "myEvent2";

public function MyEvent(type:String, bubbles:Boolean = false, 
cancellable:Boolean = false ) 
{
super(type, bubbles, cancelable);
}

}

}

Then to dispatch:

import events.MyEvent;

dispatchEvent(new MyEvent(MyEvent.MYEVENT2, false, true));


Then to listen and react to dispatch:

myObject.addEventListener(MyEvent.MYEVENT2, onMyEvent2)

public function onMyEvent2(event:MyEvent):void
{
Trace("myEvent2 heard!");
}


Jason Merrill
Bank of America Instructional Technology & Media   ·   GCIB & Staff Support 
L&LD

Interested in Flash Platform technologies?  Join the Bank of America Flash 
Platform Developer Community 
Interested in innovative ideas in Learning?  Check out the Innovative Learning 
Blog and subscribe.





-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com 
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of David 
Hershberger
Sent: Thursday, December 18, 2008 4:58 PM
To: Flash Coders List
Subject: Re: [Flashcoders] Custom eventListener

An event is just a message object.  Just because one gets created
successfully does not mean it is being delivered.  dispatchEvent() is a
method of the EventDispatcher class, which is a superclass of many classes,
including DisplayObject.  You need to listen for the event (with
addEventListener()) on the same EventDispatcher where the event was
dispatched. (Except in the case of events that bubble, but that's another
topic.)

For example:

public class MyWindowHolder extends Sprite {
  public function init(): void {
var a: MyWindow = new MyWindow();
a.addEventListener( MyEvent.EXCLAMATION, onExclamation );
  }

  private function onExclamation( event: MyEvent ): void {
trace("ouch!");
  }
}

public class MyWindow extends Sprite {
  private function injury(): void {
this.dispatchEvent( new MyEvent( MyEvent.EXCLAMATION ));
  }
}

Hope this helps,
Dave

On 12/18/08, Lehr, Ross (N-SGIS)  wrote:
>
> Hey All...
>
>  I'm having trouble with a custom event listener.  I'm working on
> experiment browser project trying to learn as3, OOP, and AIR.  I
> broadcasting the URL after a web page is loaded and I need a text box to
> listen for it.  I've added a trace to me urlLoadedEvent class and I know
> the URL is getting there (so, I think it's getting broadcasted ok), but
> it's not getting to the text box.  I think I have my listener in the
> wrong place, but not sure where to put it.  I don't have my exact code
> here, but below are some code snippets.  Thanks for any and all help.
>
> Ross
>
>
>
> -- DISPACTING  EVEN
>
> In a loadComplete function urlLocation = text field for the URL string
>
> dispatchEvent(new urlLoadEvent(urlLocation.text));
>
> -- urlLoadEvent Class (when I trace urlLocation I am getting the URL
> string)
>
> package
> {
> import flash.events.*;
>
> public class urlLoadEvent extends Event
> {
>   

Re: [Flashcoders] Custom eventListener

2008-12-19 Thread John McCormack

Re: [Flashcoders] Custom eventListener thread
is an interesting topic but it has attached itself to the
Re: [Flashcoders] Pixel precise thread

In Mozilla's Thunderbird I sort on topic and so I miss these fascinating 
discussions because the threads are mangled.

Does it mess up the archives when people don't start new threads?

John

Lehr, Ross (N-SGIS) wrote:

Hey All...

 I'm having trouble with a custom event listener.  I'm working on
experiment browser project trying to learn as3, OOP, and AIR.  I
broadcasting the URL after a web page is loaded and I need a text box to
listen for it.  I've added a trace to me urlLoadedEvent class and I know
the URL is getting there (so, I think it's getting broadcasted ok), but
it's not getting to the text box.  I think I have my listener in the
wrong place, but not sure where to put it.  I don't have my exact code
here, but below are some code snippets.  Thanks for any and all help.

Ross



-- DISPACTING  EVEN

In a loadComplete function urlLocation = text field for the URL string

dispatchEvent(new urlLoadEvent(urlLocation.text));

-- urlLoadEvent Class (when I trace urlLocation I am getting the URL
string)

package
{
import flash.events.*;

public class urlLoadEvent extends Event
{
public static const URL_CHANGED = "urlChanged";
public var urlLocation:String;

public function urlLoadEvent(urlL:String):void
{
super(URL_CHANGED);
urlLocation = urlL;
trace(urlLocation);
}

}
}

-- I'm not sure where to attach this.

???.addEventListener(urlLoadEvent.URL_CHANGED, onURLChange);
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


  



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Custom eventListener

2008-12-19 Thread Lehr, Ross (N-SGIS)
Thanks Jason... Let me ask one question to try to clarify this for me.  If I 
have the dispatchEvent that broadcasts the URL of my HTLMLoader in a 
onLoadComplete function and I want to listen for that event in a different 
class (for example I want to put the URL in a textbox that is created in a 
different class than the HTMLLoader) where would I put the addEventListener?  
I'm not sure why my head is not wrapping around this, but thanks for all your 
help.

Ross

-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com 
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason
Sent: Thursday, December 18, 2008 5:20 PM
To: Flash Coders List
Subject: RE: [Flashcoders] Custom eventListener

To add on to David's fine reply, Ross, you're close, but not quite - this is 
how I write custom events, I think you'll want to do something like this 
instead - this works great for me:

To write the event:

package events
{
import flash.events.Event;

public class MyEvent extends Event
{
public static var MYEVENT1:String = "myEvent1";  
public static var MYEVENT2:String = "myEvent2";

public function MyEvent(type:String, bubbles:Boolean = false, 
cancellable:Boolean = false ) 
{
super(type, bubbles, cancelable);
}

}

}

Then to dispatch:

import events.MyEvent;

dispatchEvent(new MyEvent(MyEvent.MYEVENT2, false, true));


Then to listen and react to dispatch:

myObject.addEventListener(MyEvent.MYEVENT2, onMyEvent2)

public function onMyEvent2(event:MyEvent):void
{
Trace("myEvent2 heard!");
}


Jason Merrill
Bank of America Instructional Technology & Media   ·   GCIB & Staff Support 
L&LD

Interested in Flash Platform technologies?  Join the Bank of America Flash 
Platform Developer Community 
Interested in innovative ideas in Learning?  Check out the Innovative Learning 
Blog and subscribe.





-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com 
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of David 
Hershberger
Sent: Thursday, December 18, 2008 4:58 PM
To: Flash Coders List
Subject: Re: [Flashcoders] Custom eventListener

An event is just a message object.  Just because one gets created
successfully does not mean it is being delivered.  dispatchEvent() is a
method of the EventDispatcher class, which is a superclass of many classes,
including DisplayObject.  You need to listen for the event (with
addEventListener()) on the same EventDispatcher where the event was
dispatched. (Except in the case of events that bubble, but that's another
topic.)

For example:

public class MyWindowHolder extends Sprite {
  public function init(): void {
var a: MyWindow = new MyWindow();
a.addEventListener( MyEvent.EXCLAMATION, onExclamation );
  }

  private function onExclamation( event: MyEvent ): void {
trace("ouch!");
  }
}

public class MyWindow extends Sprite {
  private function injury(): void {
this.dispatchEvent( new MyEvent( MyEvent.EXCLAMATION ));
  }
}

Hope this helps,
Dave

On 12/18/08, Lehr, Ross (N-SGIS)  wrote:
>
> Hey All...
>
>  I'm having trouble with a custom event listener.  I'm working on
> experiment browser project trying to learn as3, OOP, and AIR.  I
> broadcasting the URL after a web page is loaded and I need a text box to
> listen for it.  I've added a trace to me urlLoadedEvent class and I know
> the URL is getting there (so, I think it's getting broadcasted ok), but
> it's not getting to the text box.  I think I have my listener in the
> wrong place, but not sure where to put it.  I don't have my exact code
> here, but below are some code snippets.  Thanks for any and all help.
>
> Ross
>
>
>
> -- DISPACTING  EVEN
>
> In a loadComplete function urlLocation = text field for the URL string
>
> dispatchEvent(new urlLoadEvent(urlLocation.text));
>
> -- urlLoadEvent Class (when I trace urlLocation I am getting the URL
> string)
>
> package
> {
> import flash.events.*;
>
> public class urlLoadEvent extends Event
> {
> public static const URL_CHANGED = "urlChanged";
> public var urlLocation:String;
>
> public function urlLoadEvent(urlL:String):void
> {
> super(URL_CHANGED);
> urlLocation = urlL;
> trace(urlLocation);
> }
>
> }
> }
>
> -- I'm not sure where to attach this.
>
> ???.addEventListener(urlLoadEvent.URL_CHANGED, onURLChange);
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyf

RE: [Flashcoders] Custom eventListener

2008-12-19 Thread Merrill, Jason
>>" But all those things I can do with normal events, I guess.

So my wordplay aside, given my example, you would not use a "normal event" for 
this type of thing (having a class check data states and broadcast a 
notification to any listening classes that a certain data state, i.e. the 
machine is in the "on" state because all levers are pulled) - what kind of 
"normal" event are you thinking of?  I'm wondering if you're thinking of a 
tight-coupled relationship between classes where every time a lever is pulled, 
you check to see if all other levers are also pulled and then tell the 
lightbulb class to light up - that's not a good way to do it, it creates hard 
(i.e. tightly coupled) dependencies between classes.  I would instead do as in 
my example, broadcast that a certain state of the data (all levers pulled) has 
been achieved.  Then ANY other class, (i.e. the lightbulb, the Wonky Widget, 
the Funky Fan Button, etc.) can listen and react to that state of the levers.  
As you code, you want to loosely or completely de-couple relationships as m!
 uch as possible - depending on the size of the project, the larger the size 
and complexity, the more you will benefit from doing this.


Jason Merrill
Bank of America Instructional Technology & Media   ·   GCIB & Staff Support 
L&LD

Interested in Flash Platform technologies?  Join the Bank of America Flash 
Platform Developer Community 
Interested in innovative ideas in Learning?  Check out the Innovative Learning 
Blog and subscribe.






-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com 
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Cor
Sent: Thursday, December 18, 2008 5:42 PM
To: 'Flash Coders List'
Subject: RE: [Flashcoders] Custom eventListener

Jason: This is all simplified, advanced coders would use some design
patterns or frameworks to handle all this, but you get the idea.

Maybe I am slow... or even dumb?
But all those things I can do with normal events, I guess.
So what I mean was an example of something you cannot do with normal event
or what is specific case for using a custom event?


Kind regards
Cor

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Custom eventListener

2008-12-19 Thread Merrill, Jason
>> Maybe I am slow... or even dumb?
>>But all those things I can do with normal events, I guess.

I was simply showing you a simple example of how you would have a custom class 
broadcast a custom event... normally you would not use normal events like the 
mouse event kind for that kind of situation. ;) 


Jason Merrill
Bank of America Instructional Technology & Media   ·   GCIB & Staff Support 
L&LD

Interested in Flash Platform technologies?  Join the Bank of America Flash 
Platform Developer Community 
Interested in innovative ideas in Learning?  Check out the Innovative Learning 
Blog and subscribe.




___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Custom eventListener

2008-12-19 Thread Lehr, Ross (N-SGIS)
Thanks all.

-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Muzak
Sent: Friday, December 19, 2008 12:38 AM
To: Flash Coders List
Subject: Re: [Flashcoders] Custom eventListener

You might wanna read the docs for some basics on Events in AS3:
http://livedocs.adobe.com/flash/9.0/main/0138.html
http://livedocs.adobe.com/flash/9.0/main/0139.html

When writing cusom events, you can usually ommit the bubbles and
cancellable arguments, as those are false by default.

And you should always implement a clone() method:


Event class utility methods

There are two utility methods in the Event class. The clone() method
allows you to create copies of an event object. The toString() 
method allows you to generate a string representation of the properties
of an event object along with their values. Both of these 
methods are used internally by the event model system, but are exposed
to developers for general use.

For advanced developers creating subclasses of the Event class, you must
override and implement versions of both utility methods to 
ensure that the event subclass will work properly.


AFAIK, the toString() method is only useful for debugging purposes
(trace).

- Original Message - 
From: "Cor" 
To: "'Flash Coders List'" 
Sent: Thursday, December 18, 2008 11:27 PM
Subject: RE: [Flashcoders] Custom eventListener


> Thanks Ross and Jason!
>
> Now I understand this.
> But I am trying to imagine when I would use a custom event.
> I have no idea?
> Could you give an example?
>
> Kind regards
> Cor
>
> -Original Message-
> From: flashcoders-boun...@chattyfig.figleaf.com
> [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of
Merrill,
> Jason
> Sent: donderdag 18 december 2008 23:20
> To: Flash Coders List
> Subject: RE: [Flashcoders] Custom eventListener
>
> To add on to David's fine reply, Ross, you're close, but not quite -
this is
> how I write custom events, I think you'll want to do something like
this
> instead - this works great for me:
>
> To write the event:
>
> package events
> {
> import flash.events.Event;
>
> public class MyEvent extends Event
> {
> public static var MYEVENT1:String = "myEvent1";
> public static var MYEVENT2:String = "myEvent2";
>
> public function MyEvent(type:String, bubbles:Boolean =
> false, cancellable:Boolean = false )
> {
> super(type, bubbles, cancelable);
> }
>
> }
>
> }
>
> Then to dispatch:
>
> import events.MyEvent;
>
> dispatchEvent(new MyEvent(MyEvent.MYEVENT2, false, true));
>
>
> Then to listen and react to dispatch:
>
> myObject.addEventListener(MyEvent.MYEVENT2, onMyEvent2)
>
> public function onMyEvent2(event:MyEvent):void
> {
> Trace("myEvent2 heard!");
> }
>
>
> Jason Merrill
> Bank of America Instructional Technology & Media   *   GCIB &
Staff
> Support L&LD
>

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] round number to closet value of 8

2008-12-19 Thread Hans Wichman
Hey,

it cuts off the lowest 3 bits. These lowest 3 bits are 001, 010, 011 etc, so
1,2,3,4,5,6,7

But cutting off only the lowest three bits, will result in 0..7 being 0,
8..15 being 8, while you want 0..4 -> 0 , 5..12 -> 8, etc, so 4 is added.

But Benjamin can prolly explain better hehe since it's his trick :)

greetz
JC

On Fri, Dec 19, 2008 at 10:04 AM, Jiri Heitlager <
jiriheitla...@googlemail.com> wrote:

> Indeed it looks very impressive. Could some explain what is does exactly?
>
>
>
> Hans Wichman wrote:
>
>> very cool!
>>
>> On Thu, Dec 18, 2008 at 4:26 PM, Benjamin Wolsey > >wrote:
>>
>> Am Donnerstag, den 18.12.2008, 16:13 +0100 schrieb Hans Wichman:
>>>
 Hi,
 I think you are looking for :
 function roundToEight (pVal:Number) {
  return Math.round(pVal/8)<<3;
 }
 although 44.9 and 44.4 will both return 48, don't you mean 43.9 and
 44.4?

 int(pVal + 4) &~ 7;
>>>
>>> will also do it.
>>>
>>> --
>>> Free Flash, use Gnash
>>> http://www.gnu.org/software/gnash/
>>>
>>> Benjamin Wolsey, Software Developer - http://benjaminwolsey.de
>>>
>>> ___
>>> Flashcoders mailing list
>>> Flashcoders@chattyfig.figleaf.com
>>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>
>>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] round number to closet value of 8

2008-12-19 Thread Jiri Heitlager

Indeed it looks very impressive. Could some explain what is does exactly?


Hans Wichman wrote:

very cool!

On Thu, Dec 18, 2008 at 4:26 PM, Benjamin Wolsey wrote:


Am Donnerstag, den 18.12.2008, 16:13 +0100 schrieb Hans Wichman:

Hi,
I think you are looking for :
function roundToEight (pVal:Number) {
 return Math.round(pVal/8)<<3;
}
although 44.9 and 44.4 will both return 48, don't you mean 43.9 and 44.4?


int(pVal + 4) &~ 7;

will also do it.

--
Free Flash, use Gnash
http://www.gnu.org/software/gnash/

Benjamin Wolsey, Software Developer - http://benjaminwolsey.de

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders