Actionscript 3.0 Scope Issue?

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.



Go Back   Webforumz.com > Main Forums > Design Your Website > Flash & Multimedia Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Nov 23rd, 2007, 14:09
Junior Member
Join Date: Jun 2004
Location: USA
Age: 25
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to DocBoy52 Send a message via AIM to DocBoy52 Send a message via Yahoo to DocBoy52
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?
Reply With Quote

Reply

Thread Tools

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

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

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


All times are GMT. The time now is 22:46.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43