Archive for the ‘ActionScript’ Category

Url Variable in Action script 3

Friday, October 12th, 2007

Thing were easy in Actionscript 2 when you need to pass value from browser to the flash the you could do

  <object classid=“clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″
 codebase=“http://download.macromedia.com/
pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0″ width=“210″ height=“120″>

    <param name=“movie” value=“aflash.swf?var1=value1&var2=value2″>

    <param name=“quality” value=“high”>

    <param name=“wmode” value=“transparent”>

    <param name=“menu” value=“false”>

    <embed src=aflash.swf?var1=value1&var2=value2

width=“210″ height=“120″ quality=“high” 
pluginspage=“http://www.macromedia.com/go/getflashplayer” 
type=“application/x-shockwave-flash” wmode=“transparent” menu=“false”></embed>

Here i am passing two variable var1 and var2
in actionscript i can just refer the variables as var1 and var2 in the main time line or the time line of _root
but in Action script 3 the code goes like this
(Code in the main time line)

var1=this.loaderInfo.parameters.var1;

What is loaderInfo ?
loaderInfo is an object of flash.display.LoaderInfo . It provides information about loaded media such as content type, content length, url , bytesloaded
The Class DisplayObject has a property loaderInfo of type LoderInfo which means all the classes like movieclip, buttons (sub classes of Displaybjet) have this property so does the main time line . so we are using parameters property to get url variable .

no _root in Actionscript 3

Friday, October 12th, 2007

Hey we don’t have _root in ActionScript 3
annoying is it well here is what AS3 has for _root
1) Stage
The Stage class in flash.display package represents the drawing area of the main stage and stage is the ready made object of the Stage so now if you want to put an instance of a movie clip Abc then the code would be

var aClip:Abc=new Abc();
stage.addChild(aClip);

2) this in main time line
this referred to the _root in Action script 2 when you use it in main time line but in Actionscript 3 this refers to the object of MainTimeLine which also extends the class flash.display.DisplayObject