Prevent Cache of SWF Files and Xml Content in Flash

by Nathan 19. August 2009 09:17

 

If you like the flash player to expire the content of the SWF file add the following line between your <HEAD></HEAD>  tags

<META HTTP-EQUIV="Expires" CONTENT="Mon, 04 Dec 1999 21:29:02 GMT">
for more information check out: 
http://kb2.adobe.com/cps/147/tn_14743.html 

 

To prevent flash caching xml data, you can use the cache manager extension. It basically adds a timestamp to the querystring so it looks like a unique request.

 

You can download this from here:

http://www.communitymx.com/content/article.cfm?cid=827ea

Once you install the extension the usage is quite simple:

xml.load(CacheManager.uncacheURL(XmlFileLocation));

 

Tags: ,

Flash

Calculating Elapsed Time ActionScript

by Nathan 27. July 2009 09:58

 

function calculateTimeElapsed(startTime:Date,endTime:Date) {
    
    var sHours = startTime.getHours();
    var sMinutes = startTime.getMinutes();
     var sSeconds = startTime.getSeconds();
    var sMilliSeconds = startTime.getMilliseconds();

    var eHours = endTime.getHours();
    var eMinutes = endTime.getMinutes();
     var eSeconds = endTime.getSeconds();
    var eMilliSeconds = endTime.getMilliseconds();
    
    var sTimeSpan = (sHours*3600*1000) + (sMinutes*60*1000) + (sSeconds*1000) + (sMilliSeconds);
    var eTimeSpan = (eHours*3600*1000) + (eMinutes*60*1000) + (eSeconds*1000) + (eMilliSeconds);
    return eTimeSpan - sTimeSpan;
    
}

Tags: ,

Flash

Dynamically Creating Movie Clips in Flash

by Nathan 16. July 2009 05:19

var myText:TextField;

for (var i:Number = 1; i<6; i++) {
        this["clip"+i] = new MovieClip();
        this["clip"+i].graphics.beginFill(0xFFFF00);
        this["clip"+i].graphics.drawCircle(40, 40, 40);
        this["clip"+i].x=i*80;
        myText=new TextField;
        myText.width=250;
        myText.height=250;
        myText.text="clip" +i;
        myText.x=10;
        myText.y=20;
        this["clip"+i].addChild(myText);
        addChild(this["clip"+i]);
}

Tags: ,

Flash

Accessing Web Services in Flash AS2

by Nathan 22. January 2009 14:56

 

Here is some example code to access web services in Action Script 2

// Import the Service Library

import mx.services.*;

// define your web service URL, remember to have WDSL at the end

var webService= "http://www.mywebhost.com/webservice/service.asmx?WDSL";

var webService = new mx.services.WebService(webService);
var serviceStatus = true;
webService.onLoad = function (result)
{
    trace("Accessing Web Service: " + company.WebService);
}
;

 

 // to access a method in the web service

 function loadWebMethod() {

    var value1:String = 'test value';

    var value2:Number = 100;

    // set object to use web method called 'MyWebMethod'

    serviceObj = webService.MyWebMethod(value1,value2);

    serviceObj .onStatus = function(status) {
        trace(status);
    };

    serviceObj .onResult = function(result) {
        // Load Current Server Time
        trace(result.toString());
        var xml:XML = new XML();
        xml.ignoreWhite = true;
        xml.parseXML(result.toString());
        ServerTime.Year = xml.firstChild.attributes.year;
    };

    serviceObj .onFault = function(fault) {
        trace("Failed to Load WebService"+fault.faultCode+","+fault.faultstring);
    };
}

 

 

Tags: , , ,

Flash

Powered by BlogEngine.NET 1.6.0.0
Theme by Mads Kristensen