| Subcribe via RSS

Viagra online
XANAXadderall onlineLevitraPuppies for sale

Convert String to MovieClip in Flash AS3

March 16th, 2010 | No Comments | Posted in ActionScript 3

Pretty straightforward:

 
function doClick(e:Event):void {
    this[e.target.name].gotoAndStop('over')
}
 

Of course, in the case above you could actually just use:

 
e.currentTarget.gotoAndStop('over')
 
Tags: , , , ,

AS3 MovieClip Arrays & Loops

March 16th, 2010 | No Comments | Posted in ActionScript 3

I'm often tasked with applying the same listeners & properties to multiple MovieClips in Flash. The easiest is to store the MovieClips in an array:

 
var navButtons=[navCompanyMC,navNewsMC...];
 

Then you can simply iterate over them:

 
var i=1;
for (i in navButtons) {
  doSomethingToClip(navButtons[i]);
}
 

Sample usage:

 
public function doBuild():void {
  var navButtons=[navCompanyMC,navNewsMC...];
  var i=1;
  for (i in navButtons) {
    registerEachButton(navButtons[i]);
  }
}
function registerEachButton(clip:MovieClip):void {
  clip.buttonMode=true;
  EventManager.addEventListener(clip,MouseEvent.MOUSE_OVER,doRollOver,false,0,true,true);
  EventManager.addEventListener(clip,MouseEvent.MOUSE_OUT,doRollOut,false,0,true,true);
  EventManager.addEventListener(clip,MouseEvent.CLICK,doClick,false,0,true,true);
}
function doRollOver(e:Event):void {
  //trace(e.target.name)
  e.currentTarget.gotoAndStop('over');
}
function doRollOut(e:Event):void {
  trace(e.target.name);
  e.currentTarget.gotoAndStop(1);
}
function doClick(e:Event):void {
  trace(e.target.name);
}
 
Tags: , , ,

Flash AS3 - Calling a Method in a Parent Class

March 10th, 2010 | No Comments | Posted in ActionScript 3

When loading a movie in a movie, here's an easy way to call a method within a parent class:

 
  if(this.parent != null){
    var parentObject:Object = this.parent as Object;
    parentObject.doShowMain()
  }
 
Tags: , , ,

ClickTag in AS3

March 5th, 2010 | No Comments | Posted in ActionScript 3

To build a ClickTag in Flash AS3 you need to first create the ActionScript:

 
clickTrackBTN.buttonMode=true; //using an MC for button so I need to declare it
clickTrackBTN.addEventListener(MouseEvent.CLICK,function():void { navigateToURL(new URLRequest(formatClickTag()),"_blank"); });
//the function
function formatClickTag():String {
  for (var key:String in root.loaderInfo.parameters) {
    if (key.toLowerCase()=="clicktag") {
      return root.loaderInfo.parameters[key];
    }
  }
  return "";
}
 

Remember to import any needed classes:

 
import flash.display.MovieClip;
import flash.events.*;
import flash.net.navigateToURL;
import flash.net.URLRequest;
 

Then, in the HTML:

 
..."flashvars",'clickTAG=http://www.yourdomain.com&clickTarget=_blank', ...
and
<param name='flashvars' value='clickTag=http://www.yourdomain.com&clickTarget=_blank' />