scrubbing video [NetStream]
Filed under Lab Work, Programming | Tags:Actionscript 3,Flash,math
I always like to do my video players from the ground up…i guess it’s just my style. I have used often the FLVPlayback, but there is a satisfaction in creating your own player. One thing that always plays with my head is the scrubbing. It’s the actual Math that gets me, and generally, i get it after a few tries…but never on the first (much like the custom scrollbar) . Read the rest of this entry »
shared font library, programatic textfields, and css
Filed under Lab Work, Programming | Tags:Actionscript 3,embedFont,Flash,fonts,share library,text
recently, i was tasked to do a gallery of images with captions. A few cavates to the request:
- we must use a shared library.
- we can not embed fonts to the working fla
- captions must be html enabled
…and so begins the dissection of Flash and Fonts Read the rest of this entry »
Sandisk YouTube Brand Channel
Filed under LoomisGroup, Programming, Projects | Tags:Actionscript 3,api,Flash,Javascript,Papervision
Papervision 3D, Local Connections and YouTube’s api create an exciting off the ground experience.
Read the rest of this entry »Orbit in Papervision, the real way and the easy way
Filed under Lab Work, Programming | Tags:Actionscript 3,Flash,math,papervision3d
I have been working with papervision3D only a bit now, and really starting to get the concepts of the camera, 3D space, containers, prmitives, etc. The hardest part by all means has been knowing/learning when to manage the camera vs just the container object holding 3D objects. A hot tip (up for dispute) from one of our motion designers was to try not to move the camera and to rely on the container rotation. This is great, if the background is static and has no need to relay an orbiting effect. However, in my case, i needed the camera to swing around the object in question. Knowing that, my approach was to “fasten” the camera to a virutal boom. Essentially, this “boom” would be an empty DisplayObject3D that will spin. The camera would in turn respond to that rotation accordingly.
So, into Trigland we go. Like all Flash trig mind games, the only thing you will need is an angle and a radius. The rest was done thousands of years ago by the greeks using their good friends cosine and sine.
[NOTE: i have to give all the math credit to Tyler Egeto from a post at the DDBlog, here . Tyler, you don't know it, but thanks.]
//calling the method below from my render loop(enterFrame) private function setCamera() : void { var rdx = boom.rotationX *(Math.PI/180); //rotation in radians var rdy = boom.rotationY *(Math.PI/180); //rotation in radians var radius = boom.distanceTo(cam); /*----------------------------------------------------------------------> //Egeto's original math follows the mouse movement. A very cool effect: var theta = mouseX*0.02; var phi = mouseY*0.02; cam.x = radius * Math.cos(theta) * Math.sin(phi) cam.z = radius * Math.sin(theta) * Math.sin(phi) cam.y = radius * Math.cos(phi); //however i want to follow the "boom", so i need to change up a few things in the formula //(not the swap of sin and cos, as well as the cam.x swap with cam.y) ---------------------------------------------------------------------->*/ var theta = rdx var phi = rdy cam.y = radius * Math.sin(theta) * Math.cos(phi) cam.z = radius * Math.cos(theta) * Math.cos(phi) cam.x = radius * Math.sin(phi); } however, let it be known, the same guy who told me to resist moving the camera (and also knows very little about code), seemed to know enough to bring the orbit method into a useful purpose. cam.orbit(90,boom.rotationY,true,boom);
ha!. Well, not all for nothing. Practicing the trig is hugely necessary and will no doubt pay off another day.
Local Connection as2 to as3, and back
Filed under Lab Work, Programming | Tags:Actionscript 2,Actionscript 3,Flash,LocalConnection
It’s been a while because things are so crazy busy. The last few weeks has been all about papervision. 3D is totally new to me. The terminology, 3D vertices, Matrix, etc…it’s deep…literally. Anyway, today’s post is not about that. I was tasked with importing the youtube chromeless player into papervision. This meant i had to also create the player controls. However, before doing anything, i needed to get these guys to talk with each other. Getting as3 to talk to as2 was no problem. A new local connection object, set a connection ‘frequency’ (using the connect method) get’s the one way communication all set up. Going the other way (from as2 to as3) was as simple, just not as intuitive. It comes down to the following key points:
- each swf needs two local connection objects – one to send, one to receive. Both objects will have unique connection names. However, all connection names must be shared in each swf.
- the as3 swf uses a ‘client’ (a generic object or custom class) to receive the events from as2. -ie…the callback. that was the key for me
in all, here is a generic sample (source)
as2:
var lcGet:LocalConnection = new LocalConnection() lcGet.connect('as2bridge') var lcSend:LocalConnection = new LocalConnection() lcGet.command = function(method:String,args:Array) { trace('command received'+method+" "+args); var ob:Object = this ob[method].apply(this,args[0]); textbox.text = args; lcSend.send('fromAs2','callingBackToAs3','yipeeeee!') } function write(msg:String) { textbox.text = msg; } textbox.text = ' i am the as2 swf';
as3 class
package com.loomisgroup { import flash.display.*; import flash.events.*; import flash.net.*; public class AS3Bridger extends MovieClip { public var ld:Loader; public var lcGet:LocalConnection; public var lcRec:LocalConnection; public var rec:LocalConnection; public function AS3Bridger():void { lcGet = new LocalConnection() ; lcGet.addEventListener(StatusEvent.STATUS,onStatus) lcRec = new LocalConnection() lcRec.connect('fromAs2'); var myClient = new Object(); lcRec.client = myClient; myClient.callingBackToAs3 = function (e){trace(e,'is the call back from as2')}; var req:URLRequest = new URLRequest(); req.url = 'as2.swf'; ld = new Loader(); ld.contentLoaderInfo.addEventListener(Event.COMPLETE,loaded); ld.load(req); addChild(ld); } public function onStatus(e:StatusEvent):void { trace('calling back now') } public function loaded(e:Event):void { var m = this.getChildByName('mc') m.addEventListener(MouseEvent.CLICK,cl)</code> } private function cl(e:MouseEvent) { lcGet.send('as2bridge','command','write','and now it is as3'); } } }





