Montgomery Bank Design

The latest design for Banc Intranets is the Montgomery Bank re-design. Hot off the presses below is the home page design getting ready for CSS/HTML and integration into the Banc Intranets framework.

Montgomery Bank




Flash Video Player

Recently I also created a custom video player/skin for promoting internal video on the intranet. Below is a screen shot of the final player, which resizes based on content from 250px to 750px. The player also has logic controlled by passing flash vars into it to determine whether or not the video is streaming or progressive, allowing us to use one player skin for all video internally.

note - To preserve any complications with compliance of King Pharmaceuticals I am only posting simple screenshots of applications that I have created. Any content that may be shown is strictly for demonstration purposes of my portfolio.

Video Player




Flash mp3 player

I recently created a custom mp3 player/skin for promoting company sound bytes on the internal portal. Using Flash and AS3 was a no brainer for this type of project. I will package the project and classes soon to include in this post.

note - To preserve any complications with compliance of King Pharmaceuticals I am only posting simple screenshots of applications that I have created. Any content that may be shown is strictly for demonstration purposes of my portfolio.

Audio Player




FDT3 by Powerflasher - AS3 super editor!

I have seen the light. An old friend sent me a link today to FDT3, an AS3 super editor based on Eclipse. There is a plugin for Eclipse as well as a stand alone install. The basic features that I have used so far would help any new or seasoned AS3 developer greatly. The real time debugging and strict coding parameters alone have already improved my quality of coding. Check it out at http://fdt.powerflasher.com/. Now if I can only talk my boss into getting me a copy…but I have to admit it’s pretty damn expensive.

AS3: Re-Usable TextFormat class

In this simple tip I provide an easy to use text formatting class. To use this class, simply import the class into your existing document class or other, and then create a variable instance. To call the formatter you will use “textfield.setTextFormat(variable.formatfunction);

The formatting class is below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package com.riareviver{
 
	//FLASH CLASS IMPORT
	import flash.display.MovieClip
	import flash.events.*
	import flash.text.TextFormat
 
	public class TxtFormat extends MovieClip {
 
		//VAR
		public var myTextFormat:TextFormat = new TextFormat()
 
		public function TxtFormat() {
			//TEXT FORMATTER
			myTextFormat.font = "Verdana"
			myTextFormat.color = 0xFFFFFF
			myTextFormat.size = 10
			myTextFormat.align = "left"
		}
	}
}





Below is a sample textfield class using the formatter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.riareviver{
 
	//FLASH CLASS IMPORT
 
	//CUSTOM CLASS IMPORT
	import com.riareviver.TxtFormat
 
	public class MyText extends MovieClip {
 
		//PUBLIC VARS	
 
		//PRIVATE VARS
		private var myTextField:TextField
		private var txtFormat:TxtFormat = new TxtFormat()
 
		public function MyText() {
			myTextField = new TextField()
			myTextField.x = 5
			myTextField.y = 5
			myTextField.width = 200
			myTextField.text = "My Text"
			myTextField.setTextFormat(txtFormat.myTextFormat)
			myTextField.selectable = false
			addChild(myTextField)
		}
	}
}




Click here to see more text formatting properties




Related Articles:

  • Flash Video Player
  • Flash mp3 player
  • AS3: Using Array and For Loop to create movable panels
  • AS3: Homegrown particles
  • AS3: Alternate row colors on dynamic movieclips

  • AS3: Using Array and For Loop to create movable panels

    This tip will show you how to 1. create movable panels, and 2. to create them using array and for loop statements to access the panel class. This is an exercise in creating re-usable code classes, and accessing them with and array.

    First we create a Flash project to hold all the files for the exercise. Then we create 3 separate files, one .fla and two .as files. The .fla does nothing more than access the document class and set the size of the stage. I usually name the document class the same as the .fla, but feel free to name it as you like. The two .as classes that we will create are the one we will use as the document class (PanelNav.as) and a class that holds the panel creation code (PanelSpawn.as).

    The class PanelNav.as imports the class Panel Spawn.as, creating panels by cycling through an array of information. I am passing a few arguments from the array, but more can be passes as you get into the class, such as header color, border color, etc. Everything is generated by using one major for/loop statement, cycling through the amount of Array items, generating a panel from the PanelSpawn.as class for each array item. You can use the PanelSpawn.as class to create one panel, but why when you can create an unlimited amount of panels by using a simple array and for statement? Enough of my explanation, here is the code.

    Download the source project here

    Click and drag a panel below, note the transparency on click.

    Below is the code for the Document Class

    package com.riareviver{
     
    	//FLASH CLASS IMPORT
    	import flash.display.MovieClip
    	import flash.events.*
     
    	//CUSTOM CLASS IMPORT
    	import com.riareviver.PanelSpawn
    	import com.riareviver.DebugPanel
     
    	public class PanelNav extends MovieClip {
     
    		//VARS
    		public var panelArray:Array = new Array()
    		public var genPanel:Array = new Array()
    		public var debugPanel:DebugPanel
     
    		public function PanelNav() {
    			//Debug Panel
    			debugPanel = new DebugPanel()
     
    			//Panel Array push
    			panelArray.push({width:200, height:180, title:"Panel One", xLoc:20, yLoc:20})
    			panelArray.push({width:200, height:180, title:"Panel Two", xLoc:120, yLoc:60})
    			panelArray.push({width:200, height:180, title:"Panel Three", xLoc:220, yLoc:100})
     
    			for (var b:int = 0 b &lt panelArray.length b++) {
    				///////////////////////////////////////////////////////////////////////
    				//Create new Panel from Array
    				genPanel[b] = new PanelSpawn(panelArray[b].width, panelArray[b].height, panelArray[b].title)
    				genPanel[b].x = panelArray[b].xLoc
    				genPanel[b].y = panelArray[b].yLoc
    				addChild(genPanel[b])
    				///////////////////////////////////////////////////////////////////////
     
    				///////////////////////////////////////////////////////////////////////
    				//Add Panel Event Listeners
    				genPanel[b].addEventListener(MouseEvent.MOUSE_DOWN, startPanelDrag)
    				genPanel[b].addEventListener(MouseEvent.MOUSE_UP, stopPanelDrag)
    				stage.addEventListener(MouseEvent.MOUSE_UP, stopPanelDrag)
    				///////////////////////////////////////////////////////////////////////
     
    				///////////////////////////////////////////////////////////////////////
    				//Add Event Handlers for Panels
    				function startPanelDrag(e:MouseEvent):void {
    					for (var g:int = 0 g &lt panelArray.length g++) {
    						switch (e.currentTarget) {
    							case genPanel[g] :
    								genPanel[g].startDrag()
    								genPanel[g].alpha = .5
    								setChildIndex(genPanel[g], numChildren - 1)
    								break
    						}
    					}
    				}
    				function stopPanelDrag(e:MouseEvent):void {
    					for (var g:int = 0 g &lt panelArray.length g++) {
    						switch (e.currentTarget) {
    							case genPanel[g] :
    								genPanel[g].alpha = 1
    								genPanel[g].stopDrag()
    								break
     
    							case stage :
    								genPanel[g].alpha = 1
    								genPanel[g].stopDrag()
    								break
    						}
    					}
    				}
    				///////////////////////////////////////////////////////////////////////
    			}
    		}
    	}
    }

    The Panel creation class is below:

    package com.riareviver{
     
    	//FLASH CLASS IMPORT
    	import flash.display.MovieClip
    	import flash.events.*
    	import flash.text.TextField
     
    	//CUSTOM CLASS IMPORT
    	import com.riareviver.TxtFormat
     
    	public class PanelSpawn extends MovieClip {
     
    		//PUBLIC VARS
    		public var panelContainer:MovieClip
    		public var panelHeader:MovieClip
    		public var panelBody:MovieClip
     
    		//PRIVATE VARS
    		private var pLineStyleWidth:Number
    		private var pLineStyleColor:uint
    		private var pHeaderFillColor:uint
    		private var pFillColor:uint
    		private var pPanelWidth:Number
    		private var pHeaderXloc:Number
    		private var pHeaderYloc:Number
    		private var pHeaderWidth:Number
    		private var pHeaderHeight:Number
    		private var pBodyHeight:Number
    		private var headerText:TextField
    		private var txtFormat:TxtFormat = new TxtFormat()
     
    		public function PanelSpawn(panelWidth:Number, bodyHeight:Number, panelTitle:String) {
     
    			pPanelWidth = panelWidth
    			pBodyHeight = bodyHeight
     
    			pLineStyleWidth = .5
    			pLineStyleColor = 0x666666
    			pHeaderFillColor = pLineStyleColor
    			pFillColor = 0xFFFFFF
    			pHeaderXloc = 0
    			pHeaderYloc = 0
    			pHeaderWidth = pPanelWidth
    			pHeaderHeight = 20
     
    			//CONTAINER
    			panelContainer = new MovieClip()
    			panelContainer.x = 0
    			panelContainer.y = 0
    			addChild(panelContainer)
     
    			//HEADER
    			panelHeader = new MovieClip()
    			panelHeader.graphics.lineStyle(pLineStyleWidth, pLineStyleColor)
    			panelHeader.graphics.beginFill(pHeaderFillColor)
    			panelHeader.graphics.drawRect(pHeaderXloc, pHeaderYloc, pPanelWidth, pHeaderHeight)
    			panelHeader.graphics.endFill()
    			panelContainer.addChild(panelHeader)
     
    			headerText = new TextField()
    			headerText.x = 5
    			headerText.y = 1
    			headerText.width = pPanelWidth - 20
    			headerText.text = panelTitle
    			headerText.setTextFormat(txtFormat.displayFormat) //TxtFormat class reference
    			headerText.selectable = false
    			panelHeader.addChild(headerText)
     
    			//BODY
    			panelBody = new MovieClip()
    			panelBody.graphics.lineStyle(pLineStyleWidth, pLineStyleColor)
    			panelBody.graphics.beginFill(pFillColor)
    			panelBody.graphics.drawRect(pHeaderXloc , pHeaderYloc + pHeaderHeight, pPanelWidth, pBodyHeight)
    			panelBody.graphics.endFill()
    			panelContainer.addChild(panelBody)
     
    		}
    	}
    }

    Related Articles:

  • Flash Video Player
  • Flash mp3 player
  • AS3: Re-Usable TextFormat class
  • AS3: Homegrown particles
  • AS3: Alternate row colors on dynamic movieclips
  • Unbelievable new features in Flash CS4 @gotoAndLearn()

    Check out the new unbelievable features of Flash CS4, highlighted on gotoAndLearn() by Lee Brimelow.

    Flash CS4 Feature tour

    SlideRocket now open for public Beta

    The public can now check out SlideRocket…Sign up for a public beta account here.

    SlideRocket

    A great new, well at least a “new” product…FeatureCreep.

    I work with a great team of designers and developers, but one thing exists in this internal facing team as does with any other external facing team I have been on…feature creep. Our team is very Adobe oriented (not saying it is a bad thing), especially one of my coworkers…and I am convinced that he is secretly working on a new product with Adobe. I threw together a quick mock-up of the new logo for his product pitch to Adobe. Also coming soon, Feature Creep’s open source framework, Scope Creep. Both will be a WTFWYT (What the F*** Were you Thinking) based product.

    By popular demand…get your FeatureCreep Apparel here.

    Feature Creep

    AS3: Homegrown particles

    First off, I will say that without Matthew Tretter’s garbage collection classes this demo would not be possible…While generating this many “particles” on ENTER_FRAME, the Flash Player can not keep up (or wouldn’t in my case), with the 3 tweens on X, Y, and alpha.
    After saying that…here is a demo that I came up with tonight playing around in Flash and practicing some rapid development prototyping. It is a “particle” generator (that’s what I am calling it) using the display class, randomly positioning X and Y, as well as tweening the alpha channel.

    Particles
    Go ahead, click and drag below…you know you want to.

    import flash.display.MovieClip
    import fl.transitions.Tween
    import fl.transitions.easing.*
    import fl.transitions.TweenEvent
    import fl.transitions.*
    import fl.motion.easing.*
     
    //Matthew Tretter's Garbage collection class
    import com.exanimo.transitions.GCSafeTween
     
    //VARIABLES
    var circBubble:MovieClip
    var XLocMove:Number = 10
    var YLocMove:Number = 10
    var circRadius:Number = Math.random()*10
    var bubbleTween:Tween
    var bubbleColor:uint = 0x000000
    var bubbleArray:Array = new Array()
     
    //Event Listeners
    stage.addEventListener(MouseEvent.MOUSE_DOWN, checkMouseDown)
    stage.addEventListener(MouseEvent.MOUSE_UP, checkMouseUp)
     
    //Check Mouse Actions
    function checkMouseDown(e:MouseEvent):void {
    	stage.addEventListener(Event.ENTER_FRAME,tweenBubble)
    }
    function checkMouseUp(e:MouseEvent):void {
    	stage.removeEventListener(Event.ENTER_FRAME,tweenBubble)
    }
     
    //Method to kick off the particles, gets called on every frame at 30fps.
    function tweenBubble(e:Event):void {
     
    	circBubble = new MovieClip()
    	addChild(circBubble)
     
    	circBubble.graphics.beginFill(bubbleColor)
    	circBubble.graphics.drawCircle(mouseX,mouseY, circRadius)
    	circBubble.graphics.endFill()
     
    	//Matthew Tretter's garbage collection class calls the tweens
    	new GCSafeTween(circBubble, "y", Elastic.easeOut, 0, XLocMove, 2, true)
    	new GCSafeTween(circBubble, "x", Elastic.easeOut, 0, YLocMove, 2, true)
    	new GCSafeTween(circBubble, 'alpha', None.easeNone, 1, 0, 1, true)
     
    	//Randominze the XLOC - both negative and positive coordinate results
    	if (XLocMove &gt -1) {
    		XLocMove = (Math.random()*100) * -1
    	} else if (XLocMove &lt -1) {
    		XLocMove = (Math.random()*100) + -1
    	}
    	//Randominze the YLOC - both negative and positive coordinate results
    	if (YLocMove &gt -1) {
    		YLocMove = (Math.random()*100) * -1
    	} else if (YLocMove &lt -1) {
    		YLocMove = (Math.random()*100) + -1
    	}
    	//Randomize the radius of the generated bubbles
    	circRadius = Math.random()*10
     
    	//Randomly add to the bubble Color, I am partial to blue...
    	bubbleColor += 000022
    }

    Related Articles:

  • Flash Video Player
  • Flash mp3 player
  • AS3: Re-Usable TextFormat class
  • AS3: Using Array and For Loop to create movable panels
  • AS3: Alternate row colors on dynamic movieclips
  • AS3: Alternate row colors on dynamic movieclips

    Below is an example of how to dynamically change the row color of generated movieclips. I find this helpfu when making grid based layouts, buttons, etc. You can have an unlimited amount of row colors by adding to the two if/then statements. Also, you can make this class re-usable by simply adding variables in the public function, passing them into the constructor method from your main fla movieclip instantiation. I try to keep all variables outside the main constructor, or at least in a single area, to help maintain the code and keep it cleaner.

    Download the source project here

    Alt Row Colors

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    
    package com.riareviver{
     
    	//Flash Class imports
    	import flash.display.MovieClip
    	import flash.text.TextField
    	import flash.events.*
     
    	public class altRowColor extends MovieClip {
     
    		//VARIABLE Definitions
    		var boxToRepeat:MovieClip
    		var boxText:TextField
     
    		var boxXLoc:int = 50
    		var boxYLoc:int = 50
    		var boxWidth:int = 200
    		var boxHeight:int = 25
     
    		var boxFillColor:uint
    		var boxFillColor01:uint = 0x235880
    		var boxFillColor02:uint = 0x71BDEE
    		var boxFillColor03:uint = 0xCCCCCC
     
    		var altColorDetect:int = 0
    		//How many boxes there are, go ahead...change it and see!
    		var boxInstanceCount:uint = 8
     
    		public function altRowColor() {
     
    			//Repeat the box, alternating colors as you go.
    			for (var i:int = 0 i < boxInstanceCount i++) {
     
    				//Alternate the color based on the detection variable
    				if (altColorDetect == 0) {
    					boxFillColor = boxFillColor01
    				} else if (altColorDetect == 1) {
    					boxFillColor = boxFillColor02
    				} else if (altColorDetect == 2) {
    					boxFillColor = boxFillColor03
    				}
    				//Create new BOX
    				boxToRepeat = new MovieClip()
    				boxToRepeat.graphics.beginFill(boxFillColor)
    				boxToRepeat.graphics.drawRect(boxXLoc, boxYLoc, boxWidth, boxHeight)
    				boxToRepeat.graphics.endFill()
    				boxToRepeat.buttonMode = true
    				//A little trick to keep the text from preventing the hand cursor change.
    				boxToRepeat.mouseChildren = false
     
    				//Create new TEXTFIELD
    				boxText = new TextField()
    				boxText.width = 195
    				boxText.height = 15
    				boxText.x = boxXLoc + 10
    				boxText.y = boxYLoc + 5
    				boxText.selectable = false
    				boxText.text = "Box number: " + (i + 1)
     
    				//Add all children
    				addChild(boxToRepeat)
    				//We add the textfield as a child of the box
    				boxToRepeat.addChild(boxText)
     
    				//Increment the Y Location for the next box
    				boxYLoc += boxHeight
     
    				//Alternate the detection variable value
    				if (altColorDetect == 0) {
    					altColorDetect = 1
    				} else if (altColorDetect == 1) {
    					altColorDetect = 2
    				} else if (altColorDetect == 2) {
    					altColorDetect = 0
    				}
    			}
     
    		}
    	}
    }



    Related Articles:

  • Flash Video Player
  • Flash mp3 player
  • AS3: Re-Usable TextFormat class
  • AS3: Using Array and For Loop to create movable panels
  • AS3: Homegrown particles

  • I am going to Adobe MAX 08

    MAX 2008



    For the first time since MAX 2004 in New Orleans, I get to go this year in San Francisco. I have been to several, including back in the day when it was DEVCON, twice in Orlando. I am very excited and will be blogging about what I see. This year should be the best ever.

    AS3: Floating Tool Tip using currentTarget

    Without a lot of explanation on the topic, the following package creates 4 squares dynamically, then uses event listeners to point to global methods that checks the currentTarget. Based on mouse over or mouse out a method is called to show the tool tip (created on the fly) and changes its X and Y based on your mouse location. Basically, it is a floating tooltip demo, showing you how helpful currentTarget is.

    Download the source here

    ToolTip


    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    
    package com.riareviver{
     
    	//Flash Class Imports
    	import flash.display.MovieClip
    	import flash.events.*
    	import flash.text.TextField
     
    	public class toolTipMain extends MovieClip {
     
    		var square01:MovieClip
    		var square02:MovieClip
    		var square03:MovieClip
    		var square04:MovieClip
     
    		var toolTipText:TextField
     
    		var squareXLoc:Number = 50
    		var squareYLoc:Number = 50
    		var squareDim:Number = 50
     
    		public function toolTipMain() {
    			//Build Square 1 - Base
    			square01 = new MovieClip()
    			square01.graphics.beginFill(0xCCCCCC)
    			square01.graphics.drawRect(squareXLoc, squareYLoc, squareDim, squareDim)
    			square01.graphics.endFill()
    			square01.width = squareDim
    			square01.height = squareDim
    			//Build Square 2
    			square02 = new MovieClip()
    			square02.graphics.beginFill(0x333333)
    			square02.graphics.drawRect(squareXLoc + squareDim, squareYLoc, squareDim, squareDim)
    			square02.graphics.endFill()
    			square02.width = squareDim
    			square02.height = squareDim
    			//Build Square 3
    			square03 = new MovieClip()
    			square03.graphics.beginFill(0x999999)
    			square03.graphics.drawRect(squareXLoc, squareYLoc + squareDim, squareDim, squareDim)
    			square03.graphics.endFill()
    			square03.width = squareDim
    			square03.height = squareDim
    			//Build Square 4
    			square04 = new MovieClip()
    			square04.graphics.beginFill(0x666666)
    			square04.graphics.drawRect(squareXLoc + squareDim, squareYLoc + squareDim, squareDim, squareDim)
    			square04.graphics.endFill()
    			square04.width = squareDim
    			square04.height = squareDim
    			//Create ToolTip TEXTFIELD
    			toolTipText = new TextField()
    			toolTipText.width = 100
    			toolTipText.height = 15
    			toolTipText.backgroundColor = 0x64ADE9
    			toolTipText.background = true
    			toolTipText.textColor = 0x000000
    			toolTipText.visible = false
     
     
    			//Add children
    			addChild(square01)
    			addChild(square02)
    			addChild(square03)
    			addChild(square04)
    			addChild(toolTipText)
    			//Add Event Listeners
    			square01.addEventListener(MouseEvent.MOUSE_OVER, checkMouseOver)
    			square01.addEventListener(MouseEvent.MOUSE_OUT, checkMouseOut)
     
    			square02.addEventListener(MouseEvent.MOUSE_OVER, checkMouseOver)
    			square02.addEventListener(MouseEvent.MOUSE_OUT, checkMouseOut)
     
    			square03.addEventListener(MouseEvent.MOUSE_OVER, checkMouseOver)
    			square03.addEventListener(MouseEvent.MOUSE_OUT, checkMouseOut)
     
    			square04.addEventListener(MouseEvent.MOUSE_OVER, checkMouseOver)
    			square04.addEventListener(MouseEvent.MOUSE_OUT, checkMouseOut)
     
    			//Universal method to check MOUSEOVER
    			function checkMouseOver(e:MouseEvent):void {
    				switch (e.currentTarget) {
    					case square01 :
    						stage.addEventListener(Event.ENTER_FRAME,toolTipOn)
    						toolTipText.htmlText = "Square 1"
    						break
     
    					case square02 :
    						stage.addEventListener(Event.ENTER_FRAME,toolTipOn)
    						toolTipText.htmlText = "Square 2"
    						break
     
    					case square03 :
    						stage.addEventListener(Event.ENTER_FRAME,toolTipOn)
    						toolTipText.htmlText = "Square 3"
    						break
     
    					case square04 :
    						stage.addEventListener(Event.ENTER_FRAME,toolTipOn)
    						toolTipText.htmlText = "Square 4"
    						break
    				}
    			}
    			//Universal method to check MOUSEOUT
    			function checkMouseOut(e:MouseEvent):void {
    				switch (e.currentTarget) {
    					case square01 :
    						stage.removeEventListener(Event.ENTER_FRAME,toolTipOn)
    						toolTipOff(null)
    						break
     
    					case square02 :
    						stage.removeEventListener(Event.ENTER_FRAME,toolTipOn)
    						toolTipOff(null)
    						break
     
    					case square03 :
    						stage.removeEventListener(Event.ENTER_FRAME,toolTipOn)
    						toolTipOff(null)
    						break
     
    					case square04 :
    						stage.removeEventListener(Event.ENTER_FRAME,toolTipOn)
    						toolTipOff(null)
    						break
    				}
    			}
    			//Tooltip ON
    			function toolTipOn(e:Event):void {
    				toolTipText.visible = true
    				toolTipText.x = mouseX + 10
    				toolTipText.y = mouseY - 10
    			}
    			//Tooltip OFF
    			function toolTipOff(e:Event):void {
    				toolTipText.visible = false
    			}
     
    		}
    	}
    }



    Related Articles:

  • Flash Video Player
  • Flash mp3 player
  • AS3: Re-Usable TextFormat class
  • AS3: Using Array and For Loop to create movable panels
  • AS3: Homegrown particles

  • AS3: Using currentTarget to listen for your buttons

    A lot of times when I am working on a project that has a lot of buttons, I like to simplify my event listeners into two methods, watching the currentTarget to see where to go. This is extremely helpful when you have to have a mouse down effect that needs to keep looping, say on a zoom. So, when the user holds the mouse down, I add an ENTER_FRAME event that keeps the event in a loop. By using currentTarget and a switch statement, you can keep your listeners set up nice and clean, also helps the next guy figure out what you are trying to accomplish…

    1
    2
    3
    4
    5
    6
    
    btnOne.addEventListener(MouseEvent.MOUSE_DOWN,checkMouseDown)
    btnOne.addEventListener(MouseEvent.MOUSE_UP,checkMouseUp)
     
    //or even
     
    btnTwo.addEventListener(MouseEvent.CLICK,checkMouseDown)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    
    function checkMouseDown(e:MouseEvent):void {
     
    	switch (e.currentTarget) {
     
    		case btnOne :
    		stage.addEventListener(Event.ENTER_FRAME,myMethod)
    		break
     
    		case btnTwo :
    		myMethod(null)
    		break
     
    	}
    }
     
     
    function checkMouseUp(e:MouseEvent):void {
     
    	switch (e.currentTarget) {
     
    		case btnOne :
    		stage.removeEventListener(Event.ENTER_FRAME, myMethod)
    		break
     
    	}
    }
     
    function myMethod(e:Event):void{
    	//Do Something
    }



    Related Articles:

  • Flash Video Player
  • Flash mp3 player
  • AS3: Re-Usable TextFormat class
  • AS3: Using Array and For Loop to create movable panels
  • AS3: Homegrown particles

  • AS3: Learn how to create a re-usable class

    AS3: Learn how to create a re-usable class

    Download an entire Flash project using this example here.

    One thing that I found hard, being a designer turn developer turn pseudo programmer, was understanding how packages, classes, and overall re-usable code is handled. Once it clicked with me then I was off and running, but every example that I found was so complex or a small part of a larger project. What I am presenting below is a simple walk through of how to create a very simple package, and use it passing arguments.

    You will need 3 files, newBox.fla, newBox.as, and setNewBox.as. Feel free to use any name for this, but it will be easier to follow along if you name them as I have. To start off, set your document class in the newBox.fla file. I have named my document class newBox.as. That is all you need to do in the .fla, no “frame coding” going on here…

    Our constructor function, or the function that gets called in when you assign a document class…is then created as follows:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    
    package com.connatserdev{
     
    	//FLASH CLASS IMPORTS
    	import flash.display.MovieClip
     
    	//CUSTOM CLASS IMPORT
    	import com. connatserdev.setNewBox
     
    	public class newBox extends MovieClip {
     
    		public function newBox() {
     
    		}
    	}
    }

    Next, we can start creating our re-usable classes, in this instance a class to create a simple box. You will notice in the setNewBox method, we are setting several variables. These values get passed as arguments from the document class, newBox.as. This is what helps make a class re-usable, meaning I can create as many children that I want in the document class by simple creating a new instance and pass these values.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    
    package com. connatserdev{
     
    	//FLASH CLASS IMPORTS
    	import flash.display.MovieClip
     
    	public class setNewBox extends MovieClip {
     
    		public function setNewBox(boxXLoc:Number, boxYLoc:Number, boxWidth:Number, boxHeight:Number, boxColor:uint, borderThickness:Number, borderColor:uint, boxRotation:Number) {
     
    			var newBox:MovieClip = new MovieClip()
    			newBox.graphics.lineStyle(borderThickness, borderColor)
    			newBox.graphics.beginFill(boxColor)
    			newBox.graphics.drawRect(boxXLoc,boxYLoc,boxWidth,boxHeight)
    			newBox.graphics.endFill()
    			newBox.rotation = boxRotation
    			addChild(newBox)
     
    		}
    	}
    }

    Now all we need to do to use the class is add some actionscript to the constructor function in newBox.as, as follows:

    1
    2
    3
    4
    5
    
    var boxOne:setNewBox = new setNewBox(20,100,100,20,0xCCCCCC,.5,0x000000, 0)
    addChild(boxOne)
     
    var boxTwo:setNewBox = new setNewBox(100,125,100,20,0x666666,.5,0x000000, 20)
    addChild(boxTwo)

    Finally, here are our final .as files:

    newBox.as

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    
    package com.connatserdev{
     
    	//FLASH CLASS IMPORTS
    	import flash.display.MovieClip
     
    	//CUSTOM CLASS IMPORT
    	import com.connatserdev.setNewBox
     
    	public class newBox extends MovieClip {
     
    		public function newBox() {
     
    			//X, Y, width, height, background color, border thickness, border color, rotation
     
    			var boxOne:setNewBox = new setNewBox(20,100,100,20,0xCCCCCC,.5,0x000000, 0)
    			addChild(boxOne)
     
    			var boxTwo:setNewBox = new setNewBox(100,125,100,20,0x666666,.5,0x000000, 20)
    			addChild(boxTwo)
     
    		}
    	}
    }

    setNexBox.as

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    
    package com.connatserdev{
     
    	//FLASH CLASS IMPORTS
    	import flash.display.MovieClip
     
    	public class setNewBox extends MovieClip {
     
    		public function setNewBox(boxXLoc:Number, boxYLoc:Number, boxWidth:Number, boxHeight:Number, boxColor:uint, borderThickness:Number, borderColor:uint, boxRotation:Number) {
     
    			var newBox:MovieClip = new MovieClip()
    			newBox.graphics.lineStyle(borderThickness, borderColor)
    			newBox.graphics.beginFill(boxColor)
    			newBox.graphics.drawRect(boxXLoc,boxYLoc,boxWidth,boxHeight)
    			newBox.graphics.endFill()
    			newBox.rotation = boxRotation
    			addChild(newBox)
     
    		}
    	}
    }



    Related Articles:

  • Flash Video Player
  • Flash mp3 player
  • AS3: Re-Usable TextFormat class
  • AS3: Using Array and For Loop to create movable panels
  • AS3: Homegrown particles

  • Next Page →