Tag Archive for 'AS3'

Simple Screen Size Notification in AS3

I have made a small class that you can use if you would like to do something when your flash player is scaled to a maximum or minimumĀ  size. I have seen this used before where if the user scaled the browser to less then 1024×768 the user was warned to scales their browser to the correct size.

I have also added the ability to ignore all out of bound events with a simple method call.

Download Zip here
http://gfxcomplex.com/blog/wp-content/uploads/2008/07/screensizenotification.zip

Source comes with completed example file.

Heres some example useage

import com.gfxcomplex.screen_management.ScreenSizeNotification;

var testing:ScreenSizeNotification = new ScreenSizeNotification();
testing.manageStage(stage, {minSizeW:550, minSizeH:400, maxSizeW:1000, maxSizeH:850});
testing.addEventListener(ScreenSizeNotification.SCREEN_LESS_THEN_MIN, tooSmall);
testing.addEventListener(ScreenSizeNotification.SCREEN_GREATER_THEN_MAX, tooBig);

function tooSmall(e:Event):void{
	trace("Too small");
}

function tooBig(e:Event):void{
	trace("Too Big");
}
//if needed to stop event dispatches use testing.ignoreEvents(true);

Passing vars with events. or not. My take on how to simply pass vars with events.

I have seen a few posts on the internet about people saying that the hole custom event class is just not there thing or some thing alone that line. In short most of the blog posts focussed on providing different ways to pass a var with an event. I have a simple way to do this as well and it has not been discussed by any one yet so I thought I would put my 2 cents out there.

The idea is that you use the dictionary class to assign vars to an object and then access the var by passing the object to which the var is assigned to as an array index key in the dictionary.

Example:
I this example you would need three movieClips on the stage each with a instance name of someClip1_mc, someClip2_mc and someClip3_mc.

var dictionary:Dictionary = new Dictionary();	

dictionary[someClip1_mc] = "sting1";
dictionary[someClip2_mc] = "sting2";
dictionary[someClip3_mc] = "sting3";

someClip1_mc.addEventListener(MouseEvent.CLICK, traceOut);
someClip2_mc.addEventListener(MouseEvent.CLICK, traceOut);
someClip3_mc.addEventListener(MouseEvent.CLICK, traceOut);	

function traceOut(e:Event):void {
	trace(dictionary[e.target]);
}

Now the pit fall to this solution is that the scope of the dictionary instance needs to be accessible to the event method. Other then that you could use an Object, Array, ect… in the dictionary.

How to relocate for a job?? [pointers for approaching jobs out of state]

After approaching leads in st. Louis and still being out work I have made an effort to look for jobs just out of my area. If there is one thing that is not well documented, it’s relocating for a job. How do people do it? what are things you should consider when your willing to relocate for a job. Should you try to negotiate your costs of moving with your possible job prospects? These are all things I wish to know more about before hopping on a train or plain. Any pointers?

PS: If you don’t know by now I am looking for work and I am a flash developer / designer.
Here is my resume:http://gfxcomplex.com/josh_chernoffs_resume.pdf


How qualified are you for that Flash and or Action Script job?

I have been wondering how my skills compare to other developers / designers out there and if I could call my self a true Flash pro yet. With the wide range of tasks Flash and Action Script can achieve it’s not so black and white to say your the best qualified person for that job title of Flash pro. So I am trying to outline what it takes to archive a title of skill level in flash Design and Development

Lets start with what makes a novice flash developer / designer.

To say your a Novice Flash skill level you should have a good understanding of the following.

  • You know how to use the time line and stage.
  • You know how to make display object instances (MovieClips, Buttons, Images, ect…)
  • You know how to use the time line shape tweener and motions tweener.
  • You know how to Nest objects and have a understanding of scope
  • You know the basics of embedding in html
  • You can identify every tool in the tool panel

Even a novice skill leveled flash worker can produce high quality animations and banners. From my experience people who work in flash as a designer / animator never really perspire to learn more skills then this.
When I think in terms of the wages that level of skill is qualified to make I think in the range of $15 - $30 per hour.

If your have a moderate skill level of Flash then you have a understanding of the following

  • What action script is and the different types there are (AS1, AS2, AS3)
  • You know how to use action script on the time line to interact with display objects, property’s, methods and vars.
  • You have a basic understanding of var and how to use them

For the most part this is your average flash designer / developer. This level of skill is seen in flash sites that have a basic level of interactivity. Most of the time the type of web sites seen from users of this skill level are static a have some time of animation involved in it. When I think in terms of the wages that level of skill is qualified to make I think in the range of $15 - $40 per hour.

To be a advanced developer / designer you must understander the following

  • You know how to write with strict Datatypes, Class, Naming conventions
  • You know how to use and manage data from local and remote data sources (XML, flash var, remoting via AMF, ect..)
  • You have a basic understanding of OOP and design styles of programing such as MVC
  • You have little experience with frame works and have used one in a development project.
  • You have about two years experience with programing with Action script and working in the Flash IDE

This is your average freelance developer / designer and makes any where from $20 - $60 per hour depending on their professional experience and portfolio. The types of projects you see in flash on common web sites are made with the help of an advanced flash developer / designer.

Do you think your a pro yet?

I could use some help with describing this level of skill as I have yet to make it pro, but from what I can tell this is your average Pro flash developer / designer.

A pro Flash Developer / Designer:

  • Can write a complicated framework top to bottom
  • works on a production team of other pro flash developers and or has a consultant or support group of other pro flash developers
  • Can utilize complex APIs and data types such as the byteArray class.
  • has had his or her work showcased as best of it’s type at least once.

You can tell what a flash pro’s work looks like. Have a look at http://thefwa.com Every great site that gets showcased there is made by a professional team of flash developers and designers. Though I better there are many pros not show there too. From what I understand many Flash professionals make on average any where from $60 - $150+ per hour.

I know there maybe a few areas that I have not included here in my list. Feel free to add your opinions and or share your level of skills and why you think you are qualified for your title.

Code hints and escape shortcuts (”two simple things to help you become a better coder”)

Here is a mini cheat sheet to better and faster coding.

By naming your Object types with the corresponding Variable suffix you will add code hinting when you have not strong typed your Object types as well making your code more readable.

Use escape shortcuts for redundant typing of the same code. (”it’s kinda like snip-its of premade code”)

================
AS3 code hint triggers

Object type:
Variable suffix:

Array
_array

Button
_btn

Camera
_cam

Color
_color

ContextMenu
_cm

ContextMenuItem
_cmi

Date
_date

Error
_err

LoadVars
_lv

LocalConnection
_lc

Microphone
_mic

MovieClip
_mc

MovieClipLoader
_mcl

PrintJob
_pj

NetConnection
_nc

NetStream
_ns

SharedObject
_so

Sound
_sound

String
_str

TextField
_txt

TextFormat
_fmt

Video
_video

XML
_xml

XMLNode
_xmlnode

XMLSocket
_xmlsocket

======================
Escape shortcuts for AS3

with (Escape + wt)
while (Escape + wh)
var (Escape + vr)
throw (Escape + th)
switch (Escape + sw)
return (Escape + rt)
if (Escape + if)
function (Escape + fn)
for..in (Escape + fi)
for (Escape + fr)
else (Escape + el)
do (Escape + do)
default (Escape + dt)
continue (Escape + co)
class (Escape + cl)
case (Escape + ce)
break (Escape + br)
// ( Escape + //)

Play hang man with Digg.com ~ [ Digg man ] ~

I made a hang man game that uses digg’s headlines as the thing you need to guess to win. It’s still in Alfa and needs some testing for usability and difficulty. Please try it out and tell me what you think of the game in it’s current state.

http://gfxcomplex.com/labs/digg_man/

Please note that the game play is not complete yet. I want to correct any problems with the usability before I progress any more with the game play.

TODO:

  1. Complete game logic
  2. Add more dynamic content for game play (Levels, ect…)
  3. Add scoring system

(AS3 === AS3) = false! I am frustrated with the Flash vs Flex API’s and the bias of the community

What are the excuses for not allowing all that flex can do in flash or vice versa? I think AS3 should be AS3 not Flash’s AS3 or Flex’s AS3. I believe Adobe needs to address this big problem. We need a discrepancy free program language. The web community has become more bias to Flex over the last year with out concern for the developers working in Flash. Example Yahoo’s map API which works just fine in flash’s AS2 now is limited to flex in AS3 though with out any real under standing why.

From an IDE stand point what is the use of providing a IDE the power of AS3 only to limit it’s use? I want to know why Flex can do more then flash. From what I under stand the hole flex API is built off of the components built in flash. I think this bias for one IDE over the other with in the context of AS3 is setting the stage for failure and leaves a negative precedences in our community. I believe adobe needs to merge the two programs in to a single IDE or make a better attempt to bridge their discrepancy.

Hows my dynamic Runtime font blog header working for you?

I made a header that loads a custom font at runtime and uses it to display the main blog title.
I would like to know you experience with it. See any bugs, problems loading or maybe you just think it’s dumb.
Any way it is I would like some input please thanks.
- Josh Chernoff

[Need Help] What are the laws of redistributing fonts via swf if any?

I want to make a large library of font swf files for use in flash programs but I don’t realy feel like getting sued over it. Would redistributing fonts via swf constitute as redistributing the font it’s self. My thoughts are 1: you can only use the font in flash, 2: I would not be redistributing the font it’s self but only a swf file.

One of the key functions of doing this is to help with the load of install the font just to embedded it in to your program and as well cross platform support.

What are your thoughts?

- Josh Chernoff

Wade Arnold’s new amfphp datagrid example at amfphp.org

amfphp.pnghttp://amfphp.org/docs2/tutorials/datagrid.html

Wade Arnold Amfphp.org has added a new example to adding a record set to a datagrid.

here’s the main document class: requires a datagrid component in the library.

// Wade Arnold: 1/16/2008
// Example is designed to show how to use amfphp to populate a fl.controls.datagrid.
// TODO: Add method to update the dataset array.
// TODO: Add an additional call that shows how to get data from a database.
// TODO: Add a method to update the database dataset. 

package {
	// required for flash file and output display
	import flash.display.MovieClip;
	import fl.events.*;
	import flash.events.*;
	// required to send/recieve data over AMF
	import flash.net.NetConnection;
	import flash.net.Responder;
	// required for the datagrid
	import fl.controls.DataGrid;
	//import fl.controls.dataGridClasses.DataGridColumn;
	import fl.data.DataProvider;

	// Flash CS3 Document Class.
	public class Main extends MovieClip {
		private var gateway:String = "http://localhost/amfphp/gateway.php";
		private var connection:NetConnection;
		private var responder:Responder;
		// DataGrid on the stage
		private var myDg:DataGrid;
		// Dataprovider for the DataGrid
		private var dp:DataProvider;

		public function Main() {
			trace("AMFPHP DataGrid Example");
			// Create the new dataprovider
			dp = new DataProvider();
			myDG.dataProvider = dp;

			// Responder to handle data returned from AMFPHP.
			responder = new Responder(onResult, onFault);
			connection = new NetConnection;

			// Gateway.php url for NetConnection
			connection.connect(gateway);
			// Ask for the data on the load of the flash file.
			connection.call("DataGrid.getDataSet", responder);
		}

		// Handle a successful AMF call. This method is defined by the responder.
		private function onResult(result:Object):void {
			// Add the data that was returned from ther service into the Dataprovider.
			dp.addItems(result);
			// Debug: Just showing how large the dataset is.
			trace("Rows Returned: "+dp.length);
		}

		// Handle an unsuccessfull AMF call. This is method is dedined by the responder.
		private function onFault(fault:Object):void {
			trace(String(fault.description));
		}
	}
}