Re: [Flashcoders] quick scoping question

2008-02-27 Thread Allandt Bik-Elliott (Receptacle)

thanks for the advice

a



On 27 Feb 2008, at 18:18, Muzak wrote:


The constructor should be as empty as possible.

package com.receptacle.drawingtest{
import flash.display.*;
import flash.text.TextField;
import flash.events.MouseEvent;
public class GreetingApp extends Sprite {
  public function GreetingApp() {
   draw();
 }

 private function draw() {
  var rectAndCircle:Sprite = new Sprite();

  rectAndCircle.graphics.lineStyle(10,0x99,1);
rectAndCircle.graphics.beginFill(0xFF,1);
rectAndCircle.graphics.drawRect(125,0,150,75);
rectAndCircle.graphics.beginFill(0xFF, 0.8);
rectAndCircle.graphics.drawCircle(150,100,50);

  rectAndCircle.x = 125;
  rectAndCircle.y = 100;
  addChild(rectAndCircle);
  rectAndCircle.addEventListener(MouseEvent.MOUSE_OVER,m);

  var triangle:Sprite = new Sprite();
  triangle.graphics.beginFill(0xFF5500,0.8);
  triangle.graphics.moveTo(50,0);
  triangle.graphics.lineTo(100,100);
  triangle.graphics.lineTo(0,100);
  triangle.graphics.lineTo(50,0);
  triangle.graphics.endFill();
  triangle.x = 175;
  triangle.y = 75;
  addChildAt(triangle, getChildIndex(rectAndCircle));
triangle.addEventListener(MouseEvent.MOUSE_OVER,m);

var greeting_txt:TextField = new TextField();
  greeting_txt.text = "hello world";
  greeting_txt.x = 200;
  greeting_txt.y = 300;
  addChild(greeting_txt);
 }

 private function m(evt:MouseEvent):void  {
  setChildIndex(evt.target as Sprite, numChildren-1);  }

}

}

- Original Message - From: "Allandt Bik-Elliott  
(Receptacle)" <[EMAIL PROTECTED]>

To: "Flash Coders List" 
Sent: Wednesday, February 27, 2008 6:29 PM
Subject: Re: [Flashcoders] quick scoping question



ah yeh - thanks - i'm still getting used to access-control
just out of interest - the GreetingApp is my class constructor   
method, would you still say that it should not have any functions   
within it?



___
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] quick scoping question

2008-02-27 Thread Muzak

The constructor should be as empty as possible.

package com.receptacle.drawingtest{
import flash.display.*;
import flash.text.TextField;
import flash.events.MouseEvent;

public class GreetingApp extends Sprite {
 
 public function GreetingApp() {

   draw();
 }

 private function draw() {
  var rectAndCircle:Sprite = new Sprite();

  rectAndCircle.graphics.lineStyle(10,0x99,1); 
  rectAndCircle.graphics.beginFill(0xFF,1); 
  rectAndCircle.graphics.drawRect(125,0,150,75); 
  rectAndCircle.graphics.beginFill(0xFF, 0.8); 
  rectAndCircle.graphics.drawCircle(150,100,50);

  rectAndCircle.x = 125;
  rectAndCircle.y = 100;
  addChild(rectAndCircle);
  rectAndCircle.addEventListener(MouseEvent.MOUSE_OVER,m);

  var triangle:Sprite = new Sprite();
  triangle.graphics.beginFill(0xFF5500,0.8);
  triangle.graphics.moveTo(50,0);
  triangle.graphics.lineTo(100,100);
  triangle.graphics.lineTo(0,100);
  triangle.graphics.lineTo(50,0);
  triangle.graphics.endFill();
  triangle.x = 175;
  triangle.y = 75;
  addChildAt(triangle, getChildIndex(rectAndCircle)); 
  triangle.addEventListener(MouseEvent.MOUSE_OVER,m);
  
  var greeting_txt:TextField = new TextField();

  greeting_txt.text = "hello world";
  greeting_txt.x = 200;
  greeting_txt.y = 300;
  addChild(greeting_txt);
 }

 private function m(evt:MouseEvent):void  {
  setChildIndex(evt.target as Sprite, numChildren-1); 
 }


}

}

- Original Message - 
From: "Allandt Bik-Elliott (Receptacle)" <[EMAIL PROTECTED]>

To: "Flash Coders List" 
Sent: Wednesday, February 27, 2008 6:29 PM
Subject: Re: [Flashcoders] quick scoping question



ah yeh - thanks - i'm still getting used to access-control

just out of interest - the GreetingApp is my class constructor  
method, would you still say that it should not have any functions  
within it?





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


Re: [Flashcoders] quick scoping question

2008-02-27 Thread Allandt Bik-Elliott (Receptacle)

ah yeh - thanks - i'm still getting used to access-control

just out of interest - the GreetingApp is my class constructor  
method, would you still say that it should not have any functions  
within it?


repurpose of my old code:


package com.receptacle.drawingtest
{
import flash.display.*;
import flash.text.TextField;
import flash.events.MouseEvent;

public class GreetingApp extends Sprite
{
public function GreetingApp()
{
			//var rectAndCircle:Shape = new Shape(); shape changed to sprite  
to support mouseevent

var rectAndCircle:Sprite = new Sprite();
			//adding multiple shapes to a single Shape() instance is akin to  
creating a graphic instance
			rectAndCircle.graphics.lineStyle(10,0x99,1); // draw lines  
around all rectAndCircle objects 100% alpha (now alpha = 1)

rectAndCircle.graphics.beginFill(0xFF,1); // set 
colour on object
rectAndCircle.graphics.drawRect(125,0,150,75); // 
rectangle
			rectAndCircle.graphics.beginFill(0xFF, 0.8); // change colour  
on object 80% alpha (now alpha = 0.8)

rectAndCircle.graphics.drawCircle(150,100,50); // circle
rectAndCircle.x = 125;
rectAndCircle.y = 100;
//without this, rectAndCircle will not display
addChild(rectAndCircle);
//just for fun
rectAndCircle.addEventListener(MouseEvent.MOUSE_OVER,m);

var triangle:Sprite = new Sprite();
triangle.graphics.beginFill(0xFF5500,0.8);
triangle.graphics.moveTo(50,0);
triangle.graphics.lineTo(100,100);
triangle.graphics.lineTo(0,100);
triangle.graphics.lineTo(50,0);
triangle.graphics.endFill();
triangle.x = 175;
triangle.y = 75;
			addChildAt(triangle, getChildIndex(rectAndCircle)); // puts  
triangle BELOW rectAndCircle

triangle.addEventListener(MouseEvent.MOUSE_OVER,m);

var greeting_txt:TextField = new TextField();
greeting_txt.text = "hello world";
greeting_txt.x = 200;
greeting_txt.y = 300;
addChild(greeting_txt);
}

protected function m(evt:MouseEvent):void
{
			setChildIndex(evt.target as Sprite, numChildren-1); //  
MouseEvent.target gives the target but must be a sprite

}
}
}


thanks
a



On 27 Feb 2008, at 16:38, Muzak wrote:


Casting is not hacky, it's how things are done in AS3.

Get rid of the nested function though.

 public function GreetingApp() {
 }
  protected function m(evt:MouseEvent):void{
 }

not
 public function GreetingApp() {
 function m(evt:MouseEvent):void{
 }
 }

regards,
Muzak



- Original Message - From: "Allandt Bik-Elliott  
(Receptacle)" <[EMAIL PROTECTED]>

To: "Flash Coders List" 
Sent: Wednesday, February 27, 2008 4:52 PM
Subject: Re: [Flashcoders] quick scoping question



i've amended my function to be
function m(evt:MouseEvent):void
{
setChildIndex(DisplayObject(evt.target), numChildren-1);
}
which works but forcing the object type seems a bit hacky to me  
and  doesn't really teach me anything

On 27 Feb 2008, at 14:58, Allandt Bik-Elliott (Receptacle) wrote:

hi guys

i'm playing with some as3 to get my head around it and i've come   
across a little wierdness in the drawing api that i hope you can   
shed some light on


here is my script - it's an amended version of one from  
Essential  Actionscript:




package com.receptacle.drawingtest
{
import flash.display.*;
import flash.text.TextField;
import flash.events.MouseEvent;
public class GreetingApp extends Sprite
{
public function GreetingApp()
{
//var rectAndCircle:Shape = new Shape(); shape changed to sprite   
to support mouse event

var rectAndCircle:Sprite = new Sprite();
//adding multiple shapes to a single Shape() instance is akin to   
creating a graphic instance
rectAndCircle.graphics.lineStyle(10,0x99,1); // draw lines   
around all rectAndCircle objects
rectAndCircle.graphics.beginFill(0xFF,1); // set colour on   
object

rectAndCircle.graphics.drawRect(125,0,150,75); // rectangle
rectAndCircle.graphics.beginFill(0xFF, 0.8); // change   
colour on object

rectAndCircle.graphics.drawCircle(150,100,50); // circle
rectAndCircle.x = 125;
rectAndCircle.y = 100;
//without this, rectAndCircle will not display
addChild(rectAndCircle);
//just for fun
rectAndCircle.addEventListener(MouseEvent.MOUSE_OVER,m);

var triangle:Sprite = new Sprite()
t

Re: [Flashcoders] quick scoping question

2008-02-27 Thread Allandt Bik-Elliott (Receptacle)

thankyou :)



On 27 Feb 2008, at 16:12, Cor wrote:


That was what I basicly meant

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Allandt
Bik-Elliott (Receptacle)
Verzonden: woensdag 27 februari 2008 17:03
Aan: Flash Coders List
Onderwerp: Re: [Flashcoders] quick scoping question

however

trying this did work

function m(evt:MouseEvent):void
{
setChildIndex(evt.target as Sprite,
numChildren-1);
}



On 27 Feb 2008, at 15:25, Cor wrote:


I made a minor adjustment because you have to typecast these  to a
Sprite:


package
{
import flash.display.*;
import flash.text.TextField;
import flash.events.MouseEvent;

public class GreetingApp extends Sprite
{
public function GreetingApp()
{
//var rectAndCircle:Shape = new Shape(); shape

changed to sprite to

support mouse event
var rectAndCircle:Sprite = new Sprite();
//adding multiple shapes to a single Shape()

instance is akin to

creating a graphic instance
rectAndCircle.graphics.lineStyle(10,0x99,1); //

draw lines

around all rectAndCircle objects
rectAndCircle.graphics.beginFill(0xFF,1); // set

colour on

object
rectAndCircle.graphics.drawRect(125,0,150,75); //

rectangle

rectAndCircle.graphics.beginFill(0xFF, 0.8); //

change colour

on object
rectAndCircle.graphics.drawCircle(150,100,50); //

circle

rectAndCircle.x = 125;
rectAndCircle.y = 100;
//without this, rectAndCircle will not display
addChild(rectAndCircle);
//just for fun

rectAndCircle.addEventListener(MouseEvent.MOUSE_OVER,m) as Sprite;

var triangle:Sprite = new Sprite()
triangle.graphics.beginFill(0xFF5500,0.8);
triangle.graphics.moveTo(50,0);
triangle.graphics.lineTo(100,100);
triangle.graphics.lineTo(0,100);
triangle.graphics.lineTo(50,0);
triangle.graphics.endFill();
triangle.x = 175;
triangle.y = 75;
addChildAt(triangle, getChildIndex(rectAndCircle));

// puts

triangle BELOW rectAndCircle
triangle.addEventListener(MouseEvent.MOUSE_OVER,m)
as Sprite;

function m(e:MouseEvent):void
{
trace(this);
//setChildIndex(this, numChildren-1);

//doesn't work - 'this' is

scoped to the holding object
trace(e);
}

var greeting_txt:TextField = new TextField();
greeting_txt.text = "hello world";
greeting_txt.x = 200;
greeting_txt.y = 300;
addChild(greeting_txt);
}
}
}


-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Allandt
Bik-Elliott (Receptacle)
Verzonden: woensdag 27 februari 2008 15:58
Aan: flashcoders
Onderwerp: [Flashcoders] quick scoping question

hi guys

i'm playing with some as3 to get my head around it and i've come
across a little wierdness in the drawing api that i hope you can shed
some light on

here is my script - it's an amended version of one from Essential
Actionscript:



package com.receptacle.drawingtest
{
import flash.display.*;
import flash.text.TextField;
import flash.events.MouseEvent;

public class GreetingApp extends Sprite
{
public function GreetingApp()
{
//var rectAndCircle:Shape = new Shape(); shape

changed to sprite to

support mouse event
var rectAndCircle:Sprite = new Sprite();
//adding multiple shapes to a single Shape()

instance is akin to

creating a graphic instance
rectAndCircle.graphics.lineStyle(10,0x99,1); //

draw lines

around all rectAndCircle objects
rectAndCircle.graphics.beginFill(0xFF,1); // set

colour on

object
rectAndCircle.graphics.drawRect(125,0,150,75); //

rectangle

rectAndCircle.graphics.beginFill(0xFF, 0.8); //

change colour

on object
rectAndCircle.graphics.drawCircle(150,100,50); //

circle

 

Re: [Flashcoders] quick scoping question

2008-02-27 Thread Muzak

Casting is not hacky, it's how things are done in AS3.

Get rid of the nested function though.

 public function GreetingApp() {
 }
 
 protected function m(evt:MouseEvent):void{

 }

not 


 public function GreetingApp() {
 function m(evt:MouseEvent):void{
 }
 }

regards,
Muzak



- Original Message - 
From: "Allandt Bik-Elliott (Receptacle)" <[EMAIL PROTECTED]>

To: "Flash Coders List" 
Sent: Wednesday, February 27, 2008 4:52 PM
Subject: Re: [Flashcoders] quick scoping question



i've amended my function to be

function m(evt:MouseEvent):void
{
setChildIndex(DisplayObject(evt.target), numChildren-1);
}


which works but forcing the object type seems a bit hacky to me and  
doesn't really teach me anything



On 27 Feb 2008, at 14:58, Allandt Bik-Elliott (Receptacle) wrote:


hi guys

i'm playing with some as3 to get my head around it and i've come  
across a little wierdness in the drawing api that i hope you can  
shed some light on


here is my script - it's an amended version of one from Essential  
Actionscript:




package com.receptacle.drawingtest
{
import flash.display.*;
import flash.text.TextField;
import flash.events.MouseEvent;

public class GreetingApp extends Sprite
{
public function GreetingApp()
{
//var rectAndCircle:Shape = new Shape(); shape changed to sprite  
to support mouse event

var rectAndCircle:Sprite = new Sprite();
//adding multiple shapes to a single Shape() instance is akin to  
creating a graphic instance
rectAndCircle.graphics.lineStyle(10,0x99,1); // draw lines  
around all rectAndCircle objects
rectAndCircle.graphics.beginFill(0xFF,1); // set colour on  
object

rectAndCircle.graphics.drawRect(125,0,150,75); // rectangle
rectAndCircle.graphics.beginFill(0xFF, 0.8); // change  
colour on object

rectAndCircle.graphics.drawCircle(150,100,50); // circle
rectAndCircle.x = 125;
rectAndCircle.y = 100;
//without this, rectAndCircle will not display
addChild(rectAndCircle);
//just for fun
rectAndCircle.addEventListener(MouseEvent.MOUSE_OVER,m);

var triangle:Sprite = new Sprite()
triangle.graphics.beginFill(0xFF5500,0.8);
triangle.graphics.moveTo(50,0);
triangle.graphics.lineTo(100,100);
triangle.graphics.lineTo(0,100);
triangle.graphics.lineTo(50,0);
triangle.graphics.endFill();
triangle.x = 175;
triangle.y = 75;
addChildAt(triangle, getChildIndex(rectAndCircle)); // puts  
triangle BELOW rectAndCircle

triangle.addEventListener(MouseEvent.MOUSE_OVER,m);

function m(event:MouseEvent):void
{
setChildIndex(this, numChildren-1); //doesn't work - 'this' is  
scoped to the holding object

}

var greeting_txt:TextField = new TextField();
greeting_txt.text = "hello world";
greeting_txt.x = 200;
greeting_txt.y = 300;
addChild(greeting_txt);
}
}
}



is what i've done possible? ie can i set a single mouseListener  
method (m in my example) to be used by any of the sprites to move  
themselves to the front of the display stack or would i have to  
write an explicit statement for each one?


thanks for your time
a



___
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] quick scoping question

2008-02-27 Thread Cor
That was what I basicly meant 

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Allandt
Bik-Elliott (Receptacle)
Verzonden: woensdag 27 februari 2008 17:03
Aan: Flash Coders List
Onderwerp: Re: [Flashcoders] quick scoping question

however

trying this did work

function m(evt:MouseEvent):void
{
setChildIndex(evt.target as Sprite,
numChildren-1);
}



On 27 Feb 2008, at 15:25, Cor wrote:

> I made a minor adjustment because you have to typecast these  to a
> Sprite:
>
> 
> package
> {
>   import flash.display.*;
>   import flash.text.TextField;
>   import flash.events.MouseEvent;
>   
>   public class GreetingApp extends Sprite
>   {
>   public function GreetingApp()
>   {
>   //var rectAndCircle:Shape = new Shape(); shape
changed to sprite to 
> support mouse event
>   var rectAndCircle:Sprite = new Sprite();
>   //adding multiple shapes to a single Shape()
instance is akin to 
> creating a graphic instance
>   rectAndCircle.graphics.lineStyle(10,0x99,1); //
draw lines 
> around all rectAndCircle objects
>   rectAndCircle.graphics.beginFill(0xFF,1); // set
colour on 
> object
>   rectAndCircle.graphics.drawRect(125,0,150,75); //
rectangle
>   rectAndCircle.graphics.beginFill(0xFF, 0.8); //
change colour 
> on object
>   rectAndCircle.graphics.drawCircle(150,100,50); //
circle
>   rectAndCircle.x = 125;
>   rectAndCircle.y = 100;
>   //without this, rectAndCircle will not display
>   addChild(rectAndCircle);
>   //just for fun
>   
> rectAndCircle.addEventListener(MouseEvent.MOUSE_OVER,m) as Sprite;
>
>   var triangle:Sprite = new Sprite()
>   triangle.graphics.beginFill(0xFF5500,0.8);
>   triangle.graphics.moveTo(50,0);
>   triangle.graphics.lineTo(100,100);
>   triangle.graphics.lineTo(0,100);
>   triangle.graphics.lineTo(50,0);
>   triangle.graphics.endFill();
>   triangle.x = 175;
>   triangle.y = 75;
>   addChildAt(triangle, getChildIndex(rectAndCircle));
// puts 
> triangle BELOW rectAndCircle
>   triangle.addEventListener(MouseEvent.MOUSE_OVER,m)
> as Sprite;
>   
>   function m(e:MouseEvent):void
>   {
>   trace(this);
>   //setChildIndex(this, numChildren-1);
//doesn't work - 'this' is 
> scoped to the holding object
>   trace(e);
>   }
>   
>   var greeting_txt:TextField = new TextField();
>   greeting_txt.text = "hello world";
>   greeting_txt.x = 200;
>   greeting_txt.y = 300;
>   addChild(greeting_txt);
>   }
>   }
> }
> 
>
> -Oorspronkelijk bericht-
> Van: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Namens Allandt 
> Bik-Elliott (Receptacle)
> Verzonden: woensdag 27 februari 2008 15:58
> Aan: flashcoders
> Onderwerp: [Flashcoders] quick scoping question
>
> hi guys
>
> i'm playing with some as3 to get my head around it and i've come 
> across a little wierdness in the drawing api that i hope you can shed 
> some light on
>
> here is my script - it's an amended version of one from Essential
> Actionscript:
>
> 
>
> package com.receptacle.drawingtest
> {
>   import flash.display.*;
>   import flash.text.TextField;
>   import flash.events.MouseEvent;
>   
>   public class GreetingApp extends Sprite
>   {
>   public function GreetingApp()
>   {
>   //var rectAndCircle:Shape = new Shape(); shape
changed to sprite to 
> support mouse event
>   var rectAndCircle:Sprite = new Sprite();
>   //adding multiple shapes to a single Shape()
instance is akin to 
> creating a graphic instance
>   rectAndCircle.graphics.lineStyle(10,0x99,1); //
draw lines 
> around all rectAndCircle objects
>   rectAndCircle.graphics.beginFill(0

Re: [Flashcoders] quick scoping question

2008-02-27 Thread Allandt Bik-Elliott (Receptacle)

however

trying this did work

function m(evt:MouseEvent):void
{
setChildIndex(evt.target as Sprite, 
numChildren-1);
}



On 27 Feb 2008, at 15:25, Cor wrote:

I made a minor adjustment because you have to typecast these  to a  
Sprite:



package
{
import flash.display.*;
import flash.text.TextField;
import flash.events.MouseEvent;

public class GreetingApp extends Sprite
{
public function GreetingApp()
{
//var rectAndCircle:Shape = new Shape(); shape
changed to sprite to support mouse event
var rectAndCircle:Sprite = new Sprite();
//adding multiple shapes to a single Shape()
instance is akin to creating a graphic instance
rectAndCircle.graphics.lineStyle(10,0x99,1); //
draw lines around all rectAndCircle objects
rectAndCircle.graphics.beginFill(0xFF,1); // set
colour on object
rectAndCircle.graphics.drawRect(125,0,150,75); //
rectangle
rectAndCircle.graphics.beginFill(0xFF, 0.8); //
change colour on object
rectAndCircle.graphics.drawCircle(150,100,50); //
circle
rectAndCircle.x = 125;
rectAndCircle.y = 100;
//without this, rectAndCircle will not display
addChild(rectAndCircle);
//just for fun

rectAndCircle.addEventListener(MouseEvent.MOUSE_OVER,m) as Sprite;

var triangle:Sprite = new Sprite()
triangle.graphics.beginFill(0xFF5500,0.8);
triangle.graphics.moveTo(50,0);
triangle.graphics.lineTo(100,100);
triangle.graphics.lineTo(0,100);
triangle.graphics.lineTo(50,0);
triangle.graphics.endFill();
triangle.x = 175;
triangle.y = 75;
addChildAt(triangle, getChildIndex(rectAndCircle));
// puts triangle BELOW rectAndCircle
triangle.addEventListener(MouseEvent.MOUSE_OVER,m)
as Sprite;

function m(e:MouseEvent):void
{
trace(this);
//setChildIndex(this, numChildren-1);
//doesn't work - 'this' is scoped to the holding object
trace(e);
}

var greeting_txt:TextField = new TextField();
greeting_txt.text = "hello world";
greeting_txt.x = 200;
greeting_txt.y = 300;
addChild(greeting_txt);
}
}
}


-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Allandt
Bik-Elliott (Receptacle)
Verzonden: woensdag 27 februari 2008 15:58
Aan: flashcoders
Onderwerp: [Flashcoders] quick scoping question

hi guys

i'm playing with some as3 to get my head around it and i've come  
across a
little wierdness in the drawing api that i hope you can shed some  
light on


here is my script - it's an amended version of one from Essential
Actionscript:



package com.receptacle.drawingtest
{
import flash.display.*;
import flash.text.TextField;
import flash.events.MouseEvent;

public class GreetingApp extends Sprite
{
public function GreetingApp()
{
//var rectAndCircle:Shape = new Shape(); shape
changed to sprite to support mouse event
var rectAndCircle:Sprite = new Sprite();
//adding multiple shapes to a single Shape()
instance is akin to creating a graphic instance
rectAndCircle.graphics.lineStyle(10,0x99,1); //
draw lines around all rectAndCircle objects
rectAndCircle.graphics.beginFill(0xFF,1); // set
colour on object
rectAndCircle.graphics.drawRect(125,0,150,75); //
rectangle
rectAndCircle.graphics.beginFill(0xFF, 0.8); //
change colour on object
rectAndCircle.graphics.drawCircle(150,100,50); //
circle
rectAndCircle.x = 125;
rectAndCircle.y = 100;
//without this, rectAndCircle will not display
addChild(rectAndCircle);
//just for fun

rectAndCircle.addEventListener(MouseEvent.MOUSE_OVER,m);

var triangle:Sprite = new Sprite()
triangle.g

Re: [Flashcoders] quick scoping question

2008-02-27 Thread Allandt Bik-Elliott (Receptacle)

thanks for the input, Cor...

hmmm didn't work for me



On 27 Feb 2008, at 15:25, Cor wrote:

I made a minor adjustment because you have to typecast these  to a  
Sprite:



package
{
import flash.display.*;
import flash.text.TextField;
import flash.events.MouseEvent;

public class GreetingApp extends Sprite
{
public function GreetingApp()
{
//var rectAndCircle:Shape = new Shape(); shape
changed to sprite to support mouse event
var rectAndCircle:Sprite = new Sprite();
//adding multiple shapes to a single Shape()
instance is akin to creating a graphic instance
rectAndCircle.graphics.lineStyle(10,0x99,1); //
draw lines around all rectAndCircle objects
rectAndCircle.graphics.beginFill(0xFF,1); // set
colour on object
rectAndCircle.graphics.drawRect(125,0,150,75); //
rectangle
rectAndCircle.graphics.beginFill(0xFF, 0.8); //
change colour on object
rectAndCircle.graphics.drawCircle(150,100,50); //
circle
rectAndCircle.x = 125;
rectAndCircle.y = 100;
//without this, rectAndCircle will not display
addChild(rectAndCircle);
//just for fun

rectAndCircle.addEventListener(MouseEvent.MOUSE_OVER,m) as Sprite;

var triangle:Sprite = new Sprite()
triangle.graphics.beginFill(0xFF5500,0.8);
triangle.graphics.moveTo(50,0);
triangle.graphics.lineTo(100,100);
triangle.graphics.lineTo(0,100);
triangle.graphics.lineTo(50,0);
triangle.graphics.endFill();
triangle.x = 175;
triangle.y = 75;
addChildAt(triangle, getChildIndex(rectAndCircle));
// puts triangle BELOW rectAndCircle
triangle.addEventListener(MouseEvent.MOUSE_OVER,m)
as Sprite;

function m(e:MouseEvent):void
{
trace(this);
//setChildIndex(this, numChildren-1);
//doesn't work - 'this' is scoped to the holding object
trace(e);
}

var greeting_txt:TextField = new TextField();
greeting_txt.text = "hello world";
greeting_txt.x = 200;
greeting_txt.y = 300;
addChild(greeting_txt);
}
}
}


-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Allandt
Bik-Elliott (Receptacle)
Verzonden: woensdag 27 februari 2008 15:58
Aan: flashcoders
Onderwerp: [Flashcoders] quick scoping question

hi guys

i'm playing with some as3 to get my head around it and i've come  
across a
little wierdness in the drawing api that i hope you can shed some  
light on


here is my script - it's an amended version of one from Essential
Actionscript:



package com.receptacle.drawingtest
{
import flash.display.*;
import flash.text.TextField;
import flash.events.MouseEvent;

public class GreetingApp extends Sprite
{
public function GreetingApp()
{
//var rectAndCircle:Shape = new Shape(); shape
changed to sprite to support mouse event
var rectAndCircle:Sprite = new Sprite();
//adding multiple shapes to a single Shape()
instance is akin to creating a graphic instance
rectAndCircle.graphics.lineStyle(10,0x99,1); //
draw lines around all rectAndCircle objects
rectAndCircle.graphics.beginFill(0xFF,1); // set
colour on object
rectAndCircle.graphics.drawRect(125,0,150,75); //
rectangle
rectAndCircle.graphics.beginFill(0xFF, 0.8); //
change colour on object
rectAndCircle.graphics.drawCircle(150,100,50); //
circle
rectAndCircle.x = 125;
rectAndCircle.y = 100;
//without this, rectAndCircle will not display
addChild(rectAndCircle);
//just for fun

rectAndCircle.addEventListener(MouseEvent.MOUSE_OVER,m);

var triangle:Sprite = new Sprite()
triangle.graphics.beginFill(0xFF5500,0.8);
triangle.graphics.moveTo(50,0);
triangle.graphics.lineTo(100,100);
  

RE: [Flashcoders] quick scoping question

2008-02-27 Thread Cor
Yes, I see.
Sorry, I misunderstood. 

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Allandt
Bik-Elliott (Receptacle)
Verzonden: woensdag 27 februari 2008 16:53
Aan: Flash Coders List
Onderwerp: Re: [Flashcoders] quick scoping question

i've amended my function to be

function m(evt:MouseEvent):void
{
setChildIndex(DisplayObject(evt.target),
numChildren-1);
}


which works but forcing the object type seems a bit hacky to me and doesn't
really teach me anything


On 27 Feb 2008, at 14:58, Allandt Bik-Elliott (Receptacle) wrote:

> hi guys
>
> i'm playing with some as3 to get my head around it and i've come 
> across a little wierdness in the drawing api that i hope you can shed 
> some light on
>
> here is my script - it's an amended version of one from Essential
> Actionscript:
>
> 
>
> package com.receptacle.drawingtest
> {
>   import flash.display.*;
>   import flash.text.TextField;
>   import flash.events.MouseEvent;
>   
>   public class GreetingApp extends Sprite
>   {
>   public function GreetingApp()
>   {
>   //var rectAndCircle:Shape = new Shape(); shape
changed to sprite to 
> support mouse event
>   var rectAndCircle:Sprite = new Sprite();
>   //adding multiple shapes to a single Shape()
instance is akin to 
> creating a graphic instance
>   rectAndCircle.graphics.lineStyle(10,0x99,1); //
draw lines 
> around all rectAndCircle objects
>   rectAndCircle.graphics.beginFill(0xFF,1); // set
colour on 
> object
>   rectAndCircle.graphics.drawRect(125,0,150,75); //
rectangle
>   rectAndCircle.graphics.beginFill(0xFF, 0.8); //
change colour 
> on object
>   rectAndCircle.graphics.drawCircle(150,100,50); //
circle
>   rectAndCircle.x = 125;
>   rectAndCircle.y = 100;
>   //without this, rectAndCircle will not display
>   addChild(rectAndCircle);
>   //just for fun
>
rectAndCircle.addEventListener(MouseEvent.MOUSE_OVER,m);
>
>   var triangle:Sprite = new Sprite()
>   triangle.graphics.beginFill(0xFF5500,0.8);
>   triangle.graphics.moveTo(50,0);
>   triangle.graphics.lineTo(100,100);
>   triangle.graphics.lineTo(0,100);
>   triangle.graphics.lineTo(50,0);
>   triangle.graphics.endFill();
>   triangle.x = 175;
>   triangle.y = 75;
>   addChildAt(triangle, getChildIndex(rectAndCircle));
// puts 
> triangle BELOW rectAndCircle
>   triangle.addEventListener(MouseEvent.MOUSE_OVER,m);
>   
>   function m(event:MouseEvent):void
>   {
>   setChildIndex(this, numChildren-1);
//doesn't work - 'this' is 
> scoped to the holding object
>   }
>   
>   var greeting_txt:TextField = new TextField();
>   greeting_txt.text = "hello world";
>   greeting_txt.x = 200;
>   greeting_txt.y = 300;
>   addChild(greeting_txt);
>   }
>   }
> }
>
> 
>
> is what i've done possible? ie can i set a single mouseListener method 
> (m in my example) to be used by any of the sprites to move themselves 
> to the front of the display stack or would i have to write an explicit 
> statement for each one?
>
> thanks for your time
> a
>
>
>
> ___
> 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


--
No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.21.1/1300 - Release Date: 26-2-2008
19:50


No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.21.1/1300 - Release Date: 26-2-2008
19:50
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.21.1/1300 - Release Date: 26-2-2008
19:50
 

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


Re: [Flashcoders] quick scoping question

2008-02-27 Thread Allandt Bik-Elliott (Receptacle)

i've amended my function to be

function m(evt:MouseEvent):void
{
setChildIndex(DisplayObject(evt.target), 
numChildren-1);
}


which works but forcing the object type seems a bit hacky to me and  
doesn't really teach me anything



On 27 Feb 2008, at 14:58, Allandt Bik-Elliott (Receptacle) wrote:


hi guys

i'm playing with some as3 to get my head around it and i've come  
across a little wierdness in the drawing api that i hope you can  
shed some light on


here is my script - it's an amended version of one from Essential  
Actionscript:




package com.receptacle.drawingtest
{
import flash.display.*;
import flash.text.TextField;
import flash.events.MouseEvent;

public class GreetingApp extends Sprite
{
public function GreetingApp()
{
			//var rectAndCircle:Shape = new Shape(); shape changed to sprite  
to support mouse event

var rectAndCircle:Sprite = new Sprite();
			//adding multiple shapes to a single Shape() instance is akin to  
creating a graphic instance
			rectAndCircle.graphics.lineStyle(10,0x99,1); // draw lines  
around all rectAndCircle objects
			rectAndCircle.graphics.beginFill(0xFF,1); // set colour on  
object

rectAndCircle.graphics.drawRect(125,0,150,75); // 
rectangle
			rectAndCircle.graphics.beginFill(0xFF, 0.8); // change  
colour on object

rectAndCircle.graphics.drawCircle(150,100,50); // circle
rectAndCircle.x = 125;
rectAndCircle.y = 100;
//without this, rectAndCircle will not display
addChild(rectAndCircle);
//just for fun
rectAndCircle.addEventListener(MouseEvent.MOUSE_OVER,m);

var triangle:Sprite = new Sprite()
triangle.graphics.beginFill(0xFF5500,0.8);
triangle.graphics.moveTo(50,0);
triangle.graphics.lineTo(100,100);
triangle.graphics.lineTo(0,100);
triangle.graphics.lineTo(50,0);
triangle.graphics.endFill();
triangle.x = 175;
triangle.y = 75;
			addChildAt(triangle, getChildIndex(rectAndCircle)); // puts  
triangle BELOW rectAndCircle

triangle.addEventListener(MouseEvent.MOUSE_OVER,m);

function m(event:MouseEvent):void
{
setChildIndex(this, numChildren-1); //doesn't work - 'this' is  
scoped to the holding object

}

var greeting_txt:TextField = new TextField();
greeting_txt.text = "hello world";
greeting_txt.x = 200;
greeting_txt.y = 300;
addChild(greeting_txt);
}
}
}



is what i've done possible? ie can i set a single mouseListener  
method (m in my example) to be used by any of the sprites to move  
themselves to the front of the display stack or would i have to  
write an explicit statement for each one?


thanks for your time
a



___
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] quick scoping question

2008-02-27 Thread Cor
I made a minor adjustment because you have to typecast these  to a Sprite:


package
{
import flash.display.*;
import flash.text.TextField;
import flash.events.MouseEvent;

public class GreetingApp extends Sprite
{
public function GreetingApp()
{
//var rectAndCircle:Shape = new Shape(); shape
changed to sprite to support mouse event
var rectAndCircle:Sprite = new Sprite();
//adding multiple shapes to a single Shape()
instance is akin to creating a graphic instance
rectAndCircle.graphics.lineStyle(10,0x99,1); //
draw lines around all rectAndCircle objects
rectAndCircle.graphics.beginFill(0xFF,1); // set
colour on object
rectAndCircle.graphics.drawRect(125,0,150,75); //
rectangle
rectAndCircle.graphics.beginFill(0xFF, 0.8); //
change colour on object
rectAndCircle.graphics.drawCircle(150,100,50); //
circle
rectAndCircle.x = 125;
rectAndCircle.y = 100;
//without this, rectAndCircle will not display
addChild(rectAndCircle);
//just for fun

rectAndCircle.addEventListener(MouseEvent.MOUSE_OVER,m) as Sprite;

var triangle:Sprite = new Sprite()
triangle.graphics.beginFill(0xFF5500,0.8);
triangle.graphics.moveTo(50,0);
triangle.graphics.lineTo(100,100);
triangle.graphics.lineTo(0,100);
triangle.graphics.lineTo(50,0);
triangle.graphics.endFill();
triangle.x = 175;
triangle.y = 75;
addChildAt(triangle, getChildIndex(rectAndCircle));
// puts triangle BELOW rectAndCircle
triangle.addEventListener(MouseEvent.MOUSE_OVER,m)
as Sprite;

function m(e:MouseEvent):void
{
trace(this);
//setChildIndex(this, numChildren-1);
//doesn't work - 'this' is scoped to the holding object
trace(e);
}

var greeting_txt:TextField = new TextField();
greeting_txt.text = "hello world";
greeting_txt.x = 200;
greeting_txt.y = 300;
addChild(greeting_txt);
}
}
}


-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Allandt
Bik-Elliott (Receptacle)
Verzonden: woensdag 27 februari 2008 15:58
Aan: flashcoders
Onderwerp: [Flashcoders] quick scoping question

hi guys

i'm playing with some as3 to get my head around it and i've come across a
little wierdness in the drawing api that i hope you can shed some light on

here is my script - it's an amended version of one from Essential
Actionscript:



package com.receptacle.drawingtest
{
import flash.display.*;
import flash.text.TextField;
import flash.events.MouseEvent;

public class GreetingApp extends Sprite
{
public function GreetingApp()
{
//var rectAndCircle:Shape = new Shape(); shape
changed to sprite to support mouse event
var rectAndCircle:Sprite = new Sprite();
//adding multiple shapes to a single Shape()
instance is akin to creating a graphic instance
rectAndCircle.graphics.lineStyle(10,0x99,1); //
draw lines around all rectAndCircle objects
rectAndCircle.graphics.beginFill(0xFF,1); // set
colour on object
rectAndCircle.graphics.drawRect(125,0,150,75); //
rectangle
rectAndCircle.graphics.beginFill(0xFF, 0.8); //
change colour on object
rectAndCircle.graphics.drawCircle(150,100,50); //
circle
rectAndCircle.x = 125;
rectAndCircle.y = 100;
//without this, rectAndCircle will not display
addChild(rectAndCircle);
//just for fun

rectAndCircle.addEventListener(MouseEvent.MOUSE_OVER,m);

var triangle:Sprite = new Sprite()
triangle.graphics.beginFill(0xFF5500,0.8);
triangle.graphics.moveTo(50,0);
triangle.graphics.lineTo(100,100);
triangle.graphics.lineTo(0,100);
triangle.graphics.lineTo(50,0);
 

RE: [Flashcoders] quick scoping question

2008-02-27 Thread Cor
Yes, you can.
But you are referring to THIS and that is the class instance.
So use the .target property of the object send by the mouse event.

HTH

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Allandt
Bik-Elliott (Receptacle)
Verzonden: woensdag 27 februari 2008 15:58
Aan: flashcoders
Onderwerp: [Flashcoders] quick scoping question

hi guys

i'm playing with some as3 to get my head around it and i've come across a
little wierdness in the drawing api that i hope you can shed some light on

here is my script - it's an amended version of one from Essential
Actionscript:



package com.receptacle.drawingtest
{
import flash.display.*;
import flash.text.TextField;
import flash.events.MouseEvent;

public class GreetingApp extends Sprite
{
public function GreetingApp()
{
//var rectAndCircle:Shape = new Shape(); shape
changed to sprite to support mouse event
var rectAndCircle:Sprite = new Sprite();
//adding multiple shapes to a single Shape()
instance is akin to creating a graphic instance
rectAndCircle.graphics.lineStyle(10,0x99,1); //
draw lines around all rectAndCircle objects
rectAndCircle.graphics.beginFill(0xFF,1); // set
colour on object
rectAndCircle.graphics.drawRect(125,0,150,75); //
rectangle
rectAndCircle.graphics.beginFill(0xFF, 0.8); //
change colour on object
rectAndCircle.graphics.drawCircle(150,100,50); //
circle
rectAndCircle.x = 125;
rectAndCircle.y = 100;
//without this, rectAndCircle will not display
addChild(rectAndCircle);
//just for fun

rectAndCircle.addEventListener(MouseEvent.MOUSE_OVER,m);

var triangle:Sprite = new Sprite()
triangle.graphics.beginFill(0xFF5500,0.8);
triangle.graphics.moveTo(50,0);
triangle.graphics.lineTo(100,100);
triangle.graphics.lineTo(0,100);
triangle.graphics.lineTo(50,0);
triangle.graphics.endFill();
triangle.x = 175;
triangle.y = 75;
addChildAt(triangle, getChildIndex(rectAndCircle));
// puts triangle BELOW rectAndCircle
triangle.addEventListener(MouseEvent.MOUSE_OVER,m);

function m(event:MouseEvent):void
{
setChildIndex(this, numChildren-1);
//doesn't work - 'this' is scoped to the holding object
}

var greeting_txt:TextField = new TextField();
greeting_txt.text = "hello world";
greeting_txt.x = 200;
greeting_txt.y = 300;
addChild(greeting_txt);
}
}
}



is what i've done possible? ie can i set a single mouseListener method (m in
my example) to be used by any of the sprites to move themselves to the front
of the display stack or would i have to write an explicit statement for each
one?

thanks for your time
a



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


--
No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.21.1/1300 - Release Date: 26-2-2008
19:50


No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.21.1/1300 - Release Date: 26-2-2008
19:50
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.21.1/1300 - Release Date: 26-2-2008
19:50
 

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