1+1=window

Tweening & Scaling a Movieclip from a button

Posted in Actionscript 2 by shanDB on January 29, 2009

So I have movie clip that contains an image, and want to move (tween) and change the dimensions (scale) the movieclip when I press a button..

My button instance name is: BTN1 – Note that this needs to beĀ  a movieclip (not a button at all)

My Movieclip instance name is: myMovieClip – and in this case is actually on the root timeline

Here’s how:

import mx.transitions.Tween;
import mx.transitions.easing.*;

BTN1.onPress = function(){
new Tween(_root.myMovieClip,”_x”,Strong.easeOut
,
_root.myMovieClip._x, 40,2,true);//2 is the num of seconds
new Tween(
_root.myMovieClip,”_y”,Strong.easeOut,_root.myMovieClip._y, 100,2,true);
new Tween(
_root.myMovieClip,”_width”,Strong.easeOut,_root.myMovieClip._width,600,2,true);
new Tween(
_root.myMovieClip,”_height”,Strong.easeOut,_root.myMovieClip._height,600,2,true);
}

Button Link To Another Movieclip

Posted in Actionscript 2 by shanDB on July 22, 2008

A little tip for those getting aquainted with Actionscript.

So I have a button inside a movieclip called MC1. I need this button to link to a label called HOME on a totally different movieclip called MC2. Here’s the code that should be placed on a seperate layer to the button:

button_name.onRelease=function(){

_root.MC2.gotoAndPlay(“home”);

}

Or, alternately you could place the following script directly on the button (Not on a seperate layer):

on(release){

_root.MC2.gotoAndPlay(“home”);

}

In the case that MC1 was inside MC2 rather than being completely seperate, you could use parent:

on(release){

_parent.gotoAndPlay(“home”);

}

External SWF With Dynamic Content – Green Border Fix

Posted in Actionscript 2 by shanDB on July 22, 2008

I found that when trying to load an external SWF that contained dynamic content into a movieclip, an unwanted green border was appearing around the external SWF when testing it in my browser. Here’s the fix:

  • Create an ampty movieclip with the instance name STAGE
  • Add a behaviour to load external movie clip onto the STAGE
  • Add the following actionscript (AS2) on a seperate layer:

stage._lockout=true; /* gets rid of the green border bug */

stage.loadMovie(“external_swf.swf”);