This is a discussion on "Actionscript 3.0 Scope Issue?" within the Flash & Multimedia Forum section. This forum, and the thread "Actionscript 3.0 Scope Issue? are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
Actionscript 3.0 Scope Issue?
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Actionscript 3.0 Scope Issue?
Okay, so I have two classes. To give a better idea of what I am trying to do here - I am basically working on building a "scale" tool, to scale external graphics. Right now I am working on building the actual scale controller (which basically is a black rectangle, with 8 squares positioned around it (just like you would see in Fireworks, Flash, or Photoshop). That said... here is what I have:
Two classes - ScaleController.as, and ScaleHandle.as One Flash file - test1.fla The ScaleHandle class is basically a very small class that draws a 7x7 square on the screen. package { import flash.display.Shape; import flash.display.Sprite; public class ScaleHandle extends Sprite { public function ScaleHandle(xPos, yPos):void { var scaleHandle:Sprite = new Sprite(); scaleHandle.graphics.lineStyle(2, 0xFFFFFF, 1, true); scaleHandle.graphics.beginFill(0x000000); scaleHandle.graphics.drawRect(xPos, yPos, 7, 7); scaleHandle.graphics.endFill(); addChild(scaleHandle); } } } With that, my ScaleController class creates a containing sprite, and then 8 instances of these squares (so each one can independently control the scale point). var scaleContainer:Sprite = new Sprite(); scaleContainer.graphics.lineStyle(1, 0x000000, 1, true); scaleContainer.graphics.drawRect(0, 0, propWidth, propHeight); addChild(scaleContainer); var point1:ScaleHandle = new ScaleHandle(0, 0); var point2:ScaleHandle = new ScaleHandle(50, 50); var point3:ScaleHandle = new ScaleHandle(100, 100); scaleContainer.addChild(point1); scaleContainer.addChild(point2); scaleContainer.addChild(point3); My question is now.. can I add event listeners to each of these points?? I tried to do something like: scaleContainer.point3.addEventListener(); but that doesnt do anything, except produce an error. I am thinking that it's a scope issue. Anybody have any ideas? |
|
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| variable scope | Grape | JavaScript Forum | 2 | Jun 2nd, 2008 12:26 |
| a little actionscript | ziggi | Flash & Multimedia Forum | 0 | Sep 18th, 2007 11:46 |
| Actionscript within .NET | timshih | ASP.NET Forum | 0 | Aug 16th, 2007 00:56 |
| actionscript | cressy | Flash & Multimedia Forum | 3 | Jul 24th, 2007 07:29 |
| Actionscript 3.0 | Sgaspar11 | Flash & Multimedia Forum | 7 | May 28th, 2007 18:31 |