Josh Sager Media: Creative Technologies Blog

Josh Sager Media: Creative Technologies Blog
Creative Technologies Blog
Home | Portfolio |Blog | Presentations | music | About

Posts Tagged ‘ActionScript’

Tween Class vs Tween Lite

Thursday, March 18th, 2010

The Problem

So you’re getting further into Actionscript for your interactive projects and you dip your toe into the pool of programmatic animations. It seems like a good idea. All of your transitions can be managed from a few lines of code in one central place. You happily travel down the road of the Tween Class. You do a few tests, it’s easy to use, the results look great, and set off to implement it into your larger project.

You soon find out that the tween class chokes. It chokes hard and fails at unusual times in spectacular fashion. What do you do? You’ve spent all of this time setting up the Tween Class, and you love the idea of centralized transition control. Don’t worry there’s a great alternative, Tween lite.

Comparison

Here are some examples of the Tween Class and Tween Lite in a typical scenario. There are three buttons that when clicked will transition in 4 “products” of a similar color.

Tween Class Results

Inconsistent. With only a few shapes some of the transition pop in an out. At times the transitions will “stick” before they complete their animations. Even at this very basic level the Tween Class is Shaky at best.

Tween Lite Results

Not bad. Everything is where I expect it to be. Although I’m still a little gun shy from the Tween Class, this appears to be doing everything I need it to. Not to mention installing Tween Lite in place of the Tween Class was really easy.

Turn It Up

Okay now it was time to take Tween Lite to task a bit. To simulate a larger project I increased the number of “products” to 200 per each button click. Although the transition selected may not be appropriate for that amount of products it worked like a champ. Meanwhile the Tween Class couldn’t get more than a few products to animate.

Don’t take my work for it see it for yourself.

How Easy is it Really?

It’s super easy. Just download the Tween Lite framework, import it, and start using it.

Code Comparison

  1.  
  2. // Tween Class
  3.  
  4. import fl.transitions.easing.*
  5. import fl.transitions.Tween;
  6. import fl.transitions.TweenEvent
  7.  
  8. var trans:Tween = new Tween(mc,‘x’,Bounce.easeOut,0,300,1,true)
  9.  
  10. // Tween Lite
  11. import com.greensock.*;
  12. import com.greensock.easing.*;
  13.  
  14. var myTween:TweenLite = new TweenLite(mc, 1, {x:100});
  15. TweenLite.to(mc, 1, {x:300,ease:Bounce.easeOut});
  16.  
  17.  

Very comparable. My favorite thing is you can add an event listener right in the decoration.

  1.  
  2.  
  3. import com.greensock.*;
  4. import com.greensock.easing.*;
  5.  
  6. var myTween:TweenLite = new TweenLite(mc, 1, {x:100});
  7.       TweenLite.to(mc, 1, {x:finish,ease:Bounce.easeOut,onComplete:onTransFinish});
  8.  
  9.  
  10. function onTransFinish():void{
  11.     trace("done")
  12. }
  13.  

Now that’s really easy to use. There are sorts of other great features. Make sure to read the documentation. Greensock did a great job on putting it together.

So if are looking to up your game with programmed transitions or animation, I would check out Tween Lite. It may save you a big head ache in the long run.

Source Files

Just in case you want to poke around and create your own benchmarks I’ve provided my source code for this basic interface.
tweening-benchmark

Flash Workshop for High Schoolers

Monday, March 15th, 2010

Welcome

Today’s Agenda for working in Flash.

Our Goals

  • Explore the interface
  • Create Basic Animations
  • Create Basic Interactions though ActionSctipt

FlashPitt Workshop: Intermediate ActionScript 3.0

Thursday, October 15th, 2009

Slides for the Intermediate ActionScript 3.0 Workshop

FlashPitt is Tomorrow

Wednesday, October 14th, 2009

flashpitt200wspeakerTomorrow is FlashPitt 09 and I’m totally pumped!

My slides are ready, my jokes are horrible, and I’m all prepped and ready to go. I’m boiling with excitement over geeking out with some of the greatest people in the world. I’m really looking forward to seeing old friends and making new ones.  And I’m especially looking forward to the geek debates that I’m sure we’ll have over primanit sandwiches. So Cheers to FlashPitt eve, and all of the wonderfulness that is about to ensue.

P.S.

This year I’ll be doing a workshop on Intermediate ActionScript 3.0 and a session on Creative Interactions: Flash Experiments.

I hope to see there.  There’s an excellent line up this year and it would be insane not to come

Aviod Flash My Ass

Thursday, July 16th, 2009

I am sick and tired of reading web related articles and seeing opinions offered to young designers and developers that tell them to avoid flash. What the hell is that all about? I understand there is a movement towards purist web design and with that no third part plugins or leprechaun magic should be used, but come on. Live in the reality that is all around us. We shouldn’t narrow our view to a certain set of technologies, instead we should strive for a balance of the benefits that each technology might provide. Then the next step which seems to be a lost art, think about your approach and match the best technologies to achieve your goals.

I’m tired of seeing “magic pill” books and articles about creating better websites in 10 easy steps. It’s bull! Design is a craft despite the media that has only one rule. Thought. After that it can go in any direction.

Don’t get me wrong, I think its great that we have web standards and I do my best to follow them when its appropriate. But sometimes it just doesn’t make sense to force all ideas and concepts down a narrow set of parameters. That’s what makes the web so great. We have a plethora of options. If we used the internet the way it was “intended” there would be no e-commerce and well would all still be playing zork through a command line.

I understand there is a lot of bad content and horrible web experiences out there. Both HTML/CSS as well as flash. But why as “opinoin-ists” do so many people feel the need to cast Flash aside? It’s obviously popular. People have been using it for over a decade and the development community has been growing in droves year after year.

Instead of fighting over the proper technology lest instead put our passions towards a better experience and continue to push the bounds of what the technologies were “intended”. Thats when something truly great happens and the world is changed.

Swap Depths for AS 2.0

Saturday, March 21st, 2009

Every now and again I get asked questions about ActionScript 2.0.  Although I would much rather give that person a hug and tell them that AS 3.0 will set them free I know that not everyone can make the jump instantly.

Today I was asked how to swap depths in AS 2.0.  No problem right? Wrong! It seemed like everything I tried was jut not working. After I stepped away for a bit I was able to solve the problem but for the life of me I don’t know what was initially wrong. Nevertheless here is the answer.

  1.  
  2.    // sets swapDepths
  3.    this.swapDepths(this.getNextHighestDepth())
  4.  

This will place a movieClip at the top of the display order.
Demo Files
ActionScript 2.0 Swap Depths Demo - Project File
ActionScript 2.0 Swap Depths Demo

ActionScript 3.0 Brush Up - April 09

Saturday, March 7th, 2009

It’s that time of year again. Spring is in the air, the clocks are going to change again, and the ActionScript 3.0 Brush Up course is back again.

To make things a little easier this year I’ll be posting the slides to what we will be covering. Just download the zip file and you can reference the slides. I’m giving you permission to use this for educational purposes and not for distribution.

Here are the slides and other Resources

Week 1

ActinScript 3.0 Diagram
Week 1 - Slides

Week 2

Week 2 - Slides
Week 2 Examples

Week 3

Week 3 - Slides
Week 3 - Examples

Week 4

Week 4
Week 4 - Sample Files

##### Thanks Guys and Gals I had a great time I hope to hear from you in the future. I always learn a lot from the grads like little tips and tricks that you’ve discovered along the way.  Keep in touch!

Grant Skinners Tweetcode Content

Tuesday, March 3rd, 2009

Grant Skinner, for those of you that don’t know, is a god in Flash community and has once again blown my mind with an idea that I feel like I should have come up with.  He’s got a tweet code contest running with prizes such as Flash CS4, and Friends of Ed books.

The rules are simple.

  1. 140 characters or less
  2. Use only the gimmie code
  3. No use of outside code
  4. Be super creative
  5. Post to your twitter account

Here’s my contribution in al of it’s 67 character glory.  I call it the color snake.

xp=mouseX;yp=mouseY;ls(i,i*1e5,1);if(i==0)mt(xp,yp);lt(xp,yp);i++;

There are lots of great submissions. You could be one of them.  Check it out!

Flash Note Card Experiment

Sunday, December 28th, 2008

I’m experimenting with flash for a project I’m hoping to launch in the 1st quarter of next year. It uses a note card metaphor to explore some of the content.  After sketching out the concept it was time to go to work.

The Prototype

Note Card Experiment Prototype

I developed this prototype to show a basic idea of how it could work.  It’s still very rough and doesn’t have any of the graphics, but I thought it was kind of fun.

Prototype Features

  • The concept is to show other “cards” of information
  • The “cards” flip out behind the top cards when you click the closed card
  • The number of subsequent “cards” can change
    • You can change the number of cards from the input box
  • The opened cards can be “panned” or “dragged”
  • The cards will close when the close button is clicked

Actionscript 3.0: TextField in a MovieClip Target Issue

Thursday, September 11th, 2008

The Problem
Targeting a MovieClip when a dynamic text box is the only thing in the movie clip.

  1. trace(e.target.name);
  2. //outputs the text box name and not the movie clip name

The Solution
Target the parent. Technically the dynamic text box is a child of the MovieClip.

  1. trace(e.target.parent.name)
  2. // outputs the movie clip name

In Action

download the source file