Deprecated: Assigning the return value of new by reference is deprecated in /home/datafake/public_html/blog/wp-settings.php on line 468

Deprecated: Assigning the return value of new by reference is deprecated in /home/datafake/public_html/blog/wp-settings.php on line 483

Deprecated: Assigning the return value of new by reference is deprecated in /home/datafake/public_html/blog/wp-settings.php on line 490

Deprecated: Assigning the return value of new by reference is deprecated in /home/datafake/public_html/blog/wp-settings.php on line 526

Strict Standards: Declaration of Walker_Page::start_lvl() should be compatible with Walker::start_lvl(&$output) in /home/datafake/public_html/blog/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_Page::end_lvl() should be compatible with Walker::end_lvl(&$output) in /home/datafake/public_html/blog/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_Page::start_el() should be compatible with Walker::start_el(&$output) in /home/datafake/public_html/blog/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_Page::end_el() should be compatible with Walker::end_el(&$output) in /home/datafake/public_html/blog/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_PageDropdown::start_el() should be compatible with Walker::start_el(&$output) in /home/datafake/public_html/blog/wp-includes/classes.php on line 611

Strict Standards: Declaration of Walker_Category::start_lvl() should be compatible with Walker::start_lvl(&$output) in /home/datafake/public_html/blog/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_Category::end_lvl() should be compatible with Walker::end_lvl(&$output) in /home/datafake/public_html/blog/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_Category::start_el() should be compatible with Walker::start_el(&$output) in /home/datafake/public_html/blog/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_Category::end_el() should be compatible with Walker::end_el(&$output) in /home/datafake/public_html/blog/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_CategoryDropdown::start_el() should be compatible with Walker::start_el(&$output) in /home/datafake/public_html/blog/wp-includes/classes.php on line 728

Strict Standards: Redefining already defined constructor for class wpdb in /home/datafake/public_html/blog/wp-includes/wp-db.php on line 306

Deprecated: Assigning the return value of new by reference is deprecated in /home/datafake/public_html/blog/wp-includes/cache.php on line 103

Strict Standards: Redefining already defined constructor for class WP_Object_Cache in /home/datafake/public_html/blog/wp-includes/cache.php on line 425

Deprecated: Assigning the return value of new by reference is deprecated in /home/datafake/public_html/blog/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/datafake/public_html/blog/wp-includes/theme.php on line 618

Strict Standards: Redefining already defined constructor for class WP_Dependencies in /home/datafake/public_html/blog/wp-includes/class.wp-dependencies.php on line 15

Warning: Illegal string offset 'trackoutbound' in /home/datafake/public_html/blog/wp-content/plugins/google-analytics-for-wordpress/googleanalytics.php on line 489

Warning: Illegal string offset 'trackadsense' in /home/datafake/public_html/blog/wp-content/plugins/google-analytics-for-wordpress/googleanalytics.php on line 501

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method GoogleSitemapGeneratorLoader::Enable() should not be called statically in /home/datafake/public_html/blog/wp-includes/plugin.php on line 311

Warning: Cannot modify header information - headers already sent by (output started at /home/datafake/public_html/blog/wp-settings.php:468) in /home/datafake/public_html/blog/wp-includes/feed-rss2.php on line 8
The Datafake Blog http://www.datafake.com/blog Web fun with Actionscript, PHP and .NET Sat, 06 Mar 2010 14:39:41 +0000 http://wordpress.org/ en PHP Security - Avoid SQL Injection and XSS Attacks http://www.datafake.com/blog/?p=55 http://www.datafake.com/blog/?p=55#comments Tue, 28 Oct 2008 22:10:25 +0000 admin http://www.datafake.com/blog/?p=55
  • If using $_GET or $_POST variables in an mysql query, clean them with mysql_real_escape_string.
  • When displaying user submitted content from the database, apply htmlentities before it is displayed.
  • SQL Injection - mysql_real_escape_string()

    Using mysql_real_escape_string stops malicious inputs breaking SQL queries. The quote ‘ is a reserved character in SQL. When it appears as part of a parameter it can break or change the meaning of a query. The mysql_real_escape_string function escapes the quote ‘ so it becomes \’ SQL will not treat the quote as a reserved character and it can safely be used in a parameter usually to insert a quote into the DB.

    XSS - Htmlentities()

    Htmlentities turns characters into their equivalent html entities. This allows javascript code to be displayed in a page without the browser executing it. If a user enters some javascript into a form on your site and you display it back to them unaltered then the code will execute leaving you open to a scripting attack.

    If I enter this into a form field on a web site:

    <script>alert(”Your site executed my code. Thanks”);</script>

    and the next page displays it without applying htmlentities, the browser will execute it and pop open an alert message box.

    The consequences are worse if the input is stored and displayed again to another user. In this example that user would also see the alert message box pop open. The malicious script has access to private data that the browser stores for that user.

    An html entity is a representation of a character. for example the < less-than sign’s html entity is &lt;. Applying htmlentities() replaces characters in the above javascript with their equivalent html entities to give.

    &lt;script&gt;alert(&quot;Your site executed my code&quot;);&lt;/script&gt;

    When the browser encounters this it will decode the characters and display it in its original form but without executing the javascript it represents.

    ]]>
    http://www.datafake.com/blog/?feed=rss2&p=55
    ASP.NET Introduction - Quick Start Tutorial http://www.datafake.com/blog/?p=11 http://www.datafake.com/blog/?p=11#comments Tue, 19 Aug 2008 16:40:07 +0000 admin http://www.datafake.com/blog/?p=11 Hello, this post gives an overview of .NET then describes how to get from nothing to a database enabled web site using .NET in as few steps as possible. The end result will be quite basic, but the aim is write to a series of posts that will compare the minimal get up and go process with other competing technologies such as PHP and Coldfusion.

    The intended audience is the mass of PHP developers out there that use LAMP ( Linux, Apache, MySQL and PHP) and want an overview of the .NET thing , anyone who has an interest in .NET but no knowledge might find this post of usefull.

    My own journey into web development began with PHP using Apache server software running on a Linux operating system. To me .NET seemed a vague accronym, was it a langauge, a sever or a frame work. However after using .NET for some real projects the mystery has gone and actually it turns out that its quite good with amazing free development tools.

    .NET Overview

    .NET is a framework of code that can can be used to compile desktop or web applications. ASP.NET is the web part of this and is the upgrade to classic asp ( active server pages ).

    Classic asp worked much like PHP, you would write an asp script and post it on the server with the extension .asp. The server would be a windows server running IIS ( Internet Information Server), the equivalent of Apache. However, confusingly, you would write your asp pages using the language visual basic, compare that to writing PHP pages using the langauge PHP.

    ASP.NET, the latest technology, allows you to write .NET pages using either visual basic or the new language C# ( c-sharp ), whichever you choose your scripts will have the extension .aspx but still run on IIS.

    Microsoft have structured the .NET framework so that code written in different languages compiles down to a CLR ( Common Language Runtime ). It is a step above assembly and produces ‘managed code’. When you deploy a .NET site you can supply uncompiled .aspx scripts to the server or compile the site offline and put .dll files ( dynamic link libraries ) onto the server. This allows you to deploy pre-compiled web apps to clients that they would find hard to reverse engineer.

    Visual Studio, VB or C#

    Personally I prefer to develop using C# because it has a similar syntax to all the other big langauges such as C, C++, Java, PHP and Actionscript. VB on the other hand seems out there on its own, curly braces are generally out in favour of IF THEN and END IF kind of statements giving rise to the freaky WHILE and WEND urghh! Sorry VB lovers.

    You pretty much have to develop your site on a windows machine and deploy it to a windows server. There is a framework called mono that lets you serve .NET stuff from Linux but its not something I have had any need to look into. You could also write all your .NET as text files on a mac ( or windows ) but you would miss out on all the features of Visual Studio, Microsofts mega IDE.

    The Visual Studio IDE has an abundance of great features, particularily the excellent intellisense. When you are writing code you get autocomplete for methods in the .NET framework but even better you get intellisense for code that you wrote yourself. If you declare a variable you start to get intellisense for it after the next compile. One of my favourite features is refactoring. You can highlight a big block of random code and instantly turn it into a new method, the IDE automatically looks through the code, figures out all the parameters the method will need and creates the new method.

    Creating .NET Web Sites with Visual Studio

    ASP.NET is based around writing scripts for the web server, mixing code with html and applying CSS for styling. However much like Coldfusion and Flex, .NET works using a tag based syntax to position and place controls onto the page. The tag based markup is generally mixed with html and all C# is kept seperatly at the head of the file or preferably in a seperate code behind file of the same name but with an aspx.cs extension.

    For each page Visual Studio provides a design view ( showing a graphical representation of how the page will look), a code view of the html and tag based mark-up and also the code behind showing raw C#.

    The general process is drag and arrange some controls into the page using the design view. Then write methods in the C# code behind that will get fired by events generated by the controls.

    The whole system is event based. Apparently this was to make ASP.NET easy to understand for desktop developers who were used to dragging windows controls and hooking them up to event handlers.

    As a page loads, or is POSTed back to as the result of a click a whole series of events ranging from the web page being loaded to a row in a grid view about to get the data for a particular cell are fired. The event based model takes a bit of getting used to. At times it seems like the clearest simplest methodology there could be, at other times it can leave you frustrated and stuck.

    The best part about developing web sites with .NET is that you can test them locally with the total confidence that a remote server will behave in exactly the same way as your PC. When you press control-F5 in Visual Studio it fires up an instance of a .NET server and pops open your website in the browser of your choice. Super convenient. Even better, if you run MS_SQL on your development machine you get full working DB functionality also.

    .NET Quick Start

    1. You have a windows PC

    2. You download and install Visual Web Developer Express 2008.

    3.You download and install MS_SQL Express 2008.

    4.You download and install SQL Server Management Studio Express.

    5.You Create a new DB table with some test data.

    6.You open Visual Studio and choose create new web site.

    7.You Drag some controls onto a page.

    8.You databind some control to a DB table.

    9. You test your page by pressing cntrl-F5.

    Steps 2,3,4 Download the IDE and DB.

    Yes the Express Editions are free! The main limitation to Visual Studio Express 2008 is that you can’t extend it with third party controls. You can only use the in built ones that come with VS, fortunately there are heaps and you can code anything you like anyway. The express editions come as different applications such as Visual C++ Express, Visual C# Express and Visual Web Developer Express. The full Visual Studio has all of these wrapped into one app but thats hardly a problem.

    The main limitation to SQL Express and Management Studio is.. mmh, well im not sure but probably its limited to 4G in size or cant be used in a cluster or something like that.

    To get to the downloads visit

    http://www.microsoft.com/express/download/.

    Choose to download ‘Visual Web Developer 2008 Express Edition’. Next download ‘SQL Server 2008 Express’ and also get SQL management Studio Express, which might be harder to find but there is a link to it at the bottom of the SQL Server Express download page.

    When you install SQL Server Express you will have to answer some set up questions. The main ones are ‘allow user instances’ and allow mixed mode authentication’. Allow user instances lets each user on the PC have their own instance of each DB. One user could fill their DB with stuff while the other user sees an empty DB. Not a big concern for me either way. WIndows authentication will log a user into the DB if they are logged into windows whilst mixed mode lets a user log in by supplying a username and password. In the real world DB servers generally use mixed mode and expext a username and password, so I like to choose mixed mode.

    Step 5 Create Test Data

    Start up SQL Server Management Studio Express. This application lets you control a SQL Server in the same way PHPMyAdmin lets you control a MySQL DB, the main difference is that it is a desktop app. You can connect to any local or remote SQL Server with Management Studio Express as long as you have permissions and a username and password.

    To set up Management Studio Express to connect to your local SQL Server Express instance you can use Windows Authentication, this logs you in as the user that is logged into windows. When the app opens you will likely be presented with a connect dialogue where you will have to locate your local SQL Server Express and connect to it. If it is not already shown choose browse for new from the drop down. The SQL Express Server is usually named YOURCOMPUTERNAME\SQLEXPRESS. Click to connect with windows authentication.

    Once connected the side panel will show a view of the whole Server. Right Click on the Databases folder and select New Database. In the panel that opens fill in DB name as ‘TestDataBase’ and click OK. There is a short delay and then the ‘TestDataBase’ appears in the DataBases folder.

    Expand the ‘TestDataBase’, right click the ‘Tables’ folder and choose add new table. A blank database table design view opens. For the first Column Name enter Name and choose varchar(50) for the type. Choose Age for the second column and choose type Int.

    Create a DataBase table

    Create a DataBase table

    When you have completed the table design right click the tab at the top and choose save as. You will be prompted for a name. Call the table People.

    Right click on the newly created People table and choose Open Table. You will see the empty rows in the table. You can start to enter some test data into each row by clicking and entering data. Once you have 4 or 5 rows filled in then that is the test data complete.

    Step 6 Open Visual Studio

    And create a new web site. Thats File->New Web Site. A pop-up appears. Select new ASP.NET web site and Language C#. Choose location File System and either choose a location or go with the default. click OK.

    Create new web site

    Choose File->Create New Web Site

    A new folder is created at the specified location containing all of the files required for your web site. A start page is created for your site called ‘Default.aspx’ and opens in the IDE. Microsoft like to start things with Capital letters.

    Step 7 Drag some controls onto the page

    Switch to the design view for Default.aspx by clicking the ‘design’ button near the bottom of the screen. Open the toolbox, if it is not open already, by choosing View->toolbox. Browse down to the data tab then locate the GridView Control. Drag it onto the screen.

    Drag a Gridview Control onto the page

    Drag a Gridview Control onto the page

    You will see a default GridView filled with dummy values. The GridView control is used to allow users to page through the data in a DB table or any other data. In order to do this the GridView needs to be pointed at a data source. This is acheived by pointing the GridView at a datasource control, the datasource control holds the access details for the DB and table. This can be acheived in a few mouse clicks.

    Step 8 DataBind the Control to the DB table

    There is a small tab to the top right of the GridView control. If you click it the GridView Tasks panel opens to the right of the control. Open the ‘Choose Data Source’ drop down and click on ‘new data source..’. A Data Source Configuration Wizard opens asking ‘where will the application get data from’ showing a list of possible data sources. Choose Database and click OK for the default name SqlDataSource1.

    The next step asks ‘Which data connection should your application use to connect to the database?’. Click new connection. In the Add Connection dialogue select your SQL Server Express from the server drop down list. For ‘Select or enter a database name’ choose the ‘TestDataBase’ created earlier. Click to test the connection and if it is ok click OK. You should now be able to preview the connection string that the data source will use.

    The next step of the wizard prompts you to store the connection string in the web.config file. A web.config file is stored by each .NET web site and contains settings specific to that site. Click Next to store the connection in the web.config file. You can browse the web.config file later and find the entry for the connection string.

    Next you will be asked ‘How would you like to retreive data from your database?’.

    Retreive Data

    Retreive Data

    Click on the ‘Specify Columns from a table or view radio button and check the * column to return all the data in the table. The equivalent Select statement is shown. The final step lets you test the query to see that the data is returned correctly.

    When you are returned to the design view you will see that the GridView now shows headings for each column selected from the DB table.

    Step 9 Press Cntrl F5 to Test

    When you test the web site a bubble pops up informing you that the ASP.NET development server has started running and gives you the URL of the local server. Internet Explorer ( you can change target browser ) fires up opening the Default.aspx page. If everything is in order the GridView will display the data from the People DB table. Hurrah!

    On my machine the page above has a URL http://localhost:2073/quickstart/Default.aspx ,this is only valid when the development server is actually running. If you are a Flash developer developing a swf that requires data from a backend database, you can do everything locally just set URLs to point at pages on the local development server that could serve the data to your SWF.

    ]]>
    http://www.datafake.com/blog/?feed=rss2&p=11
    Full Browser Flash Blog with Five3D http://www.datafake.com/blog/?p=7 http://www.datafake.com/blog/?p=7#comments Fri, 11 Jul 2008 14:40:17 +0000 admin http://www.datafake.com/blog/?p=7 Recently I have been evaluating some of the open source flash 3D engines. I checked out Papervision3D, Sandy3D and Away3D. These are large full featured engines however there is also Five3D which allows you to render smooth shapes and text.

    Full Browser 3D with Flash ActionScript3.0

    I was thinking about how great it would be to have a full web page that looks just like a normal html page but is infact a full browser 3D flash page. The aim would be to briefly trick an html/css purist before unleashing some 3D trickery. Anyway I downloaded the Five3D library and expanded one of the examples to recreate my blog in 3D.

    3D Blog

    Check out the result here.

    The page looks and scales like normal html, but doesn’t reveal it’s 3Dness until you click on it. I expect stuff like this will probably explode onto the web with the next few versions of the flash player. Google’s new ability to index swf’s in a human clicking style might just satisfy the SEO slaves.

    Unfortunately at the moment the performance drops off rapidly as more text is added. For that reason I haven’t put too much onto the page. If you play with the code you can uncomment the next few paragraphs and see how it performs. In his interview with FWA, Mathieu Badimon says that he thinks Flash Player10 will offer some of the same functionality as Five3D. So this should give the performance a boost.

    The Code

    You will need the Five3D classes in your classpath to compile it of course, get them from the Five3D site.  For flash to always fill the browser I refered to these articles, at adobe and here (AS2 but gives html publish settings).

    To get your swf to always fill the browser you need these html publish settings.

    Set dimensions, width and height to 100%.
    Set Scale to noscale
    Alignment: Set horizontal to left. Set vertical to top

    The code wont teach you anything more about five3D than the basic tutorials do. You will see that the code laboriously places everything sentence by sentence, shape by shape.

    If anybody writes code to process generalized html and display it in 3D, please let me know!! Adobe???

    package
    {
    import flash.display.*;
    import flash.display.StageAlign;
    import flash.events.*;

    // We import the FIVe3D classes needed.
    import five3D.display.DynamicText3D;
    import five3D.display.Scene3D;
    import five3D.display.Shape3D;
    import five3D.display.Sprite3D;
    import five3D.typography.HelveticaMedium;
    import five3D.typography.HelveticaLight;
    import five3D.utils.Drawing;

    public class Main extends Sprite
    {
    var go:Boolean = false;

    var scene:Scene3D = new Scene3D();
    var renderClip:Sprite3D = new Sprite3D();

    var mainPanel:Sprite3D = new Sprite3D();

    var searchBox:Sprite3D = new Sprite3D();
    var searchButton:Sprite3D = new Sprite3D();
    var searchButtonText:DynamicText3D = new DynamicText3D(HelveticaLight);

    var header:Sprite3D = new Sprite3D();
    var titleText:DynamicText3D = new DynamicText3D(HelveticaMedium);
    var titleCaption:DynamicText3D = new DynamicText3D(HelveticaLight);

    var targetDot:Shape3D = new Shape3D();

    var pagesHeader:DynamicText3D = new DynamicText3D(HelveticaMedium);
    var pagesLink1:DynamicText3D = new DynamicText3D(HelveticaLight);

    var ArchivesHeader:DynamicText3D = new DynamicText3D(HelveticaMedium);
    var archivesLink1:DynamicText3D = new DynamicText3D(HelveticaLight);
    var archivesLink2:DynamicText3D = new DynamicText3D(HelveticaLight);

    var categoriesHeader:DynamicText3D = new DynamicText3D(HelveticaMedium);
    var categoriesLink1:DynamicText3D = new DynamicText3D(HelveticaLight);
    var categoriesLink2:DynamicText3D = new DynamicText3D(HelveticaLight);

    var friendsHeader:DynamicText3D = new DynamicText3D(HelveticaMedium);
    var friendsLink1:DynamicText3D = new DynamicText3D(HelveticaLight);
    var friendsLink1Box:Sprite3D = new Sprite3D();

    var friendsLink2:DynamicText3D = new DynamicText3D(HelveticaLight);
    var friendsLink2Box:Sprite3D = new Sprite3D();

    var friendsLink3:DynamicText3D = new DynamicText3D(HelveticaLight);

    var firstHeader:DynamicText3D = new DynamicText3D(HelveticaMedium);
    var firstHeaderDate:DynamicText3D = new DynamicText3D(HelveticaLight);
    var firstParagraph_l1:DynamicText3D = new DynamicText3D(HelveticaLight);
    var firstParagraph_l2:DynamicText3D = new DynamicText3D(HelveticaLight);
    var firstParagraph_l3:DynamicText3D = new DynamicText3D(HelveticaLight);

    var secondHeader:DynamicText3D = new DynamicText3D(HelveticaMedium);
    var secondParagraph_l1:DynamicText3D = new DynamicText3D(HelveticaLight);
    var secondParagraph_l2:DynamicText3D = new DynamicText3D(HelveticaLight);
    var secondParagraph_l3:DynamicText3D = new DynamicText3D(HelveticaLight);
    var secondParagraph_l4:DynamicText3D = new DynamicText3D(HelveticaLight);
    var secondParagraph_l5:DynamicText3D = new DynamicText3D(HelveticaLight);
    var secondParagraph_l6:DynamicText3D = new DynamicText3D(HelveticaLight);

    var thirdHeader:DynamicText3D = new DynamicText3D(HelveticaMedium);
    var thirdParagraph_l1:DynamicText3D = new DynamicText3D(HelveticaLight);
    var thirdParagraph_l2:DynamicText3D = new DynamicText3D(HelveticaLight);
    var thirdParagraph_l3:DynamicText3D = new DynamicText3D(HelveticaLight);
    var thirdParagraph_l4:DynamicText3D = new DynamicText3D(HelveticaLight);
    var thirdParagraph_l5:DynamicText3D = new DynamicText3D(HelveticaLight);
    var thirdParagraph_l6:DynamicText3D = new DynamicText3D(HelveticaLight);

    public function onMouseClickEvent( event:MouseEvent):void
    {
    go = true;
    }

    public function handleFriendsLink1Clicked( event:MouseEvent):void
    {
    trace("clicked mark - http://www.bigkidsdidit.co.uk/");
    }

    public function handleFriendsLink2Clicked( event:MouseEvent):void
    {
    trace("clicked mike - http://mike.duguid.co.uk/");
    }

    public function handleWebDevelopmentLink1Clicked( event:MouseEvent):void
    {
    trace("clicked eastcoast - http://www.eastcoastinteractive.co.uk");
    }

    public function Main()
    {
    renderClip.addEventListener(MouseEvent.CLICK, onMouseClickEvent);
    friendsLink1.buttonMode = true;
    friendsLink1.addEventListener(MouseEvent.MOUSE_DOWN, handleFriendsLink1Clicked);
    friendsLink1Box.buttonMode = true;
    friendsLink1Box.addEventListener(MouseEvent.MOUSE_DOWN, handleFriendsLink1Clicked);

    friendsLink2.buttonMode = true;
    friendsLink2.addEventListener(MouseEvent.MOUSE_DOWN, handleFriendsLink2Clicked);
    friendsLink2Box.buttonMode = true;
    friendsLink2.addEventListener(MouseEvent.MOUSE_DOWN, handleFriendsLink2Clicked);

    stage.scaleMode=StageScaleMode.NO_SCALE;
    stage.align=StageAlign.TOP_LEFT;
    stage.addEventListener (Event.RESIZE,resizeHandler);

    var sw:Number=stage.stageWidth;
    var sh:Number=stage.stageHeight;

    // We create a new Scene3D named "scene", center it and add it to the display list.
    scene.x = sw/2;
    scene.y = sh/2;
    addChild(scene);

    scene.addChild(renderClip);
    renderClip.x = -sw/2;
    renderClip.y = -sh/2;
    renderClip.z = 0;

    renderClip.addChild(mainPanel);
    renderClip.addChild(header);
    renderClip.addChild(targetDot);

    mainPanel.addChild(searchBox);
    mainPanel.addChild(searchButton);
    mainPanel.addChild(searchButtonText);

    mainPanel.addChild(pagesHeader);
    mainPanel.addChild(pagesLink1);
    mainPanel.addChild(ArchivesHeader);
    mainPanel.addChild(archivesLink1);
    mainPanel.addChild(archivesLink2);
    mainPanel.addChild(categoriesHeader);
    mainPanel.addChild(categoriesLink1);
    mainPanel.addChild(categoriesLink2);
    mainPanel.addChild(friendsHeader);
    mainPanel.addChild(friendsLink1Box);
    mainPanel.addChild(friendsLink1);
    mainPanel.addChild(friendsLink2);
    mainPanel.addChild(friendsLink3);

    mainPanel.addChild(firstHeader);
    mainPanel.addChild(firstHeaderDate);
    mainPanel.addChild(firstParagraph_l1);
    mainPanel.addChild(firstParagraph_l2);
    mainPanel.addChild(firstParagraph_l3);

    mainPanel.addChild(secondHeader);
    mainPanel.addChild(secondParagraph_l1);
    mainPanel.addChild(secondParagraph_l2);
    mainPanel.addChild(secondParagraph_l3);
    mainPanel.addChild(secondParagraph_l4);
    mainPanel.addChild(secondParagraph_l5);
    mainPanel.addChild(secondParagraph_l6);

    mainPanel.addChild(thirdHeader);
    mainPanel.addChild(thirdParagraph_l1);
    mainPanel.addChild(thirdParagraph_l2);
    mainPanel.addChild(thirdParagraph_l3);
    mainPanel.addChild(thirdParagraph_l4);
    mainPanel.addChild(thirdParagraph_l5);
    mainPanel.addChild(thirdParagraph_l6);

    header.addChild(titleText);
    header.addChild(titleCaption);

    //targetDot.graphics3D.clear();
    //targetDot.graphics3D.beginFill(0xff0000);
    //targetDot.graphics3D.drawRoundRect(-4, -4, 4, 4, 2, 2);
    //targetDot.graphics3D.endFill();

    // We attribute a random value to the rotations on the X, Y and Z axes of the "mainPanel".
    //renderClip.rotationX = Math.random()*100-50;
    //renderClip.rotationY = Math.random()*100-50;
    //renderClip.rotationZ = Math.random()*100-50;

    renderClip.addEventListener(Event.ENTER_FRAME, loopHandler);

    // We register the class Main as a listener for the "click" mouse event of the "mainPanel" and modify some of its mouse-related properties.
    //mainPanel.addEventListener(MouseEvent.CLICK, mainPanelClickHandler);
    //mainPanel.mouseChildren = false;
    //mainPanel.buttonMode = true;

    // initialize sizing
    resizeHandler (null);
    }

    function resizeHandler (event:Event):void
    {
    var zz:Number = 0;
    // draw main panel
    var sw:Number=stage.stageWidth;
    var sh:Number=stage.stageHeight;
    var centreX:Number = sw/2;
    var mainPanelWidth:Number = 750;
    var mainPanelX:Number;
    var mainPanelY:Number = 30;
    var mainPanelHeight:Number = 800;

    if( mainPanelHeight &lt; 220 )
    {
    mainPanelHeight = 220;
    }

    scene.x = sw/2;
    scene.y = sh/2;
    renderClip.x = 0;
    renderClip.y = 0;

    if( sw &gt; mainPanelWidth+5 )
    {
    mainPanelX = sw/2 - mainPanelWidth/2;
    }
    else
    {
    mainPanelX = 5;
    }

    mainPanelX -= sw/2;
    mainPanelY -= sh/2;
    mainPanel.graphics3D.clear();
    mainPanel.graphics3D.lineStyle(2,0x888888);
    mainPanel.graphics3D.beginFill(0xffffff);
    mainPanel.graphics3D.drawRoundRect(mainPanelX, mainPanelY, mainPanelWidth, mainPanelHeight , 10, 10);
    mainPanel.graphics3D.endFill();

    /*trace("renderClip.x: " + renderClip.x );
    trace("renderClip.y: " + renderClip.y );
    trace("mainPanel.x: " + mainPanel.x );
    trace("mainPanel.y: " + mainPanel.y );
    trace("mainPanelX: " + mainPanelX );
    trace("mainPanelY: " + mainPanelY );*/


    // draw header
    var headerWidth:Number = mainPanelWidth - 20;
    var headerHeight:Number = 200;
    var headerX:Number = mainPanelX + 10;
    var headerY:Number = mainPanelY + 10;
    header.z = zz;
    header.graphics3D.clear();
    header.graphics3D.lineStyle(2,0xeeeeee);
    header.graphics3D.beginFill(0x5A9DD4);
    header.graphics3D.drawRoundRect(headerX, headerY, headerWidth, headerHeight, 10, 10);
    header.graphics3D.endFill();

    //trace("header.x: " + header.x);
    //trace("header.y: " + header.y);
    //trace("headerX: " + headerX);
    //trace("headerY: " + headerY);

    titleText.z = zz;
    titleText.size = 45;
    titleText.color = 0xFFFFFF;
    titleText.text = "The Datafake blog";
    titleText.x = headerX+175;
    titleText.y = headerY+70;

    titleCaption.z = zz;
    titleCaption.size = 16;
    titleCaption.color = 0xFFFFFF;
    titleCaption.text = "Web fun with Actionscript PHP and MySQL";
    titleCaption.x = headerX+225;
    titleCaption.y = headerY+120;

    searchBox.z = zz;
    searchBox.x = mainPanelX+574;
    searchBox.y = mainPanelY+260;
    searchBox.graphics3D.clear();
    searchBox.graphics3D.lineStyle(1,0x5A9DD4);
    searchBox.graphics3D.drawRect(-50, -10, 100, 22);
    searchBox.graphics3D.endFill();

    searchButton.z = zz;
    searchButton.x = mainPanelX+685;
    searchButton.y = mainPanelY+260;
    searchButton.graphics3D.clear();
    searchButton.graphics3D.lineStyle(0,0x000000);
    //searchButton.graphics3D.beginFill(1,0xaaaaaa);
    searchButton.graphics3D.drawRoundRect(-50, -10, 90, 22,6,6);
    searchButton.graphics3D.endFill();

    searchButtonText.z = zz;
    searchButtonText.size = 16;
    searchButtonText.color = 0x000000;
    searchButtonText.text = "Search";
    searchButtonText.x = headerX+646;
    searchButtonText.y = headerY+241;

    //var pagesHeader:DynamicText3D = new DynamicText3D(HelveticaMedium);
    //var pagesLink1:DynamicText3D = new DynamicText3D(HelveticaLight);

    pagesHeader.z = zz;
    pagesHeader.size = 16;
    pagesHeader.color = 0x000000;
    pagesHeader.text = "Pages";
    pagesHeader.x = mainPanelX+574;
    pagesHeader.y = mainPanelY+320;

    pagesLink1.z = zz;
    pagesLink1.size = 11;
    pagesLink1.color = 0x0000ff;
    pagesLink1.text = "About";
    pagesLink1.x = mainPanelX+584;
    pagesLink1.y = mainPanelY+340;

    ArchivesHeader.z = zz;
    ArchivesHeader.size = 16;
    ArchivesHeader.color = 0x000000;
    ArchivesHeader.text = "Archives";
    ArchivesHeader.x = mainPanelX+574;
    ArchivesHeader.y = mainPanelY+370;

    archivesLink1.z = zz;
    archivesLink1.size = 11;
    archivesLink1.color = 0x0000ff;
    archivesLink1.text = "July 2008";
    archivesLink1.x = mainPanelX+584;
    archivesLink1.y = mainPanelY+390;

    archivesLink2.z = zz;
    archivesLink2.size = 11;
    archivesLink2.color = 0x0000ff;
    archivesLink2.text = "June 2008";
    archivesLink2.x = mainPanelX+584;
    archivesLink2.y = mainPanelY+410;

    categoriesHeader.z = zz;
    categoriesHeader.size = 16;
    categoriesHeader.color = 0x000000;
    categoriesHeader.text = "Web Development";
    categoriesHeader.x = mainPanelX+574;
    categoriesHeader.y = mainPanelY+454;

    categoriesLink1.z = zz;
    categoriesLink1.size = 11;
    categoriesLink1.color = 0x0000ff;
    categoriesLink1.text = "East Coast Interactive";
    categoriesLink1.x = mainPanelX+584;
    categoriesLink1.y = mainPanelY+474;

    /*
    categoriesLink2.z = zz;
    categoriesLink2.size = 11;
    categoriesLink2.color = 0x0000ff;
    categoriesLink2.text = "Web Development(1)";
    categoriesLink2.x = mainPanelX+584;
    categoriesLink2.y = mainPanelY+494;
    */


    friendsHeader.z = zz;
    friendsHeader.size = 16;
    friendsHeader.color = 0x000000;
    friendsHeader.text = "Friends";
    friendsHeader.x = mainPanelX+574;
    friendsHeader.y = mainPanelY+504;

    friendsLink1.z = zz;
    friendsLink1.size = 11;
    friendsLink1.color = 0x0000ff;
    friendsLink1.text = "Mark McAulay";
    friendsLink1.x = mainPanelX+584;
    friendsLink1.y = mainPanelY+524;

    friendsLink1Box.z = zz;

    friendsLink1Box.graphics3D.clear();
    friendsLink1Box.graphics3D.beginFill(0xffff00);
    friendsLink1Box.graphics3D.drawRect(0, 0, 70, 15);
    friendsLink1Box.graphics3D.endFill();
    friendsLink1Box.x = mainPanelX+584;
    friendsLink1Box.y = mainPanelY+524;

    friendsLink2.z = zz;
    friendsLink2.size = 11;
    friendsLink2.color = 0x0000ff;
    friendsLink2.text = "Mike Duguid";
    friendsLink2.x = mainPanelX+584;
    friendsLink2.y = mainPanelY+546;

    /*
    mainPanel.addChild(flash3DHeader);
    mainPanel.addChild(flash3DLink1);
    mainPanel.addChild(flash3DLink2);
    mainPanel.addChild(flash3DLink3);
    */


    firstHeader.z = zz;
    firstHeader.size = 20;
    firstHeader.color = 0x000000;
    firstHeader.text = "The Library, Classes and MovieClips in AS3";
    firstHeader.x = mainPanelX+40;
    firstHeader.y = mainPanelY+250;

    firstHeaderDate.z = zz;
    firstHeaderDate.size = 12;
    firstHeaderDate.color = 0x000000;
    firstHeaderDate.text = "July 7th, 2008";
    firstHeaderDate.x = mainPanelX+40;
    firstHeaderDate.y = mainPanelY+275;

    firstParagraph_l1.z = zz;
    firstParagraph_l1.size = 16;
    firstParagraph_l1.color = 0x000000;
    firstParagraph_l1.text = "This post describes some of the differences I have stumbled over";
    //"whilst working with actionscript 3.0 and Flash CS3 compared to earlier versions.";
    firstParagraph_l1.x = mainPanelX+40;
    firstParagraph_l1.y = mainPanelY+320;

    firstParagraph_l2.z = zz;
    firstParagraph_l2.size = 16;
    firstParagraph_l2.color = 0x000000;
    firstParagraph_l2.text = "whilst working with actionscript 3.0 and Flash CS3 compared to ";
    firstParagraph_l2.x = mainPanelX+40;
    firstParagraph_l2.y = mainPanelY+340;

    firstParagraph_l3.z = zz;
    firstParagraph_l3.size = 16;
    firstParagraph_l3.color = 0x000000;
    firstParagraph_l3.text = "earlier versions....";
    firstParagraph_l3.x = mainPanelX+40;
    firstParagraph_l3.y = mainPanelY+360;

    /*
    secondHeader.z = zz;
    secondHeader.size = 20;
    secondHeader.color = 0x000000;
    secondHeader.text = "It starts with Export for Actionscript";
    secondHeader.x = mainPanelX+40;
    secondHeader.y = mainPanelY+400;

    secondParagraph_l1.z = zz;
    secondParagraph_l1.size = 16;
    secondParagraph_l1.color = 0x000000;
    secondParagraph_l1.text = "In AS2 if you wanted to access the properties of an instance on the ";
    secondParagraph_l1.x = mainPanelX+40;
    secondParagraph_l1.y = mainPanelY+430;

    secondParagraph_l2.z = zz;
    secondParagraph_l2.size = 16;
    secondParagraph_l2.color = 0x000000;
    secondParagraph_l2.text = "stage from code you had to ensure that the export for actionscript...";
    secondParagraph_l2.x = mainPanelX+40;
    secondParagraph_l2.y = mainPanelY+450;

    secondParagraph_l3.z = zz;
    secondParagraph_l3.size = 16;
    secondParagraph_l3.color = 0x000000;
    secondParagraph_l3.text = "checkbox was selected in the linkage properties for that MovieClip in ";
    secondParagraph_l3.x = mainPanelX+40;
    secondParagraph_l3.y = mainPanelY+470;

    secondParagraph_l4.z = zz;
    secondParagraph_l4.size = 16;
    secondParagraph_l4.color = 0x000000;
    secondParagraph_l4.text = "the library. If it wasnt your code wouldnt see the instance and would ";
    secondParagraph_l4.x = mainPanelX+40;
    secondParagraph_l4.y = mainPanelY+490;

    secondParagraph_l5.z = zz;
    secondParagraph_l5.size = 16;
    secondParagraph_l5.color = 0x000000;
    secondParagraph_l5.text = "fail silently. This was pretty confusing at first and even once you got ";
    secondParagraph_l5.x = mainPanelX+40;
    secondParagraph_l5.y = mainPanelY+510;

    secondParagraph_l6.z = zz;
    secondParagraph_l6.size = 16;
    secondParagraph_l6.color = 0x000000;
    secondParagraph_l6.text = "used to it there would be times that it would still catch you out.";
    secondParagraph_l6.x = mainPanelX+40;
    secondParagraph_l6.y = mainPanelY+530;

    thirdHeader.z = zz;
    thirdHeader.size = 20;
    thirdHeader.color = 0x000000;
    thirdHeader.text = "When you dont need to Export for ActionScript";
    thirdHeader.x = mainPanelX+40;
    thirdHeader.y = mainPanelY+580;

    thirdParagraph_l1.z = zz;
    thirdParagraph_l1.size = 16;
    thirdParagraph_l1.color = 0x000000;
    thirdParagraph_l1.text = "In AS3 you do not need to select the export for actionscript checkbox ";
    thirdParagraph_l1.x = mainPanelX+40;
    thirdParagraph_l1.y = mainPanelY+610;

    thirdParagraph_l2.z = zz;
    thirdParagraph_l2.size = 16;
    thirdParagraph_l2.color = 0x000000;
    thirdParagraph_l2.text = "to access the properties of an instance on the stage. Any MovieClip ";
    thirdParagraph_l2.x = mainPanelX+40;
    thirdParagraph_l2.y = mainPanelY+630;

    thirdParagraph_l3.z = zz;
    thirdParagraph_l3.size = 16;
    thirdParagraph_l3.color = 0x000000;
    thirdParagraph_l3.text = "instance you drag onto the stage at design time becomes a property";
    thirdParagraph_l3.x = mainPanelX+40;
    thirdParagraph_l3.y = mainPanelY+650;

    thirdParagraph_l4.z = zz;
    thirdParagraph_l4.size = 16;
    thirdParagraph_l4.color = 0x000000;
    thirdParagraph_l4.text = "of the document class and can be accessed from code as long as it has";
    thirdParagraph_l4.x = mainPanelX+40;
    thirdParagraph_l4.y = mainPanelY+670;

    thirdParagraph_l5.z = zz;
    thirdParagraph_l5.size = 16;
    thirdParagraph_l5.color = 0x000000;
    thirdParagraph_l5.text = "an instance name.";
    thirdParagraph_l5.x = mainPanelX+40;
    thirdParagraph_l5.y = mainPanelY+690;

    thirdParagraph_l6.z = zz;
    thirdParagraph_l6.size = 16;
    thirdParagraph_l6.color = 0x000000;
    thirdParagraph_l6.text = "If you do select export for actionscript for a clip in the library, like this";
    thirdParagraph_l6.x = mainPanelX+40;
    thirdParagraph_l6.y = mainPanelY+730;

    */

    //renderClip.y = - 400;
    }

    public function loopHandler(e:Event)
    {
    if( go )
    {
    if( renderClip.z &gt; - 400 )
    {
    renderClip.z-=0.5;
    }
    renderClip.rotationX -=.5;
    renderClip.rotationZ -=.05;
    }
    }

    }
    }

    Or get everything here.

    ]]>
    http://www.datafake.com/blog/?feed=rss2&p=7
    The Library, Classes and MovieClips in AS3 http://www.datafake.com/blog/?p=4 http://www.datafake.com/blog/?p=4#comments Mon, 07 Jul 2008 13:06:43 +0000 admin http://www.datafake.com/blog/?p=4 This post describes some of the differences I have stumbled over whilst working with actionscript 3.0 and Flash CS3 compared to earlier versions.

    It starts with Export for Actionscript

    In AS2 if you wanted to access the properties of an instance on the stage from code, you had to ensure that the “export for actionscript” checkbox was selected in the linkage properties for that MovieClip in the library. If it wasnt your code wouldn’t see the instance and would fail silently. This was pretty confusing at first and even once you got used to it there would be times that it would still catch you out.

    When you dont need to Export for ActionScript

    In AS3 you do not need to select the “export for actionscript” checkbox to access the properties of an instance on the stage. Any MovieClip instance you drag onto the stage at design time becomes a property of the document class and can be accessed from code as long as it has an instance name. This is only true when the “Automatically declare stage instances” option is checked in Publish Settings - Actionscript 3.0 Settings, which it is by default.

    If you do select “export for actionscript” for a clip in the library, like this.

    Linkage properties, class Square, base class flash.display.MovieClip

    When you click OK you will be greeted with the following slightly alarming pop-up message.

    ActionScript Class Warning
    A definition for this class could not be found in the classpath, so one will be automatically generated in the SWF file upon export.

    This is actually nothing to worry about but may induce mild panic, you just click OK to continue and your swf still works fine. What the message is saying is that you are creating a new type, in other words a new class.

    The MovieClip you have created in the library extends the definition of the flash MovieClip and adds extra features to it, at this point just the graphics you have drawn in it. The message is complaining that this extension of MoviClip doesn’t have a definition in code, there is not an .as file for it. However it lets you off lightly and generates the code inside the swf ( no .as files ) at compile time for your new type.

    When you do need to Export for ActionScript

    In AS3 “export for actionscript” should be selected when you want to add a MovieClip to the stage at runtime from actionscript. The syntax for doing this in AS3 with a MovieClip called Square in the library ( with export for actionscript selected ) looks like this.

    var mySquare_mc:Square = new Square();
    mySquare_mc.x= 100;
    mySquare_mc.y= 100;

    addChild (mySquare_mc );

    In the first line an instance of the new type Square is created and named mySquare. At this point mySquare doesnt exist on the display list ( so cant be seen on the stage )  it only exists as a variable in actionscript. The next two lines set some of the properties of the mySquare variable, in this case position. Then finally with the addChild command I hook the mySquare MovieClip variable onto the display list. mySquare now exists as a variable in actionscript and is referenced and displayed on the stage.

    In AS2 it was easy to think of MovieClips as things on the stage that your code could reference but with AS3 it becomes clear that a MovieClip is actually a type just as String or Number are.

    In the case above Square extends MovieClip. In purely Object Oriented terms this means that if I create an instance of Square it will have all the methods and properties of a MovieClip such as mySquare.x or mySquare.visible plus any extra I add to it. However so far I havent provided code for any extra methods hence the ActionScript Class Warning when the clip is created in the library. If I wanted to add extra methods to Square I could do so by adding a new .as file called Square.as if I wrote the .as before creating the clip in the library I wouldnt get the warning.

    Square.as

    package
    {
    import flash.display.MovieClip;

    public class Square extends MovieClip
    {
    public function sayHello()
    {
    trace( "Hello" );
    }
    }
    }

    Timeline code in my fla file

    var mySquare_mc:MovieClip = new Square();
    mySquare_mc.x= 100;
    mySquare_mc.y= 100;

    mySquare_mc.sayHello();

    addChild (mySquare_mc );

    The output now traces “hello”. As well as using the standard MovieClip methods and properties mySquare can also call the new method sayHello because it is of type Square and Square extends MovieClip.

    One last point, notice that this time I have declared mySquare as type MovieClip and before I declared it as type Square. Either could be used, this duality of type is what is known as polymorphism in Object Oriented speak.

    Hope that is of use to somebody!

    ]]>
    http://www.datafake.com/blog/?feed=rss2&p=4
    AS3 Basic Setup http://www.datafake.com/blog/?p=3 http://www.datafake.com/blog/?p=3#comments Sun, 29 Jun 2008 14:02:26 +0000 admin http://www.datafake.com/blog/?p=3 Writing your first Actionscript 3.0 application with Flash CS3. Here is the quick guide to get the basics set up.

    First create a fla. You can name this whatever you like. Maybe myFirstApp.fla. At this point you could start writing code directly into a timeline frame however best practice is to define a document class.

    The document class can be specified by entering the name of a class into the property panel for the document. This is the same place where you would specify the size of your swf. Think of a name for your document class, maybe: myFirstApp. The document class doesnt have to have the same name as your main fla there is no link between them.

    By typing myFirstApp into the property panel you are telling flash to create an instance of the myFirstApp class when the fla runs.

    When compiling your fla flash will go and look for the code for the myfirstApp class. It will look for a file called myFirstApp.as by searching the directory the fla is in or in the directories specified under classpath from preferences.

    The next step is to create the myFirstApp.as file. This just a text file with the extension changed to .as. Place the file in the same directory as your fla.

    Contents of myFirstApp.as

    package
    {
        import flash.display.Sprite;
        public class myFirstApp extends Sprite
        {
            public function myFirstApp()
            {
                trace("hi");
            }
        }
    }

    The package tag places the myFirstApp class into the root package. Which means this class wont be stored in a subfolder just in the same directory as the fla.

    The myFirstApp class extends Sprite. This means that the document class as well as having any further methods and propertys that you define will also have all the methods and properties of a Sprite. The import flash.display.Sprite statement lets the flash compiler know where to look for the definition of Sprite at compile time.

    Note that the myFirstApp.as class should only contain a class called myFirstApp or you will get errors.

    The document class unlike other classes must extend Sprite ( or some other display class ) because the document class automatically represents the swf stage. Any movieclips instances you name and place on the stage at author time become properties of the document class and can be accessed by name from actionscript inside the class.

    public function myFirstApp()
    {
        trace("hi");
    }

    This part defines the constructor for the myFirstApp class. The constructor function for a class is a function that has the same name as the class and is called whenever an instance of the class is created. For the document class an instance is created when the swf runs. This means that the constructor is the entry point for our application and the trace statement is the first line of code to be executed at runtime. The creators of flash have borrowed these concepts from the java world.

    And thats the basic set up!

    ]]>
    http://www.datafake.com/blog/?feed=rss2&p=3
    My first blog post http://www.datafake.com/blog/?p=1 http://www.datafake.com/blog/?p=1#comments Sat, 14 Jun 2008 23:51:57 +0000 admin http://www.datafake.com/blog/?p=1 Hello, you are reading my very first blog post. Ive just completed the famous 5 minute install of wordpress and it is working. Hurrah!!

    Im thinking about updating datafake since it has had the same flash content on it for the last 2 years, currently an AS2 jetsetwilly clone and some other knicknacks.

    Am thinking that i would like put up some AS3 thing that will let people litter the site with text, and also make it look nice.

    ]]>
    http://www.datafake.com/blog/?feed=rss2&p=1