People put cool intro type effect all the time but one of them that i was dying to do through actionscript was time rag. i mean if you look at http://www.2advanced.com for example you can see stuff at the bottom coming in at different timing.
well i finally found out how to do this with action script. i guess it can be done just by animating manually but usually for these kind of thing it's way faster and more acurate to do it via ActionScript.
var speed:Number = .5 * i+1;
var xTween:Tween = new Tween(pp, "x", Back.easeOut, -300, 30, speed, true);
xTween.start();
if you look carefully into it you see a variable i
well yes this is inside the for loop. and iterates for how ever many movie clips that's inside of an array. i was doing this for my new photo gallery i was building.
Here i'm giving a variable speed 0.5 * i + 1
0.5 * i expresses difference in time.
+ 1 is basically an offset value so that the element 0 or the first one will still show up. (0 * anything is 0 so speed or time it takes will be 0 - in Tween class term it means do nothing)
so putting all elements that you want time rags when showing up in an array and create for loop and tween all of them with a bit different speed.
well if you are going to do this for 100 elements it might not work...
I'm still searching for a way to do real time rag which just keeps pause before triggering animation..
maybe if you use eventListever for MOTION_FINISH and 2 tweens it will.
Tuesday, December 04, 2007
Creating the time rag using Tween.
Posted by
SONARHYTHM Logic Pro School
at
1:56 AM
0
comments
Labels: actionscript, actionscript 3.0, adobe, flash, game, OOP, programming
Monday, December 03, 2007
Tweening the filters classes with actionscript 3.0
I was trying to tween blur or glow filters via ActionScript 3.0 and I came across this issue that it doesn't tween. After some trial and error I have figured out ways of tweening filters using tween class.
This really led me to understand tween and filter classes. Basically the object assigned to filters property is an object by itself and it's not a property of the MovieCLip. so the MovieClip cannot be updated unless of course some how reapply the object.
well enough about objects and my rambling so I'll post a code here to make it work.
for example if you are trying to create roll over filter effect.
function rolledOver(e:MouseEvent):void
{
filterTween = new Tween(e.target.bfOver, "blurX", Back.easeInOut, 0, 100, 2, true);
filterTween.addEventListener(TweenEvent.MOTION_CHANGE, updateGraphics);
filterTween.start();
}
function rolledOut(e:MouseEvent):void
{
filterTween = new Tween(e.target.bfOver, "blurX", Back.easeInOut, 100, 0, 2, true);
filterTween.addEventListener(TweenEvent.MOTION_CHANGE, updateGraphics);
filterTween.start();
}
function updateGraphics(e:TweenEvent):void
{
this.filters = [bfOver];
}
This is out of my DynamicButton class so you'll have to tweak a little or create your own but at least I hope you see what I'm doing here. If it successfully compiles then you'll see blur tween over 2 seconds with some easing.
Motion Tween or tween sends out MOTION_CHANGE event when they update properties. you basically catch this event to update the desired MovieClip's appearance.
Actually it was easy.
Now.. please don't ask me about CPU etc... I don't know.
I wish you could control stages or times it calls the function or steps for tween. then you can make it a little easy for CPU or older computers.
anyways, try it out.
Posted by
SONARHYTHM Logic Pro School
at
7:31 PM
4
comments
Labels: actionscript, actionscript 3.0, adobe, game, OOP, programming
Thursday, November 29, 2007
Controlling sound in Flash CS 3 or ActionScript 3.0
I was trying to make an audio player for a web site in flash cs 3 or actionscript 3.0 today and it was more than confusing..
i was reading the references and took me a while before i realized that you had to have bunch of other objects to perform tasks like stopping,..
yes.. stopping sound seems easy but not really in actionscript 3.0..but once you get it you won't forget it.
to make an audio or mp3 player in as3 you need three objects.
Sound() - for loading sounds
SoundChannel() - to control playback, stopping
SoundTransform() - to control volume and panning(Left, right stereo stuff)
SoundChannel has .soundTransfor where you can assign SoundTransform() object
var sound:Sound = new Sound();
var sControl:SoundChannel = new SoundChannel();
var vControl:SoundTransform = new SoundTransform();
so now you have 3 objects. let take a look at how they interrelate
sound.load(new URLRequest("yourSong.mp3"); // get the sound clip
sound.addEventListener(Event.COMPLETE, soundLoaded); // triggers a function soundLoaded on load complete
btnStop.addEventListener(MouseEvent.CLICK, stopSound); // create button with inst name of btnStop on stage for it to work
btnVolumeUp.addEventListener(MouseEvent.CLICK, changeVolume);
function soundLoaded(e:Event):void
{
sControl = sound.play(); // this is the hard part...
}
function stopSound(e:MouseEvent):void
{
sControl.stop(); // sound.stop() won't work for some reason.. or for a good reason..
}
function changeVolume(e:MouseEvent):void
{
vControl.volume += .1; // since volume property's range is 0 to 1
sControl.soundTransform = vControl; // assign that info to control
}
well this should blow up your speaker since it only goes up. try it at your own risk and i didn't tell you to do it. so you can't sue me. you should spend your time in other things like try implementing decreasing volume or much more flexible way of controling volume, etc.
Posted by
SONARHYTHM Logic Pro School
at
9:36 PM
9
comments
Labels: actionscript, actionscript 3.0, flash, OOP, programming
Friday, August 31, 2007
Document Class - Flash ActionScript 3.0 feature
Now you can assign class to a document...
you just define a class, and inside the property window for the document, you should see a text field saying "Document Class"
type in ULR or name for your document class (anything..) and you are good to go.
you can actionscriptically load graphics, etc pretty easily. amazing feature
Posted by
SONARHYTHM Logic Pro School
at
4:39 AM
0
comments
Labels: actionscript, actionscript 3.0, adobe, flash, OOP, programming
