Wednesday, 20 February 2008

AS3 cheat sheet

Found a nice cheat sheet for migration from AS2 to AS3:

http://www.actionscriptcheatsheet.com/downloads/as3cs_migration.pdf

Tuesday, 19 February 2008

AS3 -AttachMovieClip is no more!!

yea, it always sounded old, AS3 works without it. A common way of including an graphical object to the stage follows. I include a way of embedding an image straight away:

package {
import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
public class Test extends MovieClip {
// be sure this is pointing to an image in your hardrive
[Embed(source='\images\whatsup.jpg')] public var MyImage:Class;
public function Test() {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
var img:MyImage = new MyImage();
addChild(img);
}
}
}

Just attaching a symbol from the Library to the stage here:

package {
import flash.display.MovieClip;
public class Test extends MovieClip {
public var MyLibrarySymbol:MovieClip;
public function Test() {
var mc:MyLibrarySymbol= new MyLibrarySymbol();
addChild(mc);
}
}
}

Sunday, 17 February 2008

The Stage Object in a Flash CS3 Movie

the stage is treated as an Object in AS3. Here a small collection of articles on the oddities and possibilities of working with the stage object in AS3.
The first article shows the different ways of referencing the stage and it's children.

Basically here the short list of queries to have some information of the stage and it's children:

trace("Number of children of the Stage: ");
trace(stage.numChildren);

trace("What are children of Stage: ");
trace(stage.getChildAt(0));

trace("What does the keyword this refer to? ");
trace(this);

trace("Number of children of MainTimeline: ");
trace(this.numChildren);

trace("Are this.stage and stage the same? ");
trace(this.stage == stage);

trace("How many children does this.stage have? ");
trace(this.stage.numChildren);

trace("What are the children of this.stage? ");
trace(this.stage.getChild(0));


http://www.flashandmath.com/intermediate/children/stage.html

the good collection of senocular classes includes a custom stageDetection class:

http://www.senocular.com/flash/actionscript.php?file=ActionScript_3.0/com/senocular/events/StageDetection.as

Wednesday, 6 February 2008

A Lightweight (2K) and FAST Tweening Engine in AS3: TweenLite

While we a re still waiting for Zigo/Fuse to update their engine, I started using TweenLite, and really start liking it.
http://blog.greensock.com/tweenliteas3/
It is light (2kB), and fast, does rely on flashes built in easing classes though. It is rather basic, but useful for almost all purposes.
here a simple example, of a sequenced animation with :

import gs.TweenLite;
import fl.motion.easing.Elastic;
TweenLite.to(mc_my, 0.8, {x:120, y:143,ease:Elastic.easeOut,delay:2,onComplete:onFinishTween, onCompleteParams:[5, mc_my],overwrite:false});
private function onFinishTween(Num,target_mc){
trace("tween finished "+target_mc
}

onEnterFrame in AS3

the old 'onEnterFrame' syntax has been removed in AS3 It seems everything has to be handled by the eventListener. Here's a simple


import flash.events.Event;
addEventListener(Event.ENTER_FRAME, dosmthng);
//
private function dosmthng(Event){
trace("smthng"+Event)//output:smthng[Event type="enterFrame" bubbles=false ...
}

and to remove it? Well, it’s a listener so you have to remove the Event Listener with :

removeEventListener(Event.ENTER_FRAME,funcToCall)

Besides ENTER_FRAME we have other Public Constants to use:

  • ACTIVATE
  • ADDED
  • ADDED_TO_STAGE
  • CANCEL
  • CHANGE
  • CLOSE
  • COMPLETE
  • CONNECT
  • DEACTIVATE
  • ENTER_FRAME
  • FULLSCREEN
  • ID3
  • INIT
  • MOUSE_LEAVE
  • OPEN
  • REMOVED
  • REMOVED_FROM_STAGE
  • RENDER
  • RESIZE
  • SCROLL
  • SELECT
  • SOUND_COMPLETE
  • TAB_CHILDREN_CHANGE
  • TAB_ENABLED_CHANGE
  • TAB_INDEX_CHANGE
  • UNLOAD

Flash ReferenceError: Error #1065: Variable Application is not defined.

If you are receiving this error when publishing your flash as3 swf it is because you need to declare your class as public. Private classes can not be used as document classes because they are out of the class package and therefore are not a part of the private scope.

I’ve seen a bunch of people with this problem so I hope this helps. (courtesy of http://optimastudios.com)

AS3 stage properties

getting the Stage Properties in AS3 has changed.
Just use stage.stageWidth and stage.stageHeight ..NOT Stage.width and Stage.height !

Friday, 2 November 2007

flash cs3 help file location in windows XP

For linking the Sepy's help to flash cs3 help files, the location for
windows XP:
C:\Document and Settings\All Users\Application Data\Adobe\Flash CS3\\Configuration\HelpPanel\Help\
windowsVista:
C:\ProgramData\Adobe\Flash CS3\\Configuration\HelpPanel\Help\
Mac: HD:/Library/Application Support/Adobe/Flash CS3//Configuration/HelpPanel/Help/

Tuesday, 7 August 2007

make text legible and sharp

Flash tends to lose it's sharpness when it comes to fonts. Althought they look perfectly sharp within the IDE, the published movies often are not that sharp anymore.

There are a few simple rules or workarounds to maintain the sharpness.

  • odd values for font sizes (9,11,13,15) cannot be scaled as well. use font sizes of even values.

  • defining the font as dynamic gives better quality, but don't forget to embed the appropriate fonts in the properties Bar

Monday, 6 August 2007

wmode @ key flash bug

I often encountered the problem that some of my flash files did not accept the @ symbol in forms. I had to use the US keyboard @-sign location to add it. this issue only seemed to be on PC, as macs did not have that issue.
The reason for this seems to come up as soon as you publish your movie in wmode( transparent window mode), then the movie only can accept US keyboard-key locations.

more here:
http://blog.headlondon.com/archives/no-wmode-please-were-british/


One Workasround could be:

keyPresser = new Object();
keyPresser.onChanged = function(intxt:TextField) {
if (34 == ((Key.getAscii())) || 64 == ((Key.getAscii()))) {
in
txt.text = intxt.text.slice(0,intxt.text.length-1) +”@”;
}
};
Key.addListener(keyListener);
input_txt.addListener(keyPresser);

FileReference onComplete is not fired on Mac OS

onComplete not fired on Mac OS.
from what I could research on the internet, this issue seems still not have been resolved in flash player 9. partial solutions given here

but further research in progress.

Thursday, 5 July 2007

firefox flash tracer plugin

For Windows Vista these logfiles will normally be located in C:\Users\{Your User Name}\AppData\Roaming\Macromedia\Flash Player\Logs\flashlog.txt

The directory shows up once you installed the debug player.
further:
  • you do need the debug version of the flash player for the tracer to work.

  • I have observed quite a difference in performance with the tracer enabled, please share your experiences.



Tuesday, 26 June 2007

default dynamic text with scrollBar

I am trying to give an easy example of one of the many possibilities to have a dynamic text field with content fed from an external text file, being controlled by a self made scrollbar.

1. create your text file. I decided to go for a very simple html format.

2.open your flash movie, create a textfield on the stage.