import com.greensock.TweenMax; import com.greensock.plugins.BezierPlugin; import com.greensock.plugins.BezierThroughPlugin; TweenMax.to(sp,5,{bezierThrough:[{x:250,y:100},{x:50,y:200},{x:500,y:200}]}); Man TweenLite/TweenMax is awesome.
Flash Scaling with Firefox
If you're making a flash clip take up the entire browser window, as can be necessary on occasion, in most browsers throwing in height="100%" works fine. Not so with firefox. Firefox interprets the doctype strictly, which disables the internal elements from setting the height of the window (100% of something in a div, will just... Continue Reading →
Stop stage rescalling AS3
stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT;
Export MySQL content to CSV file with PHP
http://www.ineedtutorials.com/code/php/export-mysql-data-to-csv-php-tutorial
Export a table to CSV with php/mysql
include("db_conn.php"); $file = 'Export'; $result = mysql_query("SHOW COLUMNS FROM [[TABLE]]"); $i = 0; if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { $csv_output .= $row['Field']."; "; $i++; } } $csv_output .= "\n"; $values = mysql_query("SELECT * FROM [[TABLE]]"); while ($rowr = mysql_fetch_row($values)) { for ($j=0;$j<$i;$j++) { $csv_output .= $rowr[$j].";"; } $csv_output .= "\n"; }... Continue Reading →
Exclude results from a query
AND status <> 'disabled' What a MySQL boffin I am. Haha
if else questionmark operators
A neat wee time saving way to write an if () {} else {} statement in flash or javascript: var a = true; var b = false; var c; if(a==b?c = true: c = false); trace(c); The statements between the ? and the : are if the if evaluated to true, and after the :... Continue Reading →
Call AS3 functions from javascript and vice versa
To communicate between JavaScript and Actionscript it isn't so hard. FLASH: import flash.external.ExternalInterface; ExternalInterface.addCallback("sendTextToFlash", getTextFromJavaScript); function getTextFromJavaScript(str):void { trace(str); } JAVASCRIPT: var currentPage="Home"; function setCurrentPage(newPage) { currentPage = newPage; SendDataToFlashMovie(newPage); } So then on the page, this code is run when an item is clicked (javascript function sending to flash) <a href="javascript:void(0);" onClick="setCurrentPage('Home')">Home</a> This javascript... Continue Reading →
Getting around Chrome Javascript error: Chrome Unsafe JavaScript attempt to access frame with URL
In this instance, I had a parent window which launched a bunch of child windows. These child windows needed to run a function on the parent window when a particular function was called. Since the event dispatcher isn't widely working with IE just yet it seems, that wasn't a real option, so I went oldschool... Continue Reading →
Radians to Degrees, Degrees to radians, AS3
// Degrees to Radians radians = degrees * Math.PI / 180 // Radians to Degrees degree = radians * 180 / Math.PI
Adding inline function and removing it AS3
Saves you making real functions for tiny little functions - handy. timer.addEventListener(TimerEvent.TIMER, function(e:TimerEvent){trace("inline function")}); To remove it, it can only be done when it is called (see the dudes link below for the source for this!) myButton_btn.addEventListener(MouseEvent.CLICK, function(e:Event) { trace(e.currentTarget.name+" was just clicked!"); //removing anonymous listener e.currentTarget.removeEventListener(e.type, arguments.callee); }); src: (ty!): http://sierakowski.eu/list-of-tips/61-using-an-anonymous-inline-function-when-adding-an-event-listener.html
Turning a clip to a point AS3
Use Math.atan2. So handy but forgetable. var targetAngle:Number = Math.atan2(mouseY - this.y, mouseX - this.x); var angle:Number = targetAngle * (180/Math.PI) - this.rotation = angle;