Playing with Pixels

i was just playing with pixels and BitmapData
the code is a little messy and is not optimized

at the end we didn’t use it on production but is a really nice mouse trial
hope you like it!
source files

Posted in AS3, General | Tagged | Leave a comment

Mouse Trap

ppiiiiuuuuuf! it’s been a whilee uh!!

now that we release the Energy Lab we have some time to post something!
if you go there you’ll find a really cool mouse effect
and here is a quick prototype in AS2 of how we build it

mousetrap

(just try to get inside of the box)

source files

Posted in General | Leave a comment

Grupow is hiring!

Location: Saltillo, Coah. Mexico

Position: Flash ActionScript/Flex developer

Information:

Mandatory technical skills:

• 3+ years experience in ActionScript 2.0 or 3.0 for Flash applications integrated with server-side web applications and CMS
• Papervision knowledge
• Experience implementing OOP concepts with ActionScript
• Experience integrating streaming media
• Building integrated data-driven applications
• Source control

Communication skills:

• Outstanding problem-solving and communication skills
• Available to work in-house during work hours – Monday - Friday
• Team player and leadership skills

Ideal additional skills:

• SWF address
• AIR
• Experience in building social networking and community systems, which include context and video tagging, streaming media and other advanced online communication features

Desired additional skills:

• Experience in PHP/MySQL
• CMS experience

To Apply:

Please send a copy of your CV with portfolio and examples of sites directly to rcalderon@grupow.com

Posted in General | 2 Comments

Flash CS4 update (10.0.2)

yei!!! finally the desired update arrived ! =D
no more crashes for bad fonts =D

you can read the full list of changes at: swfgeek
by the way is a huge list!!

and more info at: Richard Galvan post

Posted in General | 2 Comments

AS3 Dumper

i just found at libspark this handy class
it’s just like the ObjectDumper Class from AS2 =D
and has the ability to throw the message to the firebug console =D

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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
package org.libspark.utils 
{
    import flash.external.ExternalInterface;
    import flash.utils.getQualifiedClassName;
 
    /**
     * <p>Data????????????perl?Data::Dumper???????
     * ???????????Object, Array, Number, String, Boolean???
     * XML?????????????????
     * ??????FireBug?console???????????????????????
     * debug, info, warn, error ???????????????</p>
     * <listing>
     * package {
     *    import org.libspark.utils.Dumper;
     *    public Class Hoge {
     *        var test:Object = { a:'hoge', b:'fuga'};
     *        Dumper.debug(test);
     *        trace(Dumper.toString(test));
     *    }
     *    // output
     *         $var0 = {
     *                     'a' => 'hoge',
     *                     'b' => 'fuga',
     *                 }
     *     
     * }</listing>
     * @author dealforest
     * @version 0.102
     */
 
    public class Dumper {
 
        private static const INDENT:String = "    ";
        /*
         * @default 4tab
        */
        private static var _dumpString:String = "";
 
        /**
         * ????????????????????
         *
         * @param args ???????(????)
         * @return _txt ??????????????????
         */
        public static function toString(... args):String {
            var _txt:String = _dumpString = '';
            for (var a:String in args)
                _txt += parse(args[a]);
            return _txt;
        }
 
        /**
         * FireBug???????'debug'?????
         *
         * @param args ???????(????)
         */
        public static function debug(... args):void {
            if (!ExternalInterface.available) return;
 
            var _txt:String = _dumpString = '';
            for (var a:String in args)
                _txt += parse(args[a]);
            //interim action for IE
            ExternalInterface.call('function (txt) { try { console.log(txt); } catch (e) {}; }', _txt);
        }
 
        /**
         * FireBug???????'info'?????
         *
         * @param args ???????(????)
         */
        public static function info(... args):void {
            if (!ExternalInterface.available) return;
 
            var _txt:String = _dumpString = '';
            for (var a:String in args)
                _txt += parse(args[a]);
            //interim action for IE
            ExternalInterface.call('function (txt) { try { console.info(txt); } catch (e) {}; }', _txt);
        }
 
        /**
         * FireBug???????'warn'?????
         *
         * @param args ???????(????)
         */
        public static function warn(... args):void {
            if (!ExternalInterface.available) return;
 
            var _txt:String = _dumpString = '';
            for (var a:String in args)
                _txt += parse(args[a]);
            //interim action for IE
            ExternalInterface.call('function (txt) { try { console.warn(txt); } catch (e) {}; }', _txt);
        }
 
        /**
         * FireBug???????'error'?????
         *
         * @param arg ???????(????)
         */
        public static function error(... args):void {
            if (!ExternalInterface.available) return;
 
            var _txt:String = _dumpString = '';
            for (var a:String in args)
                _txt += parse(args[a]);
            //interim action for IE
            ExternalInterface.call('function (txt) { try { console.error(txt); } catch (e) {}; }', _txt);
        }
 
        /**
         * ????????????????????
         *
         * @param arg ???????(??????1?)
         * @return ?????????????
         * @private
         */
        public static function parse(arg:*):String {
            var argIndent:String = ('$var'+ ' = ');
            _dumpString += argIndent;
            inspect(arg, argIndent.replace(/./g, ' '));
            _dumpString += '\n';
           return _dumpString;
        }
 
        /**
         * ?????????????????????
         *
         * @param arg ???????(??????1?)
         * @param indent ????????
         * @private
         */
        private static function inspect(arg:*, indent:String):void {
            var bracket:Object;
 
            switch (getQualifiedClassName(arg)) {
                case 'Object':
                    bracket = {start: '{', end: '}'};
                case 'Array':
                    bracket ||= {start: '[', end: ']'};
                    _dumpString += bracket.start + '\n';
                    recursion(arg, indent + INDENT);
                    _dumpString += (indent +bracket.end);
                    break;
                default:
                    _dumpString += format(arg, indent, true);
            }
        }
 
        /**
         * ?????????????????
         *
         * @param arg ???????(??????1?)
         * @param indent ????????
         * @private
         */
        private static function recursion(arg:*, indent:String):void {
            for (var index:String in arg) {
                var tmp:* = arg[index];
                var className:String = getQualifiedClassName(tmp);
                var bracket:Object;
 
                switch(className) {
                    case 'Object':
                        bracket = {start: '{', end: '}'};
                    case 'Array':
                        bracket ||= {start: '[', end: ']'};
                        var str:String = (getQualifiedClassName(arg) == 'Object')
                            ? '\'' + index + '\' => ' : '';
                        var indent_str:String = str.replace(/./g, ' ');
 
                        _dumpString += (indent + str + bracket.start + "\n");
                        recursion(tmp, indent + indent_str + INDENT);
                        _dumpString += (indent + indent_str + bracket.end + ",");
                        break;
                    default:
                        _dumpString += format(tmp, indent, false, arg, index);
                }
                _dumpString += "\n";
            }
        }
 
        /**
         * ??????????????????
         *
         * @param target ?????Object
         * @param indent ????????
         * @param braket ,??????????
         * @param parent ?????Object
         * @param index Object?key
         * @return ???????????????
         * @private
         */
        private static function format(target:Object, indent:String, bracket:Boolean, parent:* = null, index:String = null):String {
            var className:String = getQualifiedClassName(target);
            var str:String = "";
 
            if (getQualifiedClassName(parent) == 'Object')
                return indent +  "\'" + index + "\'" + " => " + target + (bracket ? '' : ',');
 
            switch (className) {
                case 'String':
                    return (bracket)
                        ? "\'" + target + "\'"
                        : indent + "\'" + target + "\',";
 
                case 'Array':
                case 'int':
                case 'uint':
                case 'Number':
                case 'Boolean':
                    return (bracket)
                        ? target.toString()
                        : indent + target.toString() + ",";
                default:
                    return 'don\'t analyze';
            }
        }
    }
}

from Dumper Class

check it out libspark.org they have very interesting things in their repository

by the way, the japanese characters doesn’t display in my browser =(

Posted in General | Leave a comment

Random Points inside a Triangle

just copy and paste the following code:

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
 
function getRandomPointInTriangle (A:Point,B:Point,C:Point):Point {
 
	//P = aA + bB + cC
	//@see http://www.cgafaq.info/wiki/Random_Point_In_Triangle
 
	var a:Number = Math.random();
	var b:Number = Math.random();
 
	if (a + b > 1) {
		a = 1-a;
		b = 1-b;
	}
 
	var c:Number = 1-a-b;
 
	var rndX:Number = (a*A.x)+(b*B.x)+(c*C.x);
	var rndY:Number = (a*A.y)+(b*B.y)+(c*C.y);
 
	return new Point(rndX,rndY);
}
 
 
var triangleHeight:uint = 150;
var triangleShape:Shape = new Shape();
triangleShape.graphics.lineStyle(1,0xff0000);
triangleShape.graphics.moveTo(triangleHeight/2, 5);
triangleShape.graphics.lineTo(triangleHeight, triangleHeight+5);
triangleShape.graphics.lineTo(0, triangleHeight+5);
triangleShape.graphics.lineTo(triangleHeight/2, 5);
addChild(triangleShape);
 
 
var p1:Point = new Point(triangleHeight/2, 5);
var p2:Point = new Point(triangleHeight, triangleHeight+5);
var p3:Point = new Point(0, triangleHeight+5);
 
//
//
//
//
 
var source:BitmapData = new BitmapData(triangleHeight,triangleHeight,true,0);
var bitmap:Bitmap = new Bitmap(source);
 
var sprite:Sprite = new Sprite();
sprite.addChild(bitmap);
addChild(sprite);
 
 
source.fillRect(source.rect,0);
source.lock();
 
for (var i:int = 0;i<50;i++) {
	var p:Point = getRandomPointInTriangle(p1,p2,p3);
	source.setPixel32(p.x,p.y,0xffff0000);
}
 
source.unlock();

Cheers!

Posted in AS3 | Leave a comment

Always on Top

today i found my self trying to put an Sprite on the top of the display list
so here is the basic idea for solve that problem

1
2
3
4
5
6
7
8
9
10
11
 
function alwaysOnTop_handler(e:Event):void {
	//make this child always on top!
	parent.addChild(this);
}
 
function added_handler(e:Event):void {
	parent.addEventListener(Event.ADDED, alwaysOnTop_handler, false, 0, true);
}
 
addEventListener(Event.ADDED_TO_STAGE, added_handler, false, 0, true)

cheers!

Posted in AS3, General | Tagged | 1 Comment

Grupo W @ badFonts group [ Flash CS4 text properties issue ]

Using the Flash CS4 i had a little problem… everytime i tried to use the text tool, either flash crashed after or before even putting the text box on stage.

Thinking it was a flash bug i google search it… i found this.

i read only a few top posts and found that the issue was the computer performance, but then David here at W has the same computer as me. After formatting my pc flash was running ok, so there, problem fixed!

BUT when i put all of my stuff back in, again flash was doing the same thing. After a few hairs pulled and desks banged, we discover that it was the fonts i installed in the pc the day before, and going back to the link i found , reading all of the posts, Raúl found that same solution posted there.

What did we learn from this?
1: you don’t need to install every font you find.
2: read a little more before taking actions with the first post you find XD so you don’t have to format your computer in vain. XD

Posted in General | Tagged , , , | 3 Comments

Validating a String

well this is a handy code snippet to validate a string
if you want to avoid some bad words, this is for you:

1
2
3
4
5
6
7
8
9
10
11
12
 
function isValid(str:String):Boolean {
        var regExp:RegExp = /\b(badword|nastyWord)\b/i;
	var _isValid:Boolean = !regExp.test(str);
        return _isValid;
}
 
var _inValidMessage = "this is a example for a bad badword it's really nasty";
var _validMessage = "Hello Word!";
 
trace(isValid(_inValidMessage)) //false
trace(isValid(_validMessage))//true

you can add more words just separating them by a pipeline ( | ) in the Regular Expression

Cheers.

Posted in AS3, General | Tagged | Leave a comment

wowFlag [flarToolkit + pv3d + wowEngine]


wowFlag from Wolf on Vimeo.

As promised on youtube: here it’s the source

( thx to saqoosha for the help on the flarToolkit issue of translating the flag fixed vertex… you can find his example of doing this on his site, but he maded it for away3d =) )

the code is very extended, so if you have any doubts post them here, we will try and answer all of them :)

Posted in AS3, papervision3d | Tagged , , , , | 6 Comments