Re: [Flashcoders] addEventListener Problem

2010-03-01 Thread Todd Kerpelman
Flash is case-sensitive. Looks like your NavToURL in your addEventListener
call should really be navToURL

--T

On Mon, Mar 1, 2010 at 10:50 AM, Susan Day suzieprogram...@gmail.comwrote:

 Hi;
 I have the following code:

 function DisplayPicLoaded(evt:Event):void
 {
 var container:Sprite = new Sprite();
 var myXArray:Array = new Array(10,176,342,508,674,840);
 var loaderInfo:LoaderInfo = evt.target as LoaderInfo;
 var displayObject:DisplayObject = loaderInfo.content;
 displayObject.width = 150;
 displayObject.height = 150;
 displayObject.x = myXArray[countRounds];
 displayObject.y = 10;
 displayObject.filters = [createBevel()];
 container.addChild(displayObject);
 addChild(container);
 navPics.push(displayObject);
 container.addEventListener(MouseEvent.CLICK, NavToURL);
 if (countRounds  5)
 {
 countRounds++;
 init();
 }
 }

 function navToURL(e:Event):void
 {
 e.currentTarget.removeEventListener(MouseEvent.CLICK, navToURL);
 trace(e.currentTarget);
 trace('hi');
 }

 It throws the following error:

 1120: Access to undefined property NavToURL

 Why? What do?
 TIA,
 Susan
 ___
 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] targeting sprite

2010-02-25 Thread Todd Kerpelman
I'm not entirely sure what error you're getting, but if I were to take a
wild guess, I'd say the problem is that your sprite doesn't have enough
children for you to add anything at index 2.

For instance, if your sprite only had 1 child, it would occupy index 0 of
your sprite, meaning you'd only be allowed to add children at index 0 and 1.
(Don't forget that Flash starts counting at 0)

If you're looking to add a child to the top layer of your sprite, probably
the better way of doing this would be...

sparent.addChildAt(childSprite, sparent.numChildren - 1);

Good luck!

--Todd




On Thu, Feb 25, 2010 at 9:09 AM, Lehr, Theodore
ted_l...@federal.dell.comwrote:

 How would I do the following:

 function fname(sparent:Sprite) {
sparent.addChildAt(childSprite,2);
 }

 fname(spriteParent);

 It does not seem to like this
 ___
 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] Settiing the default format of TextFields in CS3

2010-01-04 Thread Todd Kerpelman
Hey, Flash Coders! Happy New Year!

Quick question for you guys: I work a lot with dynamic TextFields that I
design, format and lay out in the Flash CS3 authoring environment. The
problem I frequently run into is that when I go ahead and change the text of
these things in the code, most of the text formatting information is lost.

As a work-around, I've gotten into the habit of calling a function like this
in my constructors...

private function initTextFields():void
{
for each (var formatMe:TextField in [titleTxt, headerTxt, legalTxt,
storyTxt]) {
var tf:TextFormat = formatMe.getTextFormat();
formatMe.defaultTextFormat = tf;
}
}

This works, but I keep wondering if I'm doing unnecessary work. Is there any
kind of Keep the current formatting of any textfield I've created in the
authoring environment checkbox that I'm just missing somewhere?

Thanks!

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


Re: [Flashcoders] Settiing the default format of TextFields in CS3

2010-01-04 Thread Todd Kerpelman
Ahhh... You know, I hadn't considered the Style Sheet option. Maybe I'll
give that a try.

Thanks, guys!

--T



On Mon, Jan 4, 2010 at 1:43 PM, David Hunter davehunte...@hotmail.comwrote:


 same here, never found a solution other than reapplying the textformat to
 the field after any change. if you use a css style sheet instead i don't
 think you have to reapply it, although i think there are some limitations
 with them that i can't remember. not sure how you use embedded fonts with a
 css sheet either although i'm sure its possible.
 best,
 david

  Date: Mon, 4 Jan 2010 15:33:44 -0500
  Subject: Re: [Flashcoders] Settiing the default format of TextFields in
 CS3
  From: z...@zehfernando.com
  To: flashcoders@chattyfig.figleaf.com
 
  Not saying much, but: no normal workaround that I know. This is behavior
  that has been in Flash since the AS2 days - certain properties (like
  letterSpacing) are always lost with defaultTextFormat so you always need
 to
  set it again. I always used something similar to your code.
 
  Zeh
 
  On Mon, Jan 4, 2010 at 3:21 PM, Todd Kerpelman t...@kerp.net wrote:
 
   Hey, Flash Coders! Happy New Year!
  
   Quick question for you guys: I work a lot with dynamic TextFields that
 I
   design, format and lay out in the Flash CS3 authoring environment. The
   problem I frequently run into is that when I go ahead and change the
 text
   of
   these things in the code, most of the text formatting information is
 lost.
  
   As a work-around, I've gotten into the habit of calling a function like
   this
   in my constructors...
  
   private function initTextFields():void
   {
  for each (var formatMe:TextField in [titleTxt, headerTxt, legalTxt,
   storyTxt]) {
  var tf:TextFormat = formatMe.getTextFormat();
  formatMe.defaultTextFormat = tf;
  }
   }
  
   This works, but I keep wondering if I'm doing unnecessary work. Is
 there
   any
   kind of Keep the current formatting of any textfield I've created in
 the
   authoring environment checkbox that I'm just missing somewhere?
  
   Thanks!
  
   --Todd
   ___
   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

 _
 View your other email accounts from your Hotmail inbox. Add them now.

 http://clk.atdmt.com/UKM/go/186394592/direct/01/___
 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] array.indexOf problem

2009-06-16 Thread Todd Kerpelman
It sounds like your array is full of button objects, but you're
searching for a string (the button name), and an object and a string
don't match.

Remove the .name from the key you're searching for, and I believe it
should work.

-T



On 6/16/09, Isaac Alves isaacal...@gmail.com wrote:
 Hi fellows,
 Cannot solve this problem:

 function buttonClicked(e:Event):void {
  trace (buttonsArray.indexOf(e.target.name));

 It always  traces -1. This code should trace the index of the Array
 element right? for ex: 0, 1, 2 or 3.

 If i do this, it will trace the correct name of the element.

 function buttonClicked(e:Event):void {
  trace (e.target.name);

 If I do this, it will trace the name of the second element:

 function buttonClicked(e:Event):void {
  trace (buttonsArray[1].name);

 Why indexOf doesn´t work properly?

 Thanks a lot!
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


-- 
Sent from my mobile device

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


Re: [Flashcoders] Accessibility of a flash game

2009-04-20 Thread Todd Kerpelman
One element I can think of is to make sure your game is playable by
color-blind folks.

If you're making any kind of game where you have to match groups of
similarly-colored objects, for instance, make sure that there's a way to
tell these objects apart other than by color. (The gems in Bejeweled, for
instance all have different shapes.) Either that, or make sure the
saturation of these colors is different enough that you can still tell them
apart even if you're color blind. (One trick I've seen is to take a
screenshot of your game, stick it in Photoshop, turn it grayscale, and see
if you can still tell your objects apart.)

I've also encountered a few games that have a color-blind mode option.
Turning this mode on replaces your nicely-colored stones with stones that
have patterns on top of them. That's also another option you could try.

All of this is assuming, of course, that you have a game where telling
colors apart matters.

--T



On Mon, Apr 20, 2009 at 11:26 AM, Paul Steven paul_ste...@btinternet.comwrote:

 Thanks - I am not sure why they specified international as the game is
 aimed
 at the UK only.

 Whatever the region, can anyone give me a quick summary of what elements of
 a flash (flash player 6) game, one can affect with regards accessibility?
 Does this relate primarily to any textual content?

 Thanks

 Paul

 -Original Message-
 From: flashcoders-boun...@chattyfig.figleaf.com
 [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Paul
 Andrews
 Sent: 20 April 2009 18:24
 To: Flash Coders List
 Subject: Re: [Flashcoders] Accessibility of a flash game

 - Original Message -
 From: Kerry Thompson al...@cyberiantiger.biz
 To: 'Flash Coders List' flashcoders@chattyfig.figleaf.com
 Sent: Monday, April 20, 2009 6:05 PM
 Subject: RE: [Flashcoders] Accessibility of a flash game


  Paul Steven wrote:
 
  I am making a game and have been asked by the client to ensure The game
  should meet all international accessibility requirements
 
 Ack!!
 
  All international accessibility requirements? Your client is out of his
  mind. How can you possibly know, much less meet, so broad, varied, and
  sometimes contradictory a set of standards? Even in the U.S., you can
 meet
  federal standards, but fail to meet some state requirements.
 
  I would go back to the client and choose a country that has a
 well-defined
  set of requirements, and meet those. Hopefully, the country you live in
  has
  a reasonably clear set of requirements. Most of the G-20 countries do.

 I think I'd ask the client to specify the standards they want supported.

 Paul
 
  Cordially,
 
  Kerry Thompson
 
  ___
  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] Favorite Flex book?

2009-04-16 Thread Todd Kerpelman
By the way, in case anybody was wondering, I ended up picking up the
O'Reilly Flex Cookbook over the Training From the Source one, primarily
because the O'Reilly site had a very simple Buy the PDF option. (It's a
little easier to read and code on the train if I can just have everything on
my laptop.) Somebody oughta tell these Adobe folks about this .pdf format
I've been hearing so much about. I bet they'd like it!

--T


On Wed, Apr 15, 2009 at 2:29 AM, Paul Andrews p...@ipauland.com wrote:

 I think one of the things that will determine whether you like Flex
 training from the source, is whether you want a book you can just read and
 later pick up and thumb through a section. Flex training from the source is
 arranged more as a series of hands-on exercises where the reader is told how
 to follow through on a computer and any discussion is based on the practical
 work done. It's not so much a Pick me up and dip into me type of book
 because so much of the content is centred around actively sitting at a
 computer doing the exercises. It would make a poor reference but is strong
 at hands-on. Very much a doing book.

 Paul
 ___
 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] Favorite Flex book?

2009-04-14 Thread Todd Kerpelman
Hey, guys.

So at this point I feel like I've got a pretty good handle on AS3, but I'd
like to get some experience with more Flex-specific development. Is there a
favorite book that people have of the various ones that are out there?
Ideally, I'd like to find one that spends less time rehashing ActionScript
and a little more time focusing on what's new or different in Flex.

(On a side note, are there people out there who are successfully using
FlashDevelop with the FlexDesignView plugin for real development? Or should
I lay down the cash for FlexBuilder?)

Thanks!

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


Re: [Flashcoders] point in a circle

2009-04-09 Thread Todd Kerpelman
x = Math.cos(angle) *  radius
y = Math.sin(angle) * radius

Keep in mind the angle here needs to be in radians. If your angle is in
degrees, multiply it by 180 / Math.PI.

Also keep in mind the x and y values you get here will be relative to the
circle's center.

--T


On Thu, Apr 9, 2009 at 11:02 AM, Fabio Pinatti fpina...@gmail.com wrote:

 Hello list,

 since I ran from math classes, I have a question that I'm almost sure it's
 not hard to solve, but I don't know how to. I put a image at
 http://pinatti.com.br/circle.jpg, where it's a circle with red dots. I
 need
 to compute red dots's x/y position. The data I have is the angle that I
 increment (in this case 45º each round), and the distance (the hypotenuse,
 right?).

 Any ideas for this math?

 Thanks in advance..

 --
 Fabio Pinatti
 :: web.developer
  www.pinatti.com.br
 :: 19. 9184.3745 / 3342.1130
 ___
 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] Lint for ActionScript?

2009-03-05 Thread Todd Kerpelman
Hey, guys.

Anybody have any decent Lint-like tools that they've been using for
ActionScript? Google hasn't given me anything very useful, except the
recommendation that a Lint tool for JavaScript might work, which I'm kinda
skeptical about.

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


[Flashcoders] Either an incredibly easy or incredibly difficult problem

2009-02-09 Thread Todd Kerpelman
Hey, coders!

I have a Sprite that consists of a polygon that I drew in Flash (using the
line tool) and saved into my Library.

Using ActionScript, is there any way to easily find the points of said
polygon? It seems like I oughta be able to dig up those line coordinates out
of my Sprite.graphics object, but I can't seem to find a way of doing it...

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


[Flashcoders] Best way to access my main class?

2009-02-05 Thread Todd Kerpelman
Hey, FlashCoders.

I'm wondering if you can help me out with a general style question that I
keep running into. Let's say I've got a setup like this...

class MyGame extends MovieClip
   - It creates a camera sprite that I can add children into
   - It then creates a Bouncing Ball object with the camera sprite as
the parent to use.

class BouncingBall
{
public function BouncingBall(parentToUse:DisplayObjectContainer)
   {
 // Create member variable _mySprite:Sprite and add it to my parentToUse
 //...
   }
}

For reasons I won't get into unless you're really interested, BouncingBall
does NOT extend Sprite, it simply contains a sprite.

So MyGame has a camera as a child. That camera has my bouncingBall._mySprite
as a child.

The question is this: I want the BouncingBall sprite to occasionally call a
function in MyGame. What's the best way to do this?

*Option 1:* Within BouncingBall, just call...

 MyGame(_mySprite.root).foo(_myVar);

This works, but it strikes me as a little unnatural, since I have to dig
into my member variable and get its root. Also, I'm not sure this works if
my game were to be imported by some larger, wrapper class.

*Option 2: *My constructor for BouncingBall should contain two variables

public function BouncingBall (var parentToUse:DisplayObjectContainer, var
gameApplication:MyGame)

I store gameApplication as a member variable, and use it later...

_myGame.foo(_myVar);

This is my current solution, but the idea of passing a parent and the game
application to the constructor strikes me as slightly redundant, and, like
Option 1, it tightly couples my BouncingBall object to my main application.

*Option 3:* I create a custom event, dispatch that event, and create a
listener in MyGame rather than call a function directly.

I'm guessing this is the best way to go theoretically, and will allow me to
reuse my BouncingBall object in other applications, but it's a lot of extra
code, and I constantly worry about not property cleaning up event listeners.


I'm sure all of you have encountered this situation before. So what do you
generally do? Is there a fourth, totally obvious option that I'm
overlooking?

Thanks!

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


Re: [Flashcoders] Best way to access my main class?

2009-02-05 Thread Todd Kerpelman
Thanks, everybody!

Sounds like creating custom events is the way to go (and yes, it's for Send
an alert of some kind to MyGame kind of functionality). I don't have a lot
of experience with 'em, so I was probably going through more trouble to
avoid them than would actually be required to just suck it up and do things
the right way. :)

--T



On Thu, Feb 5, 2009 at 11:31 AM, Merrill, Jason 
jason.merr...@bankofamerica.com wrote:

 Yes - just turn event bubbling on - then any DisplayObject like sprite or
 movie clip will pass the event up the display list.


 Jason Merrill
 Bank of America Instructional Technology  Media   ·   Learning
 Performance Solutions LLD

 Interested in Flash Platform technologies?  Join the Bank of America Flash
 Platform 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: Thursday, February 05, 2009 2:15 PM
 To: Flash Coders List
 Subject: RE: [Flashcoders] Best way to access my main class?

 This brings up a question I had about events.  Is there a way to send an
 event all the way to the document class, no matter where it's been
 dispatched from?  For instance, I have a document class that creates a
 menu class, which creates several icon button classes.  I want the
 document class to be able to receive the event dispatched from the icon
 button.  Currently, the only way I know how to do it is have the icon
 button send it to the menu and then the menu send it to the document.
  So, my question is, can the document class receive an event directly sent
 from the icon button?

 Thanks,
 Ross

 -Original Message-
 From: flashcoders-boun...@chattyfig.figleaf.com [mailto:
 flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Merrill, Jason
 Sent: Thursday, February 05, 2009 1:03 PM
 To: Flash Coders List
 Subject: RE: [Flashcoders] Best way to access my main class?

 *Option 3:* I create a custom event, dispatch that event, and create a
 listener in MyGame rather than call a function directly.
 I'm guessing this is the best way to go theoretically, and will allow me
 to
 reuse my BouncingBall object in other applications, but it's a lot of
 extra
 code, and I constantly worry about not property cleaning up event
 listeners.


 Hands down, your option 3 is what you should do.  So what if it's some
 extra code? It's the right way to accomplish this.  Your object should not
 target and call methods in other classes outside of it, that's extremely
 tight coupling, which is bad.

 So have your bouncing ball sprite dispatch a custom event, have the other
 class listen for that same custom event and do whatever logic you want, like
 call another method.  It's not messy if you keep your code clean.  It just
 takes practice of doing this a lot before you realize an architecture
 emerges in your coding you are familiar with.  I think its even messier to
 do option 1 or 2, if that makes you feel any better.


 Jason Merrill
 Bank of America Instructional Technology  Media   ·   Learning
 Performance Solutions LLD

 Interested in Flash Platform technologies?  Join the Bank of America Flash
 Platform 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

 ___
 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] Missing Flashcoder archives?

2009-01-29 Thread Todd Kerpelman
Hey, List folks!

So in the interest of Not trying to repost too many questions that have
already been asked (like, for example, probably this one) I've been trying
to search the Flash Coders List archives. However, going to the archives
page over at figleaf.com (
http://chattyfig.figleaf.com/mailman/private/flashcoders/) brings me to a
page where nothing has been added since December 2007.

Is there a new location where our mail is being stored, or is the archive
page just not working?

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


Re: [Flashcoders] Missing Flashcoder archives?

2009-01-29 Thread Todd Kerpelman
Cool. Thanks, all!

Now I can finally add all of those Plaxo contacts and find out who to
contact at masterkitchen.de when Johannes is not available to answer my
mail. :)

--T


On Thu, Jan 29, 2009 at 9:28 AM, Muzak p.ginnebe...@telenet.be wrote:

 Try using the mail-archive site:
 http://www.mail-archive.com/flashcoders@chattyfig.figleaf.com/



 - Original Message - From: Todd Kerpelman t...@kerp.net
 To: Flash Coders List flashcoders@chattyfig.figleaf.com
 Sent: Thursday, January 29, 2009 5:56 PM
 Subject: [Flashcoders] Missing Flashcoder archives?


  Hey, List folks!

 So in the interest of Not trying to repost too many questions that have
 already been asked (like, for example, probably this one) I've been
 trying
 to search the Flash Coders List archives. However, going to the archives
 page over at figleaf.com (
 http://chattyfig.figleaf.com/mailman/private/flashcoders/) brings me to a
 page where nothing has been added since December 2007.

 Is there a new location where our mail is being stored, or is the archive
 page just not working?

 --T
 ___


 ___
 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] Error Instantiating Object

2009-01-27 Thread Todd Kerpelman
Hmmm... what's the rest of the Slide constructor? It sounds like maybe
that's where the error is...

Also, if you try running your Flash file in debug mode (Hit
Ctrl-Shift-Enter), the debugger will take control at the moment when you're
trying to access a null object, which usually helps you figure out what's
causing these kinds of problems.

--T


On Tue, Jan 27, 2009 at 4:40 PM, K-Dawg kdaw...@gmail.com wrote:

 Hello,

 I am new to Action Script 3.  I am used to Java, Perl,  Python.  I am
 receiving the following error:

 TypeError: Error #1009: Cannot access a property or method of a null object
 reference.
at Slide$iinit()
at PondoShow$iinit()

 All I have a PondShow class that extends Sprite.  then I have a Slide
 class.  I am trying to instantiate an array for Slide objects.

import flash.display.Sprite;
import flash.events.*;
import flash.text.*;
import flash.net.URLRequest;
import flash.utils.*;

public class PondoShow extends Sprite {
private var slides:Array;
private var slideCounter:int;
private var myTimer:Timer;

public function PondoShow() {
myTimer = new Timer(3000);
slides = new Array(4);
slides[0] = new Slide(This is a test, this is only a test,
 img/food_array.jpg, Click here to find out more, more.html, 100, 100,
 50, 50, 200, 200);
slides[1] = new Slide(This is a test, this is only a test,
 img/food_array2.jpg, Click here to find out more, more.html, 100,
 100,
 50, 50, 200, 200);
slides[2] = new Slide(This is a test, this is only a test,
 img/food_array3.jpg, Click here to find out more, more.html, 100,
 100,
 50, 50, 200, 200);
slides[3] = new Slide(This is a test, this is only a test,
 img/get_it_to_go_logo.jpg, Click here to find out more, more.html,
 100, 100, 50, 50, 200, 200);
slideCounter = 0;
trace(before adding slides);
while(true) {
if (slides[slideCounter].imgload) {
addChild(slides[slideCounter].loader.content);
break;
}
}

 Error occurs when instantiating the first Slide object.  It also fails when
 I do not use an array and all I do is try to create a single object.

 My slide class has a constructor:

public function Slide(primaryText:String, secondaryText:String,
 imagePathString:String, slideLinkText:String, slideLink:String,
 primaryTextX:int, primaryTextY:int, secondaryTextX:int, secondaryTextY:int,
 linkX:int, linkY:int) {

 Thanks for any help.  I am new to AS 3.

 Kevin
 ___
 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] top down plane games

2009-01-26 Thread Todd Kerpelman
Well, again, don't know how much this will help you, but in the past when
I've done a camera following a moving object with a scrolling background,
I've attached a virtual spring from my camera to the position I want to go
to and then just let the spring drag my camera to the right place. If you
put on some pretty heavy damping, it ends up looking pretty good, and I
don't have to think about angles. :)

Your spring code would probably look something like this...

private function onEnterFrame(e:Event):void
{

var accelX:Number = (_pointToFollow.x - this.x) * _k;
var accelY:Number = (_pointToFollow.y - this.y) * _k;
_velX += accelX;
_velY += accelY;
this.x += _velX;
this.y += _velY;
_velX *= _damping;
_velY *= _damping;

}

You probably want _k to be something in the .1 range, and _damping to be in
the .75 range. All of this assumes, by the way, that you're not rotating the
camera to match the rotation of the plane.

But the book Jason recommended might have better ideas. I haven't read it
yet.

--T



On Sun, Jan 25, 2009 at 1:15 PM, Corban Baxter corb...@gmail.com wrote:

 thanks todd. thats what I have been doing for the most part. I'm
 working on figuring out how to move the Camera sprite around on an
 angle.

 i've got script that makes the airplane point towards the mouse at all
 times. but thats the easy part. now i need the Camera sprite to move
 at a consistent rate at the same angle the plane is pointing. Just
 can't see to figure out what it take to do that.

 var minXMove:Number = 0;
 var minYMove:Number = 0;
 var maxXMove:Number = (levelMap.width - stage.stageWidth) * -1;
 var maxYMove:Number = (levelMap.height - stage.stageHeight) * -1;

 stage.addEventListener(Event.ENTER_FRAME, pointAtCursor);

 function movemap():void {


//move on x-axis
levelMap.x += speedX;

if (levelMap.x = minXMove) {
levelMap.x = minXMove;
}
if (levelMap.x = maxXMove) {
levelMap.x = maxXMove;
}


//move on y-axis
levelMap.y += speedY;

if (levelMap.y = minYMove) {
levelMap.y = minYMove;
}
if (levelMap.y = maxYMove) {
levelMap.y = maxYMove;
}
 }

 function pointAtCursor(e:Event) {

// get relative mouse location
var dx:Number = mouseX - plane.x;
var dy:Number = mouseY - plane.y;
speedX = (dx * -1);
speedY = (dy * -1);

// determine angle, convert to degrees
var cursorAngle:Number = Math.atan2(dy,dx);
var cursorDegrees:Number = 360*(cursorAngle/(2*Math.PI));

// point at cursor
plane.rotation = cursorDegrees;

plane.x -= (plane.x-mouseX) / 6;
plane.y -= (plane.y-mouseY) / 6;

movemap();

 }

 the hard part is getting the speedX and speedY to be numbers that
 don't cause the map to fly to fast. Just not sure where to go from
 here.




 On Sun, Jan 25, 2009 at 2:42 PM, Todd Kerpelman t...@kerp.net wrote:
  Well, I'm no plane game expert, but here's probably how I'd approach
 it...
 
  Within your PlaneGame movie, create a child sprite called Camera.
 
  Make all your interface stuff children of the PlaneGame movie. But make
 the
  background, your plane, the enemies, etc, all children of this Camera
 child
  sprite.
 
  Then, when it comes to creating the background scrolling below you
 look,
  don't have your background move at all. Only have the things that would
  actually move in real life (planes and tanks and whatever) move.
 
  Instead, make your Camera sprite scale and/or move itself to track your
  plane (or, even better, a point a couple hundred pixels in front of your
  plane.) That will make it look like the background is moving, but it's
  really staying in place. And it will simplify your planes and tanks and
  bullets, because you can basically just look at each sprite's position
 and
  velocity, without having to try and somehow compensate for a magical
 moving
  background.
 
  For development purposes, by the way, I would start your game by not
 having
  the camera move at all, and just making sure everything works right in a
  tiny little world the size of your screen. Once that's working, then you
 can
  enlarge the bounds of your world and start moving your camera around.
 
  Good luck!
 
  --T
 
 
 
  On Sun, Jan 25, 2009 at 11:16 AM, Corban Baxter corb...@gmail.com
 wrote:
 
  hey guys! I'm trying to build a simplified version of
  http://www.miniclip.com/games/skies-of-war/en/. Mostly looking to
  replicated the movement. But I have no ideas on where to start. I'm
  having alot of trouble setting the angles correctly to give the
  background a constant speed but allowing it to change angles. I
  understand its going to be based on the planes current angle. But
  that's where I get confused on getting the speeds to not over lap and
  making it seem like it moving faster. Ok I'm rambling now. but I was
  hoping someone might be able

Re: [Flashcoders] top down plane games

2009-01-25 Thread Todd Kerpelman
Well, I'm no plane game expert, but here's probably how I'd approach it...

Within your PlaneGame movie, create a child sprite called Camera.

Make all your interface stuff children of the PlaneGame movie. But make the
background, your plane, the enemies, etc, all children of this Camera child
sprite.

Then, when it comes to creating the background scrolling below you look,
don't have your background move at all. Only have the things that would
actually move in real life (planes and tanks and whatever) move.

Instead, make your Camera sprite scale and/or move itself to track your
plane (or, even better, a point a couple hundred pixels in front of your
plane.) That will make it look like the background is moving, but it's
really staying in place. And it will simplify your planes and tanks and
bullets, because you can basically just look at each sprite's position and
velocity, without having to try and somehow compensate for a magical moving
background.

For development purposes, by the way, I would start your game by not having
the camera move at all, and just making sure everything works right in a
tiny little world the size of your screen. Once that's working, then you can
enlarge the bounds of your world and start moving your camera around.

Good luck!

--T



On Sun, Jan 25, 2009 at 11:16 AM, Corban Baxter corb...@gmail.com wrote:

 hey guys! I'm trying to build a simplified version of
 http://www.miniclip.com/games/skies-of-war/en/. Mostly looking to
 replicated the movement. But I have no ideas on where to start. I'm
 having alot of trouble setting the angles correctly to give the
 background a constant speed but allowing it to change angles. I
 understand its going to be based on the planes current angle. But
 that's where I get confused on getting the speeds to not over lap and
 making it seem like it moving faster. Ok I'm rambling now. but I was
 hoping someone might be able to help me understand this better and
 give me some examples I could use to get moving. Any help would be
 great! thanks!

 --
 Corban Baxter
 http://www.projectx4.com
 ___
 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] Partially drawing a graphic?

2009-01-12 Thread Todd Kerpelman
Hey, Flash Coders! Wondering if you can help me out with a little problem
I'm working on...

- I have a complicated piece of vector art in my Flash file.

- I'm basically trying to find a way to partially draw it. That is, out of
the 2000 curves that are in my piece of art, I'd like to randomly draw 50%
of them, and then people can guess what the original piece of art was.

- Speed and elegant coding aren't a primary concern here. It's just a
prototype.

Any ideas of how to do this?

I was hoping I could find some sort of function that would let me iterate
through each curve in my original piece of art, and then I could randomly
decide whether or not to draw each curve into a new graphic, but I can't
seem to find anything like that. If anybody has any clever suggestions, I'd
love to hear 'em...

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


Re: [Flashcoders] Partially drawing a graphic?

2009-01-12 Thread Todd Kerpelman
Hmmm... well, for the record, my art is currently just stored as a plain ol'
Graphic in my Flash IDE library (after tracing it from a bitmap) although I
can convert it to other formats if need be. I was hoping Flash had some way
of getting at the vector data, given that it's storing it internally
already.

In any case, I'm not working in Flex at the moment, so Defraga doesn't seem
like it would help this current project, but you're right; it definitely
looks cool...


--T


On Mon, Jan 12, 2009 at 4:57 PM, Nate Beck n...@tldstudio.com wrote:

 A big issue here is that you need a format that can be parsed at runtime.
  Which I'm quickly finding out is not all that easy to do with the new
 Adobe
 Format... FXG. :(
 I'm writing a tile based game right now, and I want to store my tile
 library
 in a runtime-loadable format, like FXG or degrafa... It's not working so
 well. :/



 On Mon, Jan 12, 2009 at 4:38 PM, Joel Stransky stranskydes...@gmail.com
 wrote:

  something I've always wanted to try is write a script for Illustrator
 that
  would output all of the path info including bezier handles to a text file
  for use in flash.
 
  Maybe there's something in the api that will help.
 
 
 http://partners.adobe.com/public/developer/en/illustrator/sdk/AIJavaScriptReference.pdf
 
  On Mon, Jan 12, 2009 at 7:04 PM, Nate Beck n...@tldstudio.com wrote:
 
   How are you storing the vector art?
   You need a way to parse out the data so that you can choose which lines
  to
   draw. Degrafa is an excellent way to go. http://www.degrafa.org/
  
   I don't know Degrafa well enough to tell you if there is something
  already
   in there that will make what you're trying to accomplish easier.
  
   Also, something that comes to my mind to watch out for... would be to
  move
   the graphics drawing head to the correct place before drawing the
 next
   curve.  Think if it like an Etch-a-sketch, you need to pick up the head
  and
   move it somewhere else before you continue to draw, or else it's going
 to
   continue drawing from where you left off.
   HTH,
   Nate
  
  
  
   On Mon, Jan 12, 2009 at 3:53 PM, Todd Kerpelman t...@kerp.net wrote:
  
Hey, Flash Coders! Wondering if you can help me out with a little
  problem
I'm working on...
   
- I have a complicated piece of vector art in my Flash file.
   
- I'm basically trying to find a way to partially draw it. That is,
  out
of
the 2000 curves that are in my piece of art, I'd like to randomly
 draw
   50%
of them, and then people can guess what the original piece of art
 was.
   
- Speed and elegant coding aren't a primary concern here. It's just a
prototype.
   
Any ideas of how to do this?
   
I was hoping I could find some sort of function that would let me
  iterate
through each curve in my original piece of art, and then I could
  randomly
decide whether or not to draw each curve into a new graphic, but I
  can't
seem to find anything like that. If anybody has any clever
 suggestions,
   I'd
love to hear 'em...
   
--T
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
   
  
  
  
   --
  
   Cheers,
   Nate
   
   http://blog.natebeck.net
   ___
   Flashcoders mailing list
   Flashcoders@chattyfig.figleaf.com
   http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  
 
 
 
  --
  --Joel Stransky
  stranskydesign.com
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 



 --

 Cheers,
 Nate
 
 http://blog.natebeck.net
 ___
 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] Dictionary resource for word based games

2009-01-09 Thread Todd Kerpelman
You can try the ENABLE word list. It's open source, made for Scrabble-like
word games and therefore doesn't contain a lot of proper nouns or other
illegal words.

There's a link to it here... http://www.crosswordman.com/wordlist.html

--Todd, who still thinks that zen should be a legal word


On Fri, Jan 9, 2009 at 9:26 AM, Anthony Pace anthony.p...@utoronto.cawrote:

 Do you just need a list of words or do you need their definitions too?


 Mark Winterhalder wrote:

 On Fri, Jan 9, 2009 at 11:25 AM, Paul Steven paul_ste...@btinternet.com
 wrote:


 Can anyone point me in
 the direction of where to acquire an electronic version of the English
 dictionary that is easily incorporated into my game?



 Sure: http://download.wikimedia.org/enwiktionary/latest/
 It's under the GNU Free Documentation License, not sure how that
 applies to what you're trying to do. In any case, as all the other
 Wikimedia/Wikipedia projects, it's an interesting dataset.

 HTH,
 Mark
 ___
 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] use get / set functions or make your own

2008-12-09 Thread Todd Kerpelman
I think the Control-Shift-1 functionality is fairly new -- I only got it
working after I upgraded FD to Beta 9. But yes, it rocks. You can also use
it on your implements Interface text to generate placeholder functions
for everything in that interface. Try it!

Personally, I tend to use getters and setters only when I'm making a class
that primarily functions like a Perl hash (or a Python dictionary or
whatever the kids are using these days). If I use it to much with other
classes, I start to worry that I've created public variables when I
shouldn't have, and it constantly distracts me.

--T


On Tue, Dec 9, 2008 at 8:44 AM, Joel Stransky [EMAIL PROTECTED]wrote:

 Wow I didn't know that about FD. Gonna have to start using it. I still find
 myself wanting to use Flex Dev but that's another thread.

 It's nice to see discussions like this. I feel like some things are
 foregone
 conclusions and that I'm late to the part but hey, even Grant Skinner is
 blogging about cuddling
 braceshttp://www.gskinner.com/blog/archives/2008/11/curly_braces_to.html
 .


 For me, it depends on the complexity of the logic involved in calculating
 the return. If I'm dealing with a sensible property such as the left
 boundary for a group of display children, conditionals tend to read cleaner
 when I can just write:
 if(this.mouseX  grid.left) rather than if(this.mouseX  grid.getLeft()).
 If
 the property requires more complex code in order to return a value such as
 looping over an array, I use getVal().

 getters and setters also have certain syntax requirements so I also avoid
 using them whenever I need to do something slightly different such as use
 multiple parameters.

 On Tue, Dec 9, 2008 at 10:18 AM, Cor [EMAIL PROTECTED] wrote:

  When you open the Startpage of FD you find some more shortcuts.
  HTH
  Cor
 
  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf Of Ian
 Thomas
  Sent: dinsdag 9 december 2008 16:14
  To: Flash Coders List
  Subject: Re: [Flashcoders] use get / set functions or make your own
 
  Ooh - never knew about that. :-)
 
  You learn something every day!
 
  Ian
 
  On Tue, Dec 9, 2008 at 2:40 PM, jonathan howe [EMAIL PROTECTED]
  wrote:
   The magic Context code completion hotkey, which by default is
  Ctrl-Shift-1,
   when your cursor is over a variable declaration.
   This awesome hotkey also does cool stuff like generates an event
 handler
   when your cursor is inside an addEventListener declaration...
 definitely
   check it out in the FD docs!
  
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
  No virus found in this incoming message.
  Checked by AVG - http://www.avg.com
  Version: 8.0.176 / Virus Database: 270.9.15/1839 - Release Date:
 9-12-2008
  9:59
 
  ___
  Flashcoders mailing list
  Flashcoders@chattyfig.figleaf.com
  http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 



 --
 --Joel Stransky
 stranskydesign.com
 ___
 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] Audio lag on KeyboardEvent.KEY_DOWN

2008-12-08 Thread Todd Kerpelman
I'm actually running into a very similar problem trying to create my little
flash-based drum machine. I've got a 100 ms .wav that I'm trying to play on
a regular basis and no matter what I try, it comes out sounding weird and
erratic. I was hoping there was some magic Here's how you compress and/or
pre-load the sound so that it plays instantly trick that I was missing.

I've done several tests -- from playing the sound every x frames, to playing
the sound every x ms, to keeping two identical copies of the same sound and
alternating between them, but nothing seems to help much.

I'd be glad to share some test code if anybody's interested in trying this
at home, but it sounds like maybe the problem is Flash's and not mine. Maybe
I'll put together some hacked-together timeline solution and see if that
helps at all...

CB, when this is all over, your piano and my drummer can jam.

--T





On Mon, Dec 8, 2008 at 10:13 AM, Olivier Besson [EMAIL PROTECTED] wrote:

 Hi,
 a colleague of mine noticed the same problem with attached sounds in as3.
 He had to start music loops simultaneously and it turn out impossible by
 actionscript alone, because of a random lag.

 The only solution he found was to launch the sounds in the same keyframe in
 the timeline.
 Perhaps a timeline-based solution of your problem is possible: for example
 using the keys to controls movieClips with different labels (each label
 having one sound), and using updateAfterEvent as advised previsously. Or,
 one clip per sound.
 If it solves your problem, you can still control the volume of an
 IDE-specfied sound by using the soundChannel property of movieClips.

  Olivier


 jonathan howe a écrit :

  That part was actually confusticate's and I do believe that he was
 implying
 that the sounds had load() called prior to the KeyboardEvent, and the
 latency happens on the 100th keystroke as well as the first.

 By way of comparison, I had the same problem in sounds attached from the
 library.

 I wonder if it would make a difference if new Sound objects (in AS2) or
 SoundChannels (in AS3) were or weren't instantiated every time.
 On Mon, Dec 8, 2008 at 4:49 PM, Sidney de Koning [EMAIL PROTECTED]
 wrote:



 Hi Jonathan,

 You say: The sounds are MP3s which are load()ed into Sound objects on
 init().
 Does this mean you preload the sounds? If so;  If you press a key before
 the whole sound is loaded in it takes some time to play it, because it is
 still loading. You can make sure of this by showing the application AFTER
 all the sounds are loaded in, this can be done by creating a loader que
 (place items in an array after they are loaded and check if the total
 amount
 of items loaded in is equal to the array length).
 This way you always know that nothing shows up before all the sounds are
 loaded.

 Hope this helps you,

 Sid


 On Dec 8, 2008, at 4:31 PM, jonathan howe wrote:

 I'm very interested in the solution to this. I notice it on certain


 machines
 and not others... it does not seem to have anything to do with the input
 part, and in some cases can stutter the display updating. For example,
 if
 you were to have a timer trigger the sound and print something at the
 screen, they would both 'appear' at the same time but if you also
 measured
 the time difference between the trigger's execution and after the sound
 call, there would be latency.

 The superstitious/uneducated part of me supposes that Flash is
 establishing
 a modal call to the sound card, and some perform cards respond faster
 than
 others.
 -jonathan


 On Mon, Dec 8, 2008 at 2:37 PM, allandt bik-elliott (thefieldcomic.com)
 
 [EMAIL PROTECTED] wrote:

 did you use updateAfterEvent() to force it to play immediately? if not,
 it


 might be waiting for the next frame to process the event

 On Mon, Dec 8, 2008 at 12:14 PM, [EMAIL PROTECTED] 
 [EMAIL PROTECTED] wrote:

 Hi List,


 I'm dipping my toe into AS3 and thought I'd play around with sound by
 making
 a little piano keyboard which is played by pressing keys on the



 computer



 keyboard.

 It works - the appropriate sounds play on KeyboardEvent.KEY_DOWN -



 however,



 I've noticed that there is often a lag between the keyboard event and
 the
 actual sound playing. The occurrence of the lag seems pretty random.

 The sounds are MP3s which are load()ed into Sound objects on init().
 On
 KeyboardEvent.KEY_DOWN, the appropriate Sound is play()ed.

 I've checked all the MP3s, and they don't have extra silence at the
 beginning. I don't think it has to do with the number of MP3s involved
 (14),
 because I noticed the lag even when I was testing it out with 2
 sounds.

 Has anyone dealt with this before, and know what the problem might be?



 You



 can see (or rather, hear) the lag for yourself here:
 http://snipurl.com/7ndr2-meep

 Thanks!

 In hope,
 CB.
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 

Re: [Flashcoders] Re: adding physics to pivot object around a point

2008-12-01 Thread Todd Kerpelman
Well, I know you could do something like this very easily using a physics
engine like Box2D (http://box2dflash.sourceforge.net/), but the very
easily part only kicks in after you spend several hours converting your
entire application to using a third party physics engine.

If you're just trying to do some more basic faux-gravity rotation, there's
probably simpler ways of doing it. If I were gonna fake it and I had a
simple shape like a rectangle to work with, I might esimate what portion of
the sprite was to the left and the right of my cursor, use that to apply a
little force to some internal _angularVelocity variable, and then combine
that with the MatrixTransfrmer.rotateAroundInternalPoint method to rotate my
object around the mouse cursor. But I can't promise you that'll necessarily
look any good, though. That's just a guess.

--T


On Mon, Dec 1, 2008 at 10:12 AM, allandt bik-elliott (thefieldcomic.com) 
[EMAIL PROTECTED] wrote:

 So I guess what i'm trying to get at is that I'd like to apply gravity and
 momentum to an objects angle rather than directly to their y axis

 anyone have any ideas?

 thanks
 a

 --


 hi guys

 could anyone point me in the right direction to do the following, please?

 I'd like an object that is dragged to correctly respond to being pulled
 around by pivoting around the point it is dragged by (also applying
 downward
 force to represent gravity)

 for example, if i hold a pencil lightly at one end, it will pivot around
 the
 point i am holding and swing until it comes to a rest pointing straight
 down.

 does anyone know of any tutorials that go into this kind of thing?

 thanks for your help
 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] singleton returns null

2008-11-21 Thread Todd Kerpelman
Hmmm... I'm not sure I can pinpoint exactly where the problem is in your
code. But there is some weirdness there around where and how that _instance
variable of yours is getting instantiated. It seems like there's nothing to
enforce it only gets created once or doesn't get overwritten multiple times
by different SecondClass object.

What I can do is give you some sample code (totally stolen, incidentally
from Advanced ActionScript 3 with Design Patterns by Joey Lott) that works
for me...

package  {

public class MySingletonThing {

private static var _instance:MySingletonThing


public function MySingletonThing() {
// Initialize functions can go here...
}

public static function getInstance():MySingletonThing {
if (MySingletonThing ._instance == null) {
MySingletonThing ._instance = new MySingletonThing ();
}

return MySingletonThing ._instance;
}

  }

}

...which you can then call from anywhere using code like...

var foo:MySingletonThing = MySingletonThing.getInstance();


...actually, that's a little too oversimplified. I also include a little
SingletonEnforcer class that helps to ensure somebody doesn't incorrectly
call new MySingletonThing() outside of that class...


package  {

public class MySingletonThing {

private static var _instance:MySingletonThing


public function MySingletonThing(enforcer:SingletonEnforcer) {
// Initialize functions can go here...
}

public static function getInstance():MySingletonThing {
if (MySingletonThing ._instance == null) {
MySingletonThing ._instance = new MySingletonThing
(enforcer:SingletonEnforcer);
}

return MySingletonThing ._instance;
}

  }

}

// Really important! Make sure you include this SingletonEnforcer class in
your MySingletonThing.as file
class SingletonEnforcer{};


Hope this helps...

--T



On Fri, Nov 21, 2008 at 9:49 AM, Fabio Pinatti [EMAIL PROTECTED] wrote:

 Sure thing!

 In my main document class, I have

 class BaseClass {

   public function BaseClass() {

   }

 }


 I have a second document class, that is loaded inside the first one.

 class SecondClass {

   public static var  _instance:SecondClass;

   public function SecondClass() {
 _instance = this;
}

public static function getInstance():SecondClass {
  return _instance;
}


 }

 and my third document class, that is a movie loaded inside that same
 document as above.

 class ThirdClass {

   public function ThirdClass() {
 trace (SecondClass.getInstance());
}


 }

 In Gaia, these 3 classes are respectively Main.as, Nav.as and HomePage.as.
 In that sample I wrote, the output is null. If I declare in my base class,
 something like private var _it:SecondClass, even I didn't init that var,
 and
 compile the app again, magically, it outputs rightly my class instance. The
 weird thing is, for example, If I try the same getInstance() from
 BaseClass,
 for example, it returns correctly too. Im wondering why some classes you
 can
 get instance, and for other, you must declare a var, like my workaround...

 Thats weird, no??

 Thanks,

 Pinatti

 On Fri, Nov 21, 2008 at 12:39 PM, Hans Wichman 
 [EMAIL PROTECTED] wrote:

  Hi Fabio,
 
  could you maybe post 2 examples, one that works, and one that doesn't?
  A picture says more than a thousand words:)
 
  greetz
  JC
 
  On Fri, Nov 21, 2008 at 2:19 PM, Fabio Pinatti [EMAIL PROTECTED]
 wrote:
   Hello,
  
   About the syntax, I meant the second one, actually, declare the
 _instance
   just in constructor, but I just noticed a very weird thing...When I get
  null
   as I was referencing, if I just declare in my main class, a var casting
  the
   type of class that was returning null, it'll work. Seems compiler see
  that
   the class exists, and so it returns what I expect. It's really weird,
  since
   the singleton pattern is still the same. If i don't declare this dummy
  var
   with the type I want, even I'm sure the instance exists, it returns
 null.
  I
   really don't know why this is happening, but it was the workaround I've
   found.
  
   About the singleton implementation, I agree with you isn't the best
 thing
  to
   do, but in my case, I'm using that for 3 document classes, that for
 sure
   I'll use just one single time, so, it's the quickest solution I guess.
  
   And very nice your approach about minimize Singleton use. I'll take a
  try,
   it can save a lot of time.
  
   If you got my problem (i know it's a quite mess to explain), would be
  great
   know why this happens. Maybe it's a Gaia thing that I don't know how to
  use,
   but I was wondering if it was being a stupidity of mine with singleton
   concept, since I'm a bit new with oop.
  
   Thanks a lot,
   Pinatti
  
   On Fri, Nov 21, 2008 at 10:53 

Re: [Flashcoders] Flash Authortime vs Runtime children

2008-11-05 Thread Todd Kerpelman
Okay, I'll admit I'm only getting a vague sense of your problem, so forgive
me if I'm totally off base, but I think the proper workflow is this...

1. Uncheck the Automatically declare stage instances checkbox. (In
File... Publish Settings, go to the Flash tab, and click the Settings
button next to ActionScript 3.0) It sounds like you've already done this.

2. Create whatever you want to on stage within the Flash IDE. Remember the
name that you give it. For example, maybe you're creating a custom member of
the Ball class called bouncyBall. And maybe you added a TextField called
highScore

3. Go into your Document Class ActionScript file, and make sure you have
code like this...

public class BounceApp extends Sprite {

 public var bouncyBall:Ball;
 public var highScore:TextField;

// rest of code goes here...

4. You might need to repeat steps 2 and 3 if you've done something similar
for any individual symbols in your library. For instance, if my Ball class
had a text field called bounceCount, I'd need to include code like this...

public class Ball extends Sprite {

  public var bounceCount:Textfield;

 // other code here

4a. The nice thing is that I could actually then create a new class that
extends Ball, and as long as it has a Text Field called bounceCount in
there, it should all work.

5. From experience, I can tell you this is a pain in the butt if you're
doing it for the first time on a project you've already implemented halfway,
but when you start getting into this workflow from the beginning of a
project, it becomes second nature.

Hope that helps somewhat...

--T


On Wed, Nov 5, 2008 at 4:56 PM, Glen Pike [EMAIL PROTECTED] wrote:

 Hi,

   I found my problem...

   I had created classes that extended my AppScreen class

   public class ShowControlScreen extends AppScreen
   public class RobotDiagnosticsScreen extends AppScreen

   etc.
 But the Flash IDE would not let me use the AppScreen as the Base Class
 for my Library symbol - it whines about the Base class being already
 defined???

   So to workaround this problem, I had set the Base class to;

ShowControlScreen, RobotDiagnosticsScreen, etc.
   Then set a LinkageID for each one to something else;
 ShowControl, RobotDiagnostics, etc.

   So my symbols on stage that included components were ShowControl, etc.
 As soon as I started instanciating these instead of the Base class for
 the symbol, my on stage instances appear - hooray.

   Need to get my head around this - found a useful thread here, but I am
 having the problem that if I don't declare my stage instances automatically,
 but in my classes, I get a reference error for each thing on stage when the
 system tries to create these objects in the display list;

 ReferenceError: Error #1056: Cannot create property _displayText on
 RobotDiagnosticsScreen

   etc...

   So, does anyone know what the workflow is, because this seems like a PITA
 - either I have to create everything programmatically at runtime, or do some
 frig' in Flash with my LinkageID's to get it working and risk compounding
 errors with possible typo's etc in these fields.

   Why can't I just specify the class name as the LinkageID and choose WTF I
 want for the Base class - if I mess it up, that's my problem surely???
 Thanks, from a tired pd off Glen.

 Paul Andrews wrote:


 - Original Message - From: Glen Pike [EMAIL PROTECTED]
 
 To: Flashcoders@chattyfig.figleaf.com  Flashcoders mailing list 
 flashcoders@chattyfig.figleaf.com
 Sent: Monday, November 03, 2008 10:13 PM
 Subject: [Flashcoders] Flash Authortime vs Runtime children


 snip

The problem I have run into is that when I instanciate an AppScreen
 symbol from my library - it's not on stage - and add it to the stage I
 handle the ADDED_TO_STAGE event for wiring the components up.  All my
 component instances trace out as null at this point, so I am left scratching
 my head wondering when they might be added to the display list...


 I'd really like to see how you are trying to access the the component
 instances. Instanciating the symbols alone won't add them to the stage
 (addChild does that), so do you ever receive the event? If you do you should
 be able to find the component from the event payload.

 If you can write a tiny snippet of code to show how you attempt to load
 and access your components, then I'm sure we'd find the problem straight
 away.

 Paul


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