Asv3's Blog

September 13, 2009

Data Types

Filed under: flash — Tags: , , , — asv3 @ 12:24 pm

Primitive:

  • Boolean
  • int
  • null
  • Number
  • String
  • uint
  • undefined

Complex:

  • Object
  • Array
  • Date
  • Error
  • Function
  • RegExp
  • XML
  • XMLList

* type that is used to represent any data type. This should be used instead of omitting typing information for your variables.

Casting is treating variable of one type as variable of another type.

example:

int(true) //results 1

Key Board Events

Filed under: flash — Tags: , , , , — asv3 @ 10:53 am
  • KeyboardEvent.KEY_DOWN
  • KeyboardEvent.KEY_UP

Global Keyboard-Event Handling: Flash player by default doesn’t dispatch Global keyboard events, where as by adding key listener to Stage you can handle global key board events.

Mouse Events

Filed under: flash — Tags: , , , — asv3 @ 8:57 am
  • MouseEvent.MOUSE_DOWN
  • MouseEvent.MOUSE_UP
  • MouseEvent.CLICK
  • MouseEvent.DOUBLE_CLICK
  • MouseEvent.MOUSE_MOVE
  • MouseEvent.MOUSE_OVER
  • MouseEvent.MOUSE_OUT
  • MouseEvent.ROLL_OVER
  • MouseEvent.ROLL_OUT
  • MouseEvent.MOUSE_WHEEL

interesting thing to observe here is ROLL_OVER and MOUSE_OVER looks similar but they have it’s own purpose. The purpose of the rollOver event is to simplify the coding of rollout behaviors for display object containers with children. When the mouse leaves the area of a display object or the area of any of its children to go to an object that is not one of its children, the display object dispatches the rollOver event. This is different behavior than that of the mouseOver event, which is dispatched each time the mouse enters the area of any child object of the display object container, even if the mouse was already over another child object of the display object container.

Hence these two events make difference, when they are assigned to MovieClips with child display objects.

September 12, 2009

Operators

Filed under: flash — Tags: , , — asv3 @ 10:49 pm

Basic Operators

Arithmetic Operators: +, -, *, /, %, ++, –, +=, -=, *=, /=, %=
Comparison Operators: <, >, <=, >=, ==, ===, !,!=, !==, &&, ||
Other Operators: is, as, in, typeof, instanceof

There are even more operators for bitwise operations, I will  cover that later.

Events, Listeners, Handlers

Filed under: flash — Tags: , , — asv3 @ 10:29 pm

An Event is happening of  noteworthy occurrence which is dispatched and listened for.  In ActionScript events can be categorized into two types.

  • built-in events
  • custom events

Built-in events describe changes to the state of the runtime environment, and Custom describe changes to the state of a program.

All event target objects are either inherited from EventDispatcher class or implement IEventDispatcher, this class provides 2 methods, addEventListener() and removeEventListener() for register and de-register listeners to event target objects.

To register and Event Listener to Event,

  1. Determine the Event target
  2. Determine type of Event
  3. Create an Event Listener to respond the event
  4. use addEventListener to register event with listener

example:

theURLLoader.addEventListener(Event.COMPLETE, someListener);

function someListener(e:Event){

        //do some thing with e.target

}

Event object type: flash.events.Event
Event.type property = flash.events.Event.COMPLETE
Listener = someListener

MovieClip Properties

Filed under: flash — Tags: , , , , — asv3 @ 5:02 pm

In flash we can create 3 types of symbols.

1. MovieClip

2. Button

3. Graphic

Whenever we create a Symbol that Symbol will get added to the Library. Symbol in a Library is like master copy, we can drag Symbol from Library to create instance of the Symbol on stage. Here one thing we should remember is changes in library effect all instances on stag, where are changes to instances doesn’t. We can identify every instance of symbol with unique name called “Instance Name”.

MovieClip is the most used symbol in flash, in Flash almost every thing is a MovieClip. MovieClip is basically nothing but a container, similar to div in HTML, the only difference is it has it’s own time line. By that I mean, you can create n number of nesting MovieClips. Using property inspector we can assign an instance name for a MovieClip.

Flash doesn’t through error if you name two instances by same name, by default it assumes that name to the latest instance.

Button is used to define any click-able area. A Button is special kind of MovieClip, it has predefined 4 states.  Up, Over, Down, Hit.

Graphic is used to group shapes that doesn’t require it’s own time line.

Below are common properties of MovieClips which we can control using Actionscript.

  • x
  • y
  • width
  • height
  • scaleX
  • scaleY
  • rotation
  • alpha (transparency)

x, y take any negative or non negative integer, scaleX, scaleY, alpha take values between 0 and 1. width and height integers >= 0;

September 3, 2009

Overview Actionscript

Filed under: flash, flex — Tags: , , , — asv3 @ 4:30 pm

ActionScript is a programming language for Flash Player run-time environment. It was developed targeting designers to help them program interactivity. Today ActionScript enables efficient programming of flash applications ranging from Intros to complex, data-driven interactive applications.

ActionScript 1 started with Flash 5, which used “prototype” extensively to program interactive components for flash movies. ActionScript 2 was introduced with Flash MX 2004, which for the first time got Object Oriented concepts and implementations. Even though programmers using OOP methodologies final compiled binary was still using the ActionScript 1 format, hence the performance of flash applications were not that good by then.

Here came ActionScript 3, will lots on improvements over earlier version, AVM (ActionScript Virtual Machine) was written from the scratch, standardized components creation and usage methods. Closing up lot many security loop holes, still maintaining the backward support.

September 2, 2009

Introduction to ActionScript 3 using Flash CS3

Filed under: flash — Tags: , , — asv3 @ 4:55 pm

Coming days I am going to post tutorials on Introduction to ActionScript 3 using Flash CS3, Here are the topics I am planning to cover. for that sake we can keep flex thing aside for now, I will take it up later.

  • Overview
  • Introduction to Flash CS3
  • What’s new in ActionScript 3
  • Operators, Conditional Statements, Loops
  • Data Types
  • MovieClip Properties
  • Understanding Events, Listeners, Handlers
  • Mouse Events, KeyBoard Events
  • EnterFrame, Timer
  • Drawing API
  • Filters/Effects
  • Drag & Drop, Collision
  • Using Audio and Video
  • Simple Click-Through Prototype

Please feel free to comment

« Newer Posts

Create a free website or blog at WordPress.com.