Welcome to my website. I am always posting links to photo albums, art, technology and other creations. Everything that you will see on my numerous personal sites is powered by the formVistaTM Website Management Engine.

icon.linkedin.jpgicon.twitter.jpg

  • getURL() in a Projector Firefox Bug and Solution
    10/24/2008 11:06AM
    If you have ever tried to do a simple getURL() command in Flash from an .exe projector you'll notice that it fails when Firefox is your default browser.

    Following is the solution to the problem in both AS 2.0 and AS 3.0
    Here's the code for the fix in AS 2.0:

    // code on a keyframe on the main timeline

    var swfUrl:String = _root._url;
    var lastSlashIndex:Number = swfUrl.lastIndexOf("/");
    var pipeIndex:Number = swfUrl.indexOf("|");
    var baseUrl:String;
    if (pipeIndex >= 0)
    {
    baseUrl = swfUrl.substring(0, pipeIndex);
    baseUrl += ":";
    }
    else
    {
    baseUrl = "";
    }
    baseUrl += swfUrl.substring(pipeIndex + 1, lastSlashIndex + 1);

    myButton.onRelease = function()
    {
    var targetUrl:String = baseUrl + "test.html";
    getURL(targetUrl, "_blank");
    };


    Here's the code for the fix in AS 3.0:

    // code on a keyframe on the main timeline

    import flash.events.MouseEvent;
    import flash.net.*;

    output_txt.text = this.loaderInfo.url;

    var swfUrl:String = this.root.loaderInfo.url;
    var lastSlashIndex:Number = swfUrl.lastIndexOf("/");
    var pipeIndex:Number = swfUrl.indexOf("|");
    var baseUrl:String;
    if (pipeIndex >= 0)
    {
    baseUrl = swfUrl.substring(0, pipeIndex);
    baseUrl += ":";
    }
    else
    {
    baseUrl = "";
    }
    baseUrl += swfUrl.substring(pipeIndex + 1, lastSlashIndex + 1);

    function gotoTestHtml(event:MouseEvent):void
    {
    var targetUrl:URLRequest = new URLRequest(baseUrl + "test.html");
    navigateToURL(targetUrl, "_blank");
    }

    myButton.addEventListener(MouseEvent.CLICK, gotoTestHtml);


    Here is a link to the original article where I found this with the full explanation and fix.
  • Creating MovieClips with Button States in AS 2.0
    09/24/2008 9:41AM
    Here is a quick tutorial on how to create MovieClips that act like buttons using ActionScript 2.0.  Attached is a sample .fla file with a complete, working example.
    1. Create a new Flash document for AS 2.0
    2. Create whatever graphic/shape that you would like and convert it to a symbol.  Double click on on it with the selection tool, and then press F8 to open the create symbol dialog box, or right click on it and select "Create Symbol".  Make sure that you create it as a MovieClip.
    3. Double-click on the new MovieClip to enter the symbol edit mode.
    4. Rename the existing "Layer 1" layer that contains the base graphic "bg".
    5. Create three new layers above that one in this order:
      1. labels
      2. actions
      3. text
    6. On the labels layer:
      1. Create a keyframe at frame 10, 20, and 30
      2. In frame 1, enter the following label: _up
      3. In frame 10, enter the following label: _over
      4. In frame 20, enter the following lable: _down
    7. On the actions layer create a keyframe at frame 10, 20, and 30 and put a stop(); action in frame 1, 10, and 20.
    8. On the text layer, create a keyframe at frame 10 and 20.
      1. Add the following text to each keyframe:
        1. Frame 1: Steady State
        2. Frame 10: Over
        3. Frame 20: Down
    9. Go back to your main timeline, by clicking on the "Scene 1" button.
    10. Select your MovieClip and give it an instance name of button_mc.
    11. Create a new layer in the main timeline and name it actions
    12. Add the following actions to it:
      1. button_mc.onRelease = function(){
            trace( "Click" );
        }
    13. Test your movie and when you rollover and click on the clip you will see the different states displayed.
    Attachment: movieclip_with_button_states.fla 65536 bytes
  • Using FlashPaper .swf files in ActionScript 2.0
    07/17/2008 4:48PM
    Macromedia Studio 8 shipped with Macromedia FlashPaper 2.0, a pretty cool app that will take PDF and other documents and convert them into .swf files that you can load into other flash/swf applications.

    The following is a quick tutorial on how to load FlashPaper swf files into Flash applications in ActionScript 2.0.
    This tutorial assumes that you know the basics of FlashPaper 2.0 and have a usable FlashPaper .swf file.

    Essentially, you will include an ActionScript file that will provide the functions to allow you to load in and scale the FlashPaper .swf and then include a few configurations and lines of code to load in the FlashPaper .swf.

    First, create a new ActionScript file, save as "flashpaper.loader.as" and copy and paste the following code into it:




    function loadFlashPaperSWF( arg_flashPaper_conf:Object ):Void{
        trace( "\nFrom loadFlashPaperSWF" );
        trace( "arg_flashPaper_conf.flashPaper_SWF " + arg_flashPaper_conf.flashPaper_SWF );
        // Creating the MovieClip into which we'll load our Flash Paper document.
        this.createEmptyMovieClip( "testMovie_mc", this.getNextHighestDepth() );
       
        // callback functions for this clip
        var mcObjListener = new Object();
        mcObjListener.onLoadComplete = function(){
            testMovie_mc._visible = false;
        }
        mcObjListener.onLoadInit = function( arg_target:MovieClip ):Void{
            trace( "running the onLoadInit callback" );
            trace( "arg_target = " + arg_target );
           
            // We'll have to wait until the first page of the flash paper document has loaded
            // before we have access to the FlashPaper API
            // To do so, we'll set up an interval that will check for it's existence.
            // Then run the setSize method
            var var_intervalID = 0;
           
            // Our check function
            function checkFlashPaperLoaded(){
                // Hide the holder clip until it is loaded
                // eval( arg_target )._visible = false;
               
                // Getting a reference to our FlashPaper object
                var var_flashPaperObj = eval( arg_target ).getIFlashPaper();
                trace( "var_flashPaperObj = " + var_flashPaperObj );
               
                if( !var_flashPaperObj ){
                    return;
                }
                else{
                    trace( "We now have access to our FlashPaper API" );
                    clearInterval( var_intervalID );
                   
                    // Resize the doc to fit the size of the stage
                    var_flashPaperObj.setSize( arg_flashPaper_conf.flashPaper_width,
                                              arg_flashPaper_conf.flashPaper_height );
                   
                    // Setting the document to fit to height:
                    // var_flashPaperObj.setCurrentZoom( "page" );
                   
                    // Show it
                    eval( arg_target )._visible = true;
                }
            }
            var_intervalID = setInterval(checkFlashPaperLoaded, 100);
        };
       
       
        // Here we create a new MovieClipLoader Object
        var var_movieClipLoader = new MovieClipLoader();
                   
        // Here we add the listener to our new MovieClipLoader Object
        var_movieClipLoader.addListener( mcObjListener );
               
        // Now we use our new MovieClipLoader object to load the swf into the movieclip holder
        var_movieClipLoader.loadClip( arg_flashPaper_conf.flashPaper_SWF, "testMovie_mc" );

    }




    Then, create a new Flash file (ActionScript 2.0) and add the following to the first frame of the timeline:



    #include "flashpaper.loader.as"

    // ============================================================================
    // Configurations:
    //
    // Our config object
    var obj_flashPaper_conf:Object = new Object();

    // The flash paper swf to load:
    obj_flashPaper_conf.flashPaper_SWF = "files/flashpaper_docs/flashpaper.swf";

    // The width and height of our flashpaper doc
    obj_flashPaper_conf.flashPaper_width = 650;
    obj_flashPaper_conf.flashPaper_height = 320;

    // ============================================================================

    // Loading our Flash Paper SWF
    loadFlashPaperSWF( obj_flashPaper_conf );




    Edit the configurations to specify the location of the FlashPaper .swf and the size that you want it to be displayed and you are good to go.
  • Loading and Manipulating FlashPaper 2.0 SWFs into Flash
    04/23/2008 10:33AM
    This tutorial demonstrates how to load and manipulate (resize in this example, but once you have access to the API you can do a whole lot of other things) FlashPaper 2.0 SWF files with ActionScript 2.0.

    You will need:
    • Flash MX 2004 or Flash 8
    • FlashPaper 2.0
    Click here to see the example in action.
    Click on the attachment to download sample files.
    In this example, we will simply load a FlashPaper 2.0 document and scale it to fit the size of our Flash Movie.

    Here's an article about using FlashPaper documents.
    For more details see the documentation on the FlashPaper API.

    Add the following code to the first frame of your movie.


    // Creating the MovieClip into which we'll load our Flash Paper document.
    this.createEmptyMovieClip( "testMovie_mc", this.getNextHighestDepth() );

    // callback functions for this clip
    var mcObjListener = new Object();
    mcObjListener.onLoadComplete = function(){
        testMovie_mc._visible = false;
    }
    mcObjListener.onLoadInit = function( arg_target:MovieClip ):Void{
        trace( "running the onLoadInit callback" );
        trace( "arg_target = " + arg_target );
       
        // We'll have to wait until the first page of the flash paper document has loaded
        // before we have access to the FlashPaper API
        // To do so, we'll set up an interval that will check for it's existence.
        // Then run the setSize method
        var var_intervalID = 0;
       
        // Our check function
        function checkFlashPaperLoaded(){
            // Hide the holder clip until it is loaded
            // eval( arg_target )._visible = false;
           
            // Getting a reference to our FlashPaper object
            var var_flashPaperObj = eval( arg_target ).getIFlashPaper();
            trace( "var_flashPaperObj = " + var_flashPaperObj );
           
            if( !var_flashPaperObj ){
                return;
            }
            else{
                trace( "We now have access to our FlashPaper API" );
                clearInterval( var_intervalID );
               
                // Resize the doc
                var_flashPaperObj.setSize( 800, 600 );
               
                // Show it
                eval( arg_target )._visible = true;
            }
        }
        var_intervalID = setInterval(checkFlashPaperLoaded, 100);
    };


    // Here we create a new MovieClipLoader Object
    var var_movieClipLoader = new MovieClipLoader();
               
    // Here we add the listener to our new MovieClipLoader Object
    var_movieClipLoader.addListener( mcObjListener );
           
    // Now we use our new MovieClipLoader object to load the swf into the movieclip holder
    var_movieClipLoader.loadClip( "build.it.and.then.tell.them.swf", "testMovie_mc" );





    Make sure you have a FlashPaper 2.0 SWF of the appropriate name in the same directory and compile to see you document in Flash.

    Remember that the FlashPlayer security settings will not allow you to view this example in a browser locally.  To see it in a browser, publish a .html file with it and post to your webserver.
    Attachment: flashpaper_as2.0.zip 197626 bytes
  • Using Michael Jordan's Open Source Captioned Skins for the FLVPlayback Component in AS 2.0
    04/23/2008 9:35AM
    Following is a quick tutorial on how to set-up and use the set of captioned FLVPlayback skins created by Michael Jordan.

    This tutorial covers using the skins with ActionScript 2.0 cuepoints.
    First off, download the set of skins.  I've included them with this blog entry (because Adobe is notorious for moving and deleting pages), but there may be a newer version out there so check out this page, and/or Michael's page.

    Once you've downloaded and installed the skins fire up Flash and open a new document.

    Import your .flv video and place an instance on the stage.

    Name your FLVPlayer instance flvInstance.

    In the Component Inspector set your skin to one of the Captioned skins you just installed.

    Add the following code to the first frame of your movie, or add it to an .as file and include it into your .fla file.

    // ----------------------------------------------------------------------------

    /*
    Defining cue points
    We must define an ActionScript cuePoint object and a parameters object that contains the caption content
    */

    // Example of a cuepoint that includes a speaker indicator:
    var var_cuePoint_00_content:Object = { en: "Here we define our first cuepoint.", spk: "Ryan" };
    // Now we define our time, the name of the cueoint and add the aforementioned object as the cuepoint's parameters
    var var_cuePoint_00:Object = { time: 2.05, name: "caption", type: "actionscript", parameters: var_cuePoint_00_content };

    // Example of item without a speaker:
    var var_cuePoint_01_content:Object = { en: "Here is the second cuepoint" };
    var var_cuePoint_01:Object = { time: 4.05, name: "caption", type: "actionscript", parameters: var_cuePoint_01_content };

    // Adding our cue points to our FLVPlayer instance
    flvInstance.addASCuePoint( var_cuePoint_00 );
    flvInstance.addASCuePoint( var_cuePoint_01 );

    // Adding a listener for our FLVPlayback instance so you can see what's going
    var listenerObject:Object = new Object();
    listenerObject.cuePoint = function(eventObject:Object) {
        trace( "Elapsed time in seconds: " + flvInstance.playheadTime + "\n" );
        for( var prop:String in eventObject ){
            trace( "Property  [" + prop + "] = " + eventObject[prop] );
            if( prop == "info" ){
                trace( "the info property" );
               
                for( var infoProp:String in eventObject[prop] ){
                    trace( "Property [" + infoProp + "] = " + eventObject[prop][infoProp] );
                }
            }
        }
    };
    flvInstance.addEventListener("cuePoint",listenerObject);

    // ----------------------------------------------------------------------------


    Compile your .swf, click on the "CC" button, play your FLV and you should see your captions as your video plays
    Attachment: CaptionedSkins_v1_4.mxp 13410190 bytes
Advanced Search

Categories

Archives