0

Transversing the Display List Correctly

Transversing the Display List Correctly via @largestartist Posted by Jose Cuadra on December 10, 2009 Tags: Filed Under: References

When coming from JavaScript a common mistake when drilling down through objects is that chaining doesn’t work like you would think in AS3. Yes the languages are similar but here’s a difference.

DOM

In JavaScript you would transverse the DOM using a method called “getElementsByTagName().” You can chain these to dig into the objects.

//This grabs the first input field inside the first div on the page
var textField = document.getElementsByTagName("div")[0].getElementsByTagName("input")[0];

Now in ActionScript you can’t double up on the “getChildAt()” method, because that method doesn’t have a method of “getChildAt().” Confused yet?

In ActionScript 3 you have to cast the method into an object so you can use the method again to drill down.

ActionScript 3

var sprite:Sprite = new Sprite();
var txtField:TextField = new TextField();
txtField.text = "something";
sprite.addChild(txtField);
stage.addChild(sprite);
 
//Cast the object returned to a DisplayObjectContainer 
var path:Sprite = Sprite(stage.getChildAt(1));
 
trace(path.getChildAt(0));//[object TextField]
//trace(stage.getChildAt(1).getChildAt(0));//Error - 1061: Call to possibly undefined method getChildAt through reference with static type flash.displa:DisplayObject.
0

Conditional Shortcut in ActionScript

Conditional Shortcut in ActionScript via @largestartist Posted by Jose Cuadra on August 3, 2009 Tags: Filed Under: References

While thumbing through an old ActionScript book(Training from the Source) I found a shorthand approach to the conditional statement.

Continue Reading…

2

Flash Slideshow in Actionscript 3

Flash Slideshow in Actionscript 3 via @largestartist Posted by Jose Cuadra on March 26, 2009 Tags: | | | | Filed Under: Applications

“Simple Slide” is an automated slide show that can also be used for banner ads. Download it now to tweak it for your specific application.

Continue Reading…

0

The Textfield’s Alpha Property in AS 3.0

The Textfield’s Alpha Property in AS 3.0 via @largestartist Posted by Jose Cuadra on March 10, 2009 Tags: | Filed Under: References

A common and frustrating issue when creating text fields dynamically is the manipulation of this objects alpha property. Usually you just set it and forget it, but in this case a couple more steps are required. the trick is to set the blending mode of the text fields parent object.

Continue Reading…

0

ActionScript 2 to 3 Object Properties

ActionScript 2 to 3 Object Properties via @largestartist Posted by Jose Cuadra on July 22, 2008 Tags: | Filed Under: References

In ActionScript 3 accessing your favorite object properties no longer require underscores as they did in AS 2. Here are some examples that list the previous and current conventions.

Continue Reading…

1

Random Functions

Random Functions via @largestartist Posted by Jose Cuadra on July 21, 2008 Tags: | | | | Filed Under: References

Random text or images is an easy feature to deploy that can develop interest on a project. Any application can benefit from not presenting the same information over and over during every visit. I have listed examples in JavaScript, ActionScript, PHP, and Coldfusion.

Continue Reading…