tag:blogger.com,1999:blog-33352219680819446002024-03-05T05:41:32.050-07:00Flash ActionScript 3 (AS3) Snippets for MortalsVery simple snippets that tell you just what you need to solve everyday ActionScript tasks.Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.comBlogger31125tag:blogger.com,1999:blog-3335221968081944600.post-45085347770326403522010-11-02T14:55:00.000-06:002010-11-02T14:55:47.332-06:00Putting a PayPal Donation Button In FlashThis was a real mysterious one but I think I figured it out. <br />
<br />
Here is the code for donating a fixed amount. This option adds an item at the dollar amount you set to the PayPal cart:<br />
<br />
<pre>var variables:URLVariables = new URLVariables();
variables.cmd = "_cart";
variables.add = "1";
variables.amount = String( TOTAL DOLLAR AMOUNT HERE );
variables.business = " YOUR PAYPAL EMAIL HERE ";
variables.item_name = "Item 1";
variables.item_number = "123456789";
variables.tax = "0";
variables.currency_code = "USD";
variables.page_style = "PayPal";
variables.no_shipping = "0";
variables.undefined_quantity = "1";
variables.rn = "1";
variables.shipping = "0";
variables.shopping_url = "http://www.salvationarmyusa.org";
var request:URLRequest = new URLRequest("https://www.paypal.com/cgi-bin/webscr");
request.method = URLRequestMethod.POST;
request.data = variables;
navigateToURL(request, "_self");
</pre><br />
Here is the code for donating an amount decided by user:<br />
<br />
<pre>var variables:URLVariables = new URLVariables();
variables.cmd = "_donations";
variables.add = "1";
variables.business = "YOUR PAYPAL EMAIL GOES HERE";
variables.item_name = "Donation to Salvation Army";
variables.item_number = "123456789";
variables.tax = "0";
variables.currency_code = "USD";
variables.page_style = "PayPal";
variables.no_shipping = "0";
variables.undefined_quantity = "1";
variables.rn = "1";
variables.shipping = "0";
variables.shopping_url = "http://www.salvationarmyusa.org";
var request:URLRequest = new URLRequest("https://www.paypal.com/cgi-bin/webscr");
request.method = URLRequestMethod.POST;
request.data = variables;
navigateToURL(request, "_self");
</pre><br />
And <a href="https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables">here is PayPal's description of the variables</a>.Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com0tag:blogger.com,1999:blog-3335221968081944600.post-48351093943737533782010-10-11T04:41:00.000-06:002010-10-11T04:41:45.057-06:00AS3 Shuffle ArrayThis reorders the elements of an array into a random order.<br />
<br />
<pre>var anArray:Array = [1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4];
anArray=shuffleArray(anArray);
function shuffleArray(arr:Array):Array{
var arr2:Array = [];
while (arr.length > 0){
arr2.push(gendersArray.splice(Math.round(Math.random() * (arr.length - 1)), 1)[0]);
}
return arr2;
}
</pre>Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com0tag:blogger.com,1999:blog-3335221968081944600.post-66288672487500492842009-11-04T10:54:00.006-07:002009-11-04T11:15:15.084-07:00Convert a String into an Array Using Actionscript 3I was trying to pass an array through SWFObject flashvars and realized it can't be done. Instead you need to use a string for your array, pass it into Flash , then convert it to an array using the actionscript "split" function.<br /><pre><br />//the string to turn into an array<br />var arrayString:String="1,2,3"; <br /><br />//convert the string to an array using the "," as a divider (aka delimiter)<br />var newArray:Array= arrayString.split(",") <br /><br />//convert the array items from strings to numbers<br />var n=newArray.length;<br /> while (n--) {<br /> newArray[n]=Number(newArray[n])<br /> }<br /><br />//test: to make sure conversion to numbers worked<br />trace(String(trainCubesArray[0]+1)); //test: result is 2 <br /></pre>Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com0tag:blogger.com,1999:blog-3335221968081944600.post-68882750225121521192009-10-29T10:03:00.002-06:002009-10-29T10:05:10.286-06:00SWFObject Wizard Generator<div>This page is a wizard that lets you enter values and it creates a SWFObject embed for you. </div><div><br /></div><a href="http://www.bobbyvandersluis.com/swfobject/generator/index.html">http://www.bobbyvandersluis.com/swfobject/generator/index.html</a>Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com0tag:blogger.com,1999:blog-3335221968081944600.post-66694083649535811402009-10-29T09:47:00.004-06:002009-10-29T10:37:20.352-06:00Detecting when mouse leaves stageThis is how you detect if the mouse leaves Flash and rolls over to web page:<div><pre>stage.addEventListener( Event.MOUSE_LEAVE, mouseLeaveListener );</pre></div>Additionally you can also tell when the flash movie gains and loses focus, which you couldn't do in AS 2, by listening for Event.ACTIVATE and Event.DEACTIVATE.<div><br /></div><div>Here is some code that detects enter/exit. Just paste into main timeline, compile, then view embedded in an html page:</div><div><br /></div><pre>//draw a box for demonstration purposes<br />var c:Sprite = new Sprite();<br />c.graphics.beginFill(0xFF);<br />c.graphics.drawRect(0, 0, 200, 200);<br />addChild(c);<br /><br />//NOTE this only works embedded in a web page<br />//detect mouse leaving flash and rolling over web page<br />stage.addEventListener(Event.MOUSE_LEAVE, cursorHide);<br /><br />//there is no mouse exit so you need to use this<br />stage.addEventListener(MouseEvent.MOUSE_MOVE, cursorFollow);<br /><br />function cursorHide(evt:Event):void {<br /> c.alpha=.2<br />}<br /><br /><br />function cursorFollow(evt:MouseEvent):void {<br /> c.alpha=1<br /> evt.updateAfterEvent();<br />}</pre>Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com0tag:blogger.com,1999:blog-3335221968081944600.post-52924997733337347882009-08-05T11:10:00.001-06:002009-08-05T11:12:05.931-06:00Link navigateToURL that pops a new window with dimensions<pre><br />safePromo_mc.addEventListener(MouseEvent.MOUSE_DOWN, safeClick);<br />function safeClick(e:MouseEvent):void {<br /> var jscommand:String = "window.open('http://www.adobe.com','win','height=200,<br /> width=300,toolbar=no,scrollbars=yes');"; <br /> var url:URLRequest = new URLRequest("javascript:" + jscommand + " void(0);"); <br /> navigateToURL(url, "_self"); <br />}<br /></pre>Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com0tag:blogger.com,1999:blog-3335221968081944600.post-28103374566892037722009-02-24T09:26:00.000-07:002009-02-24T09:27:11.164-07:00Blur Using AS3<pre>var blur:BlurFilter = new BlurFilter();<br />blur.blurX=20;<br />blur.blurY=20;<br />blur.quality=BitmapFilterQuality.LOW;<br />displayObjectToBlur_mc.filters=[blur];</pre>Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com1tag:blogger.com,1999:blog-3335221968081944600.post-40939620521541358782009-02-09T07:18:00.003-07:002009-02-09T07:19:46.472-07:00AS3 full screen modeHeres a function to toggle full screen mode using AS3. Note that in fullscreen mode that only the "non-printing" keys work (arrows, shift, etc). <br /><pre><br />function toggleFullScreenMode(e:MouseEvent):void {<br /> if (viewingFullScreen==false) {<br /> viewingFullScreen=true;<br /> navsNorthMultiPage_mc.tween_mc.eastButtons_mc.fullScreenAnim_mc.gotoAndPlay("full");<br /> navsSouthMultiPage_mc.tween_mc.eastButtons_mc.fullScreenAnim_mc.gotoAndPlay("full");<br /> stage.displayState="fullScreen";<br /> } else {<br /> viewingFullScreen=false;<br /> navsNorthMultiPage_mc.tween_mc.eastButtons_mc.fullScreenAnim_mc.gotoAndPlay("out");<br /> navsSouthMultiPage_mc.tween_mc.eastButtons_mc.fullScreenAnim_mc.gotoAndPlay("out");<br /> stage.displayState="normal";<br /> }<br />}<br /></pre>Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com0tag:blogger.com,1999:blog-3335221968081944600.post-75118808848930166442008-12-19T09:09:00.004-07:002008-12-19T09:13:36.567-07:00AS3 Disable Yellow Tab RectanglesAre you wondering why when you hit tab in your Flash site you get those nasty yellow rectangles around your links? Here's how to disable them:<br /><br />If you have a movieclip with a bunch of buttons inside it and you want to disable all of them with one line of code use this:<br /><pre>MC_Container_Name.tabChildren = false;</pre><br /><br />Or to just disable the yellow box on a single movieclip use this:<br /><pre>MC_Name.tabEnabled = false;</pre>Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com4tag:blogger.com,1999:blog-3335221968081944600.post-32982418258470313652008-12-19T09:00:00.002-07:002008-12-19T09:09:09.809-07:00AS3 Smooth Loaded BitmapsLoaded bitmaps (jpgs, pngs, etc) look bad in flash when scaling unless you smooth them. This function seems to replicate the bitmap "smoothng" setting in the library pallette. I still see tons of FLash sites out there that arent aware of this awesome setting. It makes bitmaps look great when they scale.<br /><br /><pre><br />//create a new loader object and put it on the stage<br />var slideLoader:Loader=new Loader();<br />this.addChild(slideLoader);<br /><br />//load picture into loader object<br />slideLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, scaleContentForPicture);<br />slideLoader.load(new URLRequest("images/tree.jpg"));<br /><br />//smooth it once loaded<br />function scaleContentForPicture() {<br />var smoother_bm=Bitmap(slideLoader.content);<br />smoother_bm.smoothing=true;<br />}<br /></pre>Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com2tag:blogger.com,1999:blog-3335221968081944600.post-39643122593330894092008-12-15T11:00:00.002-07:002008-12-15T11:02:03.983-07:00Slideshow with autoplay and reset delayThis code starts with a long pause then starts looping through images. If the user interacts with the slideshow, the timer is reset then starts playing again later if the user hasnt interacted.<br /><br /><br /><pre><br />//setup---------------------------------------------<br />var resetTime:uint=5000;<br />var pauseBetweenSlides:uint=5000;<br />var slideCounter:uint=1;<br />var prevSlide:uint=0;<br /><br />var startShowTimer:Timer=new Timer(resetTime,1);<br />startShowTimer.addEventListener(TimerEvent.TIMER, setUpTimer);<br />var slideShowTimer:Timer=new Timer(pauseBetweenSlides,0);<br />slideShowTimer.addEventListener(TimerEvent.TIMER, autoAdvance);<br /><br />//auto advance<br />function autoAdvance(e:TimerEvent):void {<br /> nexttSlide();<br />}<br /><br />//next<br />function nexttSlide():void {<br /> prevSlide=slideCounter;<br /> slideCounter++;<br /> if (slideCounter==6) {<br /> slideCounter=1;<br /> }<br /> goToSlide();<br />}<br />//prev<br />function prevvSlide():void {<br /> prevSlide=slideCounter;<br /> slideCounter--;<br /> if (slideCounter==0) {<br /> slideCounter=5;<br /> }<br /> goToSlide();<br />}<br />//display next slide and hide previous<br />function goToSlide():void {<br /> slideshow_mc["slide"+slideCounter+"_mc"].gotoAndPlay("show");<br /> if (prevSlide>0) {<br /> slideshow_mc["slide"+prevSlide+"_mc"].gotoAndPlay("hide");<br /> }<br />}<br />//pause slideshow and reset timer<br />function resetTimer():void {<br /> slideShowTimer.stop();<br /> startShowTimer.reset();<br /> startShowTimer.start();<br />}<br />//called when reset pause is finished<br />function setUpTimer(e:TimerEvent):void {<br /> startShowTimer.reset();<br /> slideShowTimer.start();<br />}<br /><br /><br />resetTimer();<br />goToSlide();<br /><br /><br />//Controls--------<br />function showControls():void {<br /> slideShowPrev_mc.gotoAndPlay("show");<br /> slideShowNext_mc.gotoAndPlay("show");<br />}<br />function hideControls():void {<br /> slideShowPrev_mc.gotoAndPlay("hide");<br /> slideShowNext_mc.gotoAndPlay("hide");<br />}<br /><br /><br /><br />slideShowNext_mc.addEventListener(MouseEvent.CLICK, invokeNextSlide);<br />function invokeNextSlide(e:MouseEvent):void {<br /> resetTimer();<br /> nexttSlide();<br />}<br />slideShowPrev_mc.addEventListener(MouseEvent.CLICK, invokePrevSlide);<br />function invokePrevSlide(e:MouseEvent):void {<br /> resetTimer();<br /> prevvSlide();<br />}<br /></pre>Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com0tag:blogger.com,1999:blog-3335221968081944600.post-33053577487092469042008-12-15T10:53:00.002-07:002008-12-15T10:55:59.373-07:00Mouse enter and leave a movieclip using the Point objectDetect mouse entering and exiting a movieclip. Using this will allow rollover/out fuctionality without messing up mouse interaction of nested clips. <br /><br /><pre><br />slideshow_mc.arrowsHotspots_mc.addEventListener(Event.ENTER_FRAME, watchForMouseEntry);<br />var point1:Point=new Point(0,0);<br />var mouseAlreadyInside:Boolean=false;<br />function watchForMouseEntry(e:Event):void {<br /> point1.x=mouseX;<br /> point1.y=mouseY;<br /> var hs:Object=e.target;<br /> <br /> if (hs.hitTestPoint(point1.x,point1.y,true)) {<br /> if (mouseAlreadyInside==false) {<br /> mouseAlreadyInside=true;<br /> showControls()<br /> }<br /> } else {<br /> if (mouseAlreadyInside==true) {<br /> mouseAlreadyInside=false;<br /> hideControls()<br /> }<br /> }<br />}<br /></pre>Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com0tag:blogger.com,1999:blog-3335221968081944600.post-76869874873233202782008-11-20T09:38:00.003-07:002008-11-20T09:48:52.067-07:00Loading external images and reacting to load complete and smoothing bitmap<pre>var slideLoader:Loader=new Loader();<br />csHostRef.addChild(slideLoader);<br /><br />slideLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, slidePreloaded);<br />slideLoader.load(new URLRequest(xml.slide[currentSlide].mediaURL));<br /><br />function slidePreloaded(){<br /> //do stuff here now that pict has loaded<br /><br /> //...and this will smooth the bitmap so it doesnt look crappy scaling<br /> var smoother_bm=Bitmap(slideLoader.content);<br /> smoother_bm.smoothing=true;<br />}<br /><br /><br /></pre>Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com0tag:blogger.com,1999:blog-3335221968081944600.post-61519051999649193282008-11-12T13:31:00.002-07:002008-11-12T13:38:14.076-07:00Measuring the Stage in AS3In AS2 you could measure the stage using Stage.width. in AS3 things are different. <br /><br />In AS3 stage.width works BUT it gives you the measurement of all the items in the stage - not the width of the player window.<br /><br /><a href="http://www.iheartactionscript.com/stage-access-outside-of-documentroot-in-as3/">This person</a> has an interesting workaround. Basically you create an empty movieclip, convert it to a Stage, then measure it. Because there is nothing in it, it measures what it can, so measures the player window!<br /><br />At least that is how I understand it. Here is the code:<br /><br /><pre>var myMC:MovieClip = new MovieClip();<br />addChild(myMC);<br />var _stage:Stage = myMC.stage;</pre><br /><br />Then you use this to get the measurement:<br /><br /><pre>_stage.stageWidth</pre><br /><br />This even works in SWFs that are loaded in a parent shell SWF.Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com4tag:blogger.com,1999:blog-3335221968081944600.post-8210445678492850312008-11-06T11:58:00.005-07:002008-11-06T12:15:09.356-07:00Simple AS3 Video FLV PlayerHere are the basics for loading an external FLV and reading progress.<br /><pre>var vid:Video=new Video(320,240);<br />videoPlayerHost.addChild(vid);<br /><br />var nc:NetConnection=new NetConnection ;<br />nc.connect(null);<br /><br />var ns:NetStream=new NetStream(nc);<br />vid.attachNetStream(ns);<br /><br />var infoContainer:Object;<br />var listener:Object=new Object ;<br />listener.onMetaData=function(info:Object):void {<br /> trace("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate);<br /> tmrDisplay.start();<br /> infoContainer=info;<br />};<br />ns.client=listener;<br />ns.play("myVideo.flv");<br /><br />var tmrDisplay:Timer=new Timer(10);<br />tmrDisplay.addEventListener(TimerEvent.TIMER,updateDisplay);<br />var playbackPercentComplete:Number=0;<br /><br />function updateDisplay(e:TimerEvent):void {<br /> playbackPercentComplete=ns.time/infoContainer.duration;<br /> trace("PLAYING... elapsed time="+ns.time+", video length="+infoContainer.duration+", percent complete="+playbackPercentComplete);<br /> if (ns.time>infoContainer.duration) {<br /> playbackPercentComplete=0;<br /> tmrDisplay.stop();<br /> trace("done playing")<br /> }<br />}<br /><br />//ns.pause() will pause the video<br />//ns.resume() will resume the video<br />//ns.seek(0) will jump the playhead to the beginning<br /><br /></pre>Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com0tag:blogger.com,1999:blog-3335221968081944600.post-76737760938836873772008-11-05T09:28:00.001-07:002008-11-05T09:33:30.699-07:00Simple AS3 Button Click<pre>visit_btn.addEventListener(MouseEvent.CLICK, visit);<br />function visit(e:MouseEvent):void {<br /> var request:URLRequest=new URLRequest("http://www.thrillbilliestrailer.com");<br /> navigateToURL(request, "_self");<br />}</pre>Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com0tag:blogger.com,1999:blog-3335221968081944600.post-71381101383528378182008-11-03T10:00:00.004-07:002008-11-03T10:15:25.221-07:00Creating Dynamic Tween Variables In a Timed SequenceSay you want to have a number of tweens perform in a sequence but you don't want to type out all the tweens. Here is how you do it using a timer to animate some menus one at a time with a delay of 50 milliseconds between each:<br /><pre>import fl.transitions.Tween;<br />import fl.transitions.easing.*;<br />import fl.transitions.TweenEvent;<br /><br />var timerCounter:uint=0;<br />var theTimer:Timer=new Timer(50,6);/<br />theTimer.start();<br />theTimer.addEventListener(TimerEvent.TIMER, display);<br /> <br />function display(e:TimerEvent):void {<br />timerCounter++;<br />var thisLoopNode:Object=menu_mc.getChildByName("node"+timerCounter);<br />this["tweenx"+timerCounter]=new Tween(thisLoopNode,"x",Regular.easeOut,0,100,1,true);<br />this["tweeny"+timerCounter]=new Tween(thisLoopNode,"y",Regular.easeOut,0,timerCounter*10,1,true);<br />this["tweenalpha"+timerCounter]=new Tween(thisLoopNode,"alpha",Regular.easeOut,0,1,1,true);<br />}</pre>Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com2tag:blogger.com,1999:blog-3335221968081944600.post-55518814950332057672008-10-30T17:05:00.000-06:002008-10-30T17:06:12.480-06:00Tweening in AS3 Part II<pre>import fl.transitions.Tween;<br />import fl.transitions.easing.*;<br />import fl.transitions.TweenEvent;<br /><br />var myTween:Tween=new Tween(test_mc,"x",Elastic.easeOut,0,300,3,true);<br /><br />myTween.addEventListener(TweenEvent.MOTION_CHANGE,checkPos);<br />function checkPos(tevt:TweenEvent):void {<br /> trace(test_mc.x);<br />}<br />myTween.addEventListener(TweenEvent.MOTION_FINISH,finished);<br />function finished(tevt:TweenEvent):void {<br /> trace("done");<br />}</pre>Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com0tag:blogger.com,1999:blog-3335221968081944600.post-66427382478540493252008-10-29T22:48:00.000-06:002008-10-29T23:14:55.348-06:00Calling Parent Variables and Functions from a Loaded SWFLet's say I have one SWF (child.swf) that I want to load into another SWF (parent.swf), then I want to call a function that is in parent.swf from the child.swf. In AS2 you could just do _parent._parent as many times as needed to reach up the tree to get to the parent's top level. In AS3 you need to use this code below instead. Put it inside the child.swf. I have no idea what this line of code means, but is magic:<br /><pre>MovieClip(parent.parent).ParentFunction();</pre>...then this sample code goes inside the parent.swf on its main timeline:<br /><pre>//this sample code loads the external SWF into the Parent SWF<br />var indexSwfRequest:URLRequest = new URLRequest("index.swf");<br />var indexSwfLoader:Loader = new Loader();<br />indexSwfLoader.load(indexSwfRequest);<br />addChild(indexSwfLoader);<br />//This is the parent function that can be called from the command that is inside the child.swf<br />function ParentFunction():void{<br />trace("It worked!");<br />}</pre>Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com13tag:blogger.com,1999:blog-3335221968081944600.post-43675696885592914182008-10-23T15:09:00.001-06:002008-10-29T22:47:14.956-06:00Tweening in AS3This uses the built-in Tween and easing classes. I don't like juggling external classes from 3rd parties if I can help it.<br /><br />//Tweens wont work without these:<br />import fl.transitions.Tween;<br />import fl.transitions.easing.*;<br /><br />//This creates the tween<br />var myTween:Tween;<br />myTween = new Tween(movieclip, "x", Elastic.easeInOut, start, end, 3, true);<br /><br />/*<br />The stuff in parentheses...<br />1. The movieClip to tween <br />2. Property to tween<br />3. Type of tween (see help: fl.transitions.easing). Here are the options:<br />First item: Back, Bounce, Elastic, None, Regular, Strong<br />Second Item aftyer period: easeIn, easeOut, easeInOut<br />4. Start value<br />5. End value<br />6. true=Measure in seconds, false=Measure in milliseconds.<br />*/Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com0tag:blogger.com,1999:blog-3335221968081944600.post-44682349472763684422008-07-26T17:22:00.000-06:002008-07-26T17:30:28.510-06:00Global Variables AS3STEP 1. Make a class called "GlobalVarContainer.as":<br /><br />package <br />{<br /> public class GlobalVarContainer <br /> {<br /> public static var vars:Object = [];<br /> }<br />}<br /><br />STEP 2. Main timeline:<br />import GlobalVarContainer;<br />var currentNav:Number;<br />GlobalVarContainer.vars.currentNav=10;<br /><br />STEP 3. Then from any clip (even loaded ones):<br />var currentNav2:Number=GlobalVarContainer.vars.currentNav; <br />trace(currentNav2);Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com0tag:blogger.com,1999:blog-3335221968081944600.post-49619462145349778722008-07-26T16:08:00.000-06:002008-07-26T16:10:20.848-06:00Loading external variables from htmlThis brings a var in from html that is a string and converts it to a number.<br /><br />var allFlashVars:Object = LoaderInfo(this.root.loaderInfo).parameters;<br />var currentNav:String;<br />var theLoadedVar:Number=Number(allFlashVars.currentNav);Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com0tag:blogger.com,1999:blog-3335221968081944600.post-32928037038241970452008-07-22T15:38:00.000-06:002008-07-22T15:41:12.475-06:00Timervar theTimer:Timer=new Timer(1000, 0);//(delay, zero is infinite, or any other number is the repeat count)<br /> theTimer.start();<br /> theTimer.addEventListener(TimerEvent.TIMER, proceed);<br /> theTimer.addEventListener(TimerEvent.TIMER_COMPLETE, done); //when done with all repeats (not possible here because of zero)<br />}<br />function proceed(e:TimerEvent):void {<br /> trace("tick every second");<br />}<br />function done(e:TimerEvent):void {<br /> trace("done");<br />}Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com0tag:blogger.com,1999:blog-3335221968081944600.post-58895240780835446632008-07-22T11:26:00.000-06:002008-07-22T11:27:53.607-06:00rollover mouseovertheSpark.addEventListener(Event.ENTER_FRAME, enterFrameHandler);<br />theSpark.addEventListener(MouseEvent.ROLL_OVER, rollOverHandler);<br /><br />function enterFrameHandler(e:Event):void {<br />}<br />function rollOverHandler(e:MouseEvent):void {<br />}Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com0tag:blogger.com,1999:blog-3335221968081944600.post-1387389950696907642008-07-22T10:42:00.000-06:002008-07-22T10:43:02.467-06:00as3 getURLvar request:URLRequest = new URLRequest("http://www.google.com");<br /> navigateToURL(request, "_self");Matt Maxwellhttp://www.blogger.com/profile/13025883397905736760noreply@blogger.com0