Posts Tagged ‘actionscript’
1180 Call to a possibly undefined method navigateToURL
1180 Call to a possibly undefined method navigateToURL If you get the above error when trying to run your flash actionscript 3 file, you are obviously trying to use the navigateToURL() function but have not imported the flash.net library code. The following code before everything will correct the problem. import flash.net.*; ..or a more of a direct unbloated method is as follows: import flash.net.navigateToURL;
How to use a Timer in Actionscript 3
It is really easy to create a Timer in Actionscript 3. Instantiate the Timer Class and pass a time in millions of 1000 to it to work in seconds. var myTimer:Timer = new Timer(1000); Setup an event listener to call a function. myTimer.addEventListener("timer", myTimerEventHandler); Start the Timer. myTimer.start(); Start the Timer. function myTimerEventHandler(event:TimerEvent):void { trace(myTimer.currentCount+" seconds have passed."); } So altogether we have this. var myTimer:Timer…
Actionscript 2 & PHP Data Transfer
In the below example we will use Actionscript 2 to call a remote PHP file that will return data to it. It is a simple way of transferring data between the server and client. Actionscript 2 Code: callRemoteFile = function(ourVariable:String) { var result_lv:LoadVars = new LoadVars(); result_lv.onLoad = function(success:Boolean) { if (success) { …
Actionscript2: Split string by line length with & without word-wrap
Split string into sentences by max line length. This uses a character array but doesn’t use word-wrapping. var personalMessage:String = "You got this far so we reckon that you could be curious enough to learn a little more, we’ll contact you shortly to answer any questions you may have."; _root.myArray = new Array(); _root.myArray = personalMessage.split(""); _root.mySentences = new Array(); var currentCharCount:Number = 0; var currentCharItem:Number = 0; var currentCharString:String…
Error 1046: Type was not found or was not a compile-time constant: Event.
Error 1046: Type was not found or was not a compile-time constant: Event. You need to import the Event class! import flash.events.Event
Add a date to a date in Actionscript 2
I needed to work out a date range according to the date 3weeks away from the current date. After a bit of thinking, I found that it’s actually quite easy to achieve. var theDate:Date = new Date(); dateDay = theDate.getDate(); dateMonth = theDate.getMonth(); dateYear = theDate.getFullYear(); var theDate2:Date = new Date(dateYear,dateMonth,dateDay); theDate2.setDate(theDate2.getDate() + 21); dateDay2 = theDate2.getDate(); dateMonth2 = theDate2.getMonth(); dateYear2 = theDate2.getFullYear();</span> The above code gets the current date…
Add a month to selectable date range – Date Chooser – Actionscript 2
I have been working on a project where I need to select a date range starting today and ending a month from now, so the user cannot select anything in the past or over a month from now. This is how I did it: There is an instance of DateChooser on the stage with Instance Name “calDate”. var todayDate:Date = new Date(); dateBeginDay = todayDate.getDate(); dateBeginMonth = todayDate.getMonth(); dateBeginYear =…
hitTest and Actionscript2
if (mc.hitTest(_root._xmouse, _root._ymouse, true))) { trace("hitTest Run"); }
Enable / Disable Cursor Hand in Actioncsript 2
If you have a movieclip that by default has the hand cursor showing on RollOver and you don’t really want this, you can disable it by doing the following: myMC.onRollOver = function() { this.useHandCursor=false; } So the main code here is: this.useHandCursor=false; False disables it and true shows it.
Calling event functions from movieclips in actionscript 2
In a flash movie I usually have a frame of actionscript that controls all elements in the file to keep everything in one place. Sometimes I have an onPress(etc) function that refers to something happening in the scene when something is pressed, but what happens if we want another element to refer to that event for some reason? Here’s an example of that code without anything “flashy”: _root.myMC.onPress = function()…
Capitalize First Letter in Word – Actionscript 2
You have a string and you want to capitalize the first character but have the rest of the word in lowercase. DO THIS! myStringVar = myStringVar.substring(0, 1).toUpperCase()+myStringVar.substring(1);
Stage align and Stage scale in actionscript 3
If you want to position the flash top/left and not have it scale when you resize it’s bounding box window, you can set the following code. stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; For full documentation from Adobe take a look here.