Updates from November, 2009 Toggle Comment Threads | Keyboard Shortcuts

  • Shafiul Azam 7:36 pm on November 19, 2009 Permalink | Reply
    Tags: actionscript linking url, , open url in browser   

    Open a URL in new Browser window in Flex/ActionScript 

    ActionScript uses the function navigateToURL(var1:URLRequest,targetWindow:String ) to Open a URL link in a browser.

     

    For the simplictiy, there goes a function. Just calling the function with the desired URL as String will open the URL in a new window.

    public function jumpTo(jumpLoc:String):void
     {
     navigateToURL(new URLRequest(jumpLoc),"_blank");
     }

    Usage:

    Call the function defined above with the URL as a String-type parameter.
    Example:

    jumpTo("http://google.com");
    
    

    Previously published at my Progmaatic Blog

     
  • Shafiul Azam 7:26 pm on November 19, 2009 Permalink | Reply
    Tags: String replace in actionscript   

    String Replace Function in Flex ActionScript 

    There is a function String.replace() which returns the result string. But note, this only replaces the first occurance of given string/expression!

     

    So, to actually replace all the occurances of given string/expression, you must loop through until all the matches are replaced. Code & Documentation

    However, there is another easy customized function to automatically replace all the occurance of given match. Here goes the customized function:

    public function str_replace(mainStr:String, str1:String, str2:String):String
     {
     var temp:Array = mainStr.split(str1);
     var tempStr:String = temp.join(str2);
     return tempStr;
     }

    Usage:

    var myStr:String = str_replace("a_b_c", "_" , "1");   // a1b1c1

    Got Help From Source

     
  • Shafiul Azam 7:23 pm on November 19, 2009 Permalink | Reply
    Tags: actionscript split string, flex split string   

    Splitting Strings in Flex ActionScript: split method 

    Using Split method on a given String, you can get an array of Substrings. Each substring is formed from the given String by spliting them according to another given string, or expression. That means, the another string separates or splits the mother-String and split it into array of Substrings.

    Example:

    var myStr:String = "first_second_third";
    var subStr:Array = myStr.split("_");

    Now subStr[0] will contain “first”, subStr[2] will contain “third”;

    More Practical Example:

    package{
    import flash.display.Sprite;
    public class Main extends Sprite{
    public function Main(){
    var filename:String = "document.jpg";
    var nameParts:Array = filename.split(".");
    var extensionless:String = nameParts[0];
    trace ("The filename is " + extensionless);
    var extension:String = nameParts[1];
    trace ("The file extension is " + extension);
    }
    }
    }

    You can see following Useful Links:

    http://www.java2s.com/Code/Flash-Flex-ActionScript/String/Usesplitmethodtogetthefilenameanditsextensionname.htm

    This article was previously published at my Progmaatic Blog.

     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel
Follow

Get every new post delivered to your Inbox.