JSFL Extensions

Hi everyone!, well we want to share you all the JSFL Commands that we found on the web,
these extensions have been very useful here at GrupoW our productivity increased like a 98%
and the graphic designer team have blessed us =D so here they are!!

  • Add Stop Frames.jsfl
  • All Bitmaps Lossless Compression.jsfl
  • convertoToSymbol.jsfl
  • Create Invisible Button.jsfl
  • Distribute To Frames.jsfl
  • DontUseImportedCompression.jsfl
  • Find In Library.jsfl
  • Funciton Order Library.jsfl
  • Linkage equals to Name.jsfl
  • Multiple Library Linkage.jsfl
  • Multiple Library Renamer.jsfl
  • Multiple Library UnLinkage.jsfl
  • ResetTransPoints.jsfl
  • SetCompressionLevel.jsfl
  • Smooth All Bitmaps.jsfl
  • Unsmooth All Bitmaps.jsfl
  • UseImportedCompression.jsfl
  • UseLosslessCompression.jsfl
  • i think you don´t need an explanation in how to install it and how to use it, they are very self descriptive

    DownThemAll!

    use them wisely

    if you know about other useful extensions don’t hesitate on posting them

    GrupoW Developer Team

    Posted in General | Leave a comment

    [ papervision3d ] Texture switch at runtime

    Here we have a quick example on how to change the texture of a primitive object in papervision3d…

    At the end this is what you get:

    The Flash plugin is required to view this object.

    This is the Document Class, its pretty simple and the methods are self descriptive so i don’t think you’ll have any trouble using it :

    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
    
    package  
    {
    	import flash.display.Bitmap;
    	import flash.display.BitmapData;
    	import flash.display.Sprite;
    	import flash.display.MovieClip;
    	import flash.events.Event;
    	import flash.events.MouseEvent;
    	import flash.display.SimpleButton;
    	import org.papervision3d.view.BasicView;
    	import org.papervision3d.objects.primitives.Plane;
    	import org.papervision3d.materials.BitmapAssetMaterial;
    	import org.papervision3d.cameras.Camera3D;
    	import org.papervision3d.scenes.Scene3D;
    	import org.papervision3d.view.Viewport3D;
    	import org.papervision3d.render.BasicRenderEngine;
     
    	/**
    	* ...
    	* @author Wolfito
    	*/
    	public class Main extends Sprite
    	{
     
    		private var scene:Scene3D;
    		private var camera:Camera3D;
    		private var viewport:Viewport3D;
    		private var render_engine:BasicRenderEngine;
    		private var my_plane:Plane;
    		private var active_index:int = 0;
     
    		public function Main() 
    		{
    			create3dEnviroment();
    			buildPlane();
    			setEvents();
    			render3d();
    		}
     
    		private function create3dEnviroment():void
    		{
    			camera = new Camera3D();
    			scene = new Scene3D();
    			viewport = new Viewport3D(0, 0, true, true);
    			addChild(viewport);
    			render_engine = new BasicRenderEngine();
    		}
     
    		private function setEvents():void
    		{
    			//
    			stage.addEventListener(MouseEvent.MOUSE_OVER, startRendering, false, 0, true);
    			stage.addEventListener(Event.MOUSE_LEAVE, stopRendering, false, 0, true);
    			//
                           // button placed on the stage:
    			this.switchButton.addEventListener(MouseEvent.CLICK, switchTexture, false, 0, true);
    		}
     
    		private function startRendering(e:MouseEvent):void 
    		{
    			if (!this.hasEventListener(Event.ENTER_FRAME))
    			{
    				this.addEventListener(Event.ENTER_FRAME, render, false, 0, true);
    			}
    		}
     
    		private function stopRendering(e:Event):void 
    		{
    			this.removeEventListener(Event.ENTER_FRAME, render);
    		}
     
    		private function buildPlane():void
    		{
    			var texture:BitmapAssetMaterial = new BitmapAssetMaterial("Pocoyo_0");
    			texture.smooth = true;
    			my_plane = new Plane(texture, 500, 500, 4, 4);
    			scene.addChild(my_plane);
    			camera.target = my_plane;
    		}
     
    		private function render(e:Event):void
    		{
    			render3d();
    			moveCamera();
    		}
     
    		private function render3d():void
    		{
    			render_engine.renderScene(scene, camera, viewport);
    		}
     
    		private function moveCamera():void
    		{
    			camera.x = (this.stage.mouseX - (this.stage.stageWidth / 2)) * 2;
    			camera.y = (this.stage.mouseY - (this.stage.stageHeight / 2)) * 2;
    		}
     
    		private function switchTexture(e:MouseEvent):void
    		{
    			var bitmapData:BitmapData;
    			if (active_index == 0)
    			{
                                   //get bitmap linked from the library:
    				bitmapData = new Pocoyo_1(283, 283);
    				active_index = 1;
    			}
    			else
    			{
                                   //get bitmap linked from the library:
    				bitmapData = new Pocoyo_0(283, 283);
    				active_index = 0;
    			}
    			my_plane.material.bitmap.dispose();
    			my_plane.material.bitmap = bitmapData;
    			my_plane.material.updateBitmap();
    		}
    	}
     
    }

    you can download the source code too! =)

    Posted in AS3, papervision3d | Tagged , | Leave a comment

    Sending Variables in AS3 A.K.A. sendAndLoad in AS2

    in AS2 sending and receiving variables was easy, you could do it even with your eyes closed =D
    but in AS3 is another story

    remember AS2??

    1
    2
    3
    4
    
    var lv:LoadVars = new LoadVars();
    lv.username = "ruliman";
    lv.password = "123456";
    lv.sendAndLoad("somefile.php",lv,"POST");

    nice isn’t??

    in AS3

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    
    var variables:URLVariables = new URLVariables();
    variables.username = "ruliman";
    variables.password= "123456";
    //
    trace(variables.toString());
    var request:URLRequest = new URLRequest("somefile.php");
    request.method = URLRequestMethod.POST;
    request.data = variables;
     
    var loader:URLLoader = new URLLoader();
    loader.dataFormat = URLLoaderDataFormat.VARIABLES;
     
    try{
    	loader.load(request);
    }
    catch (error:Error) {
    	trace("Unable to load URL");
    }

    until here you can say “well it isn’t too bad just a bunch of classes, but is better organized =) i love AS3 ”

    but……..when you compile Flash tell you this!

    Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
    at Error$/throwError()
    at flash.net::URLVariables/decode()
    at flash.net::URLVariables$iinit()
    at flash.net::URLLoader/flash.net:URLLoader::onComplete()

    MUAHAHAAA!!!

    the PHP code is simple

    1
    2
    3
    4
    
    <?
    $user= $_POST["username "];
    $pass= $_POST["password"];
    ?>

    so…………where the error is coming from??
    i google it and found this answer, is very simple:
    my php wasn’t returning something so, put an echo throwing some variable something like:

    1
    2
    3
    4
    5
    6
    
    <?
    $user= $_POST["username "];
    $pass= $_POST["password"];
     
    echo "result=success";
    ?>

    and that’s it everything compiles normal, now i can go back to dinner =D

    Posted in AS3 | 8 Comments

    VerifyError: Error #1025 or Error from hell

    i was trying to read an XML with namespaces and then Flash throw me this weird error

    VerifyError: Error #1025: An invalid register 3 was accessed

    then we found that was beacuse of these lines (locally declared in a function)

    1
    2
    
    var ns = ttXML.namespace();
    default xml namespace = ns;

    the error comes when you try to call some function after those lines in your code

    the solution that we found was declare ns variable outside of the function
    and then everything works fine =D

    Posted in AS3 | 1 Comment

    SoundItem Class

    well we start with this Sound Util, just embed the SoundTransform and SoundChannel in one single Class and the fade ability (uses Tween Lite)

    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
    
    package com.grupow.media 
    {
    	import flash.media.Sound;
    	import flash.media.SoundChannel;
    	import flash.media.SoundLoaderContext;
    	import flash.media.SoundTransform;
    	import flash.net.URLRequest;
     
    	import gs.TweenLite;
    	import gs.easing.Linear;
     
    	/**
    	* ...
    	* @author Raúl Uranga
    	*/
    	public class SoundItem extends Sound
    	{
     
    		private var _channel:SoundChannel
    		private var _soundTransform:SoundTransform;
     
    		public function SoundItem(stream:URLRequest = null,conext:SoundLoaderContext = null) {
     
    			super(stream,conext);
     
    			_soundTransform = new SoundTransform();
     
    		}
     
    		public function fade(volume:Number,ms:int = 1000,handler:Function = null):void
    		{
    			//
    			if (volume < 0)
    				volume = 0;
    			//
    			if (volume > 1)
    				volume = 1;
    			//	
    			TweenLite.to(this, ms/1000, {volume:volume,ease:Linear.easeNone,onComplete:handler});
    		}
     
    		public override function play(startTime:Number = 0,loops:int = 0,sndTransform:SoundTransform = null):SoundChannel
    		{
    			if(sndTransform != null)
    				_soundTransform = sndTransform; 
     
    			_channel = super.play(startTime, loops, _soundTransform);
    			return _channel;
    		}
     
    		public function stop():void
    		{
    			try {
    				_channel.stop();
    			}catch (e:*) {
    				//trace("SoundItem Error: SoundChannel is not defined, you need to start playing");
    			}
    		}
     
     
    		public function get volume():Number
    		{ 
    			return _soundTransform.volume;
    		}
     
    		public function set volume(value:Number):void 
    		{
    			_soundTransform.volume = value;
     
    			try {
    				_channel.soundTransform = _soundTransform;
    			}catch (e:*) {
    				//trace("SoundItem Error: SoundChannel is not defined, you need to start playing");
    			}
    		}
     
    	}
    }

    code available at google code

    cheers!

    Posted in AS3 | 1 Comment

    Welcome!

    Hi everyone! we’re pleased to start labs.grupow, here you will find some code examples, tutorials and AS3 headaches!

    cheers!

    Posted in General | 3 Comments