Flash Action 3

Embed Size (px)

Citation preview

  • 7/27/2019 Flash Action 3

    1/26

    Some people have been asking how to create button code in Flash (CS3, CS4, or CS5) that progresses the playhead

    in a SWF to the next or previous frame using ActionScript 3.0. This is not too difficult, and is a super simple code

    modification from any other button in AS3 (and is actually a touch easier than AS2 due to scoping issues).

    This post includes an example of how to create two buttons that click between a few different frames. Ill also include

    a (CS4) FLA file for you to look at and the AS2 equivalent.

    The following code is for two buttons with the instance names button1 and button2. It uses the usual code for multiple

    buttons in a FLA file (for more information,see this post). A link to an example FLA follows the AS3 code.

    stop();

    button1.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler1);function mouseDownHandler1(event:MouseEvent):void{

    prevFrame();}

    button2.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler2);function mouseDownHandler2(event:MouseEvent):void

    {nextFrame();

    }

    - See more at:http://flashthusiast.com/2010/05/05/buttons-in-flash-using-actionscript-3-0-going-to-next-frame-and-

    previous-frame/#sthash.OX1LIA0u.dpuf

    In ActionScript 2.0, you need to do a bit of targeting to make things work correctly (although the button code is a bit

    simpler of course). Heres the same thing in AS2:

    stop();button1.onRelease = function(){

    this._parent.prevFrame();};

    button2.onRelease = function(){this._parent.nextFrame();

    };

    - See more at:http://flashthusiast.com/2010/05/05/buttons-in-flash-using-actionscript-3-0-going-to-next-frame-and-

    previous-frame/#sthash.OX1LIA0u.dpuf

    A common request in the comments is for information on how to create a button that links to a scene using ActionScript

    3.0 in Flash CS4 or CS3. Luckily, its largely the same as creating a normal button that links to whatever, and uses

    the same gotoAndPlay format as in ActionScript 2.0. So hopefully itll make sense once you see it.

    So if youre unsure on general button code, see this post here:Making a button work in AS3.More links about writing

    button code at the end of this post.

    Now youre ready for some scenes-with-buttons action. Heres some code:

    stop();button1.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);function mouseDownHandgotoAndStop(1, "Scene 2");

    }

    http://flashthusiast.com/2008/03/13/adding-more-than-one-button-to-a-fla-file-while-rocking-it-in-actionscript-30/http://flashthusiast.com/2008/03/13/adding-more-than-one-button-to-a-fla-file-while-rocking-it-in-actionscript-30/http://flashthusiast.com/2008/03/13/adding-more-than-one-button-to-a-fla-file-while-rocking-it-in-actionscript-30/http://flashthusiast.com/2010/05/05/buttons-in-flash-using-actionscript-3-0-going-to-next-frame-and-previous-frame/#sthash.OX1LIA0u.dpufhttp://flashthusiast.com/2010/05/05/buttons-in-flash-using-actionscript-3-0-going-to-next-frame-and-previous-frame/#sthash.OX1LIA0u.dpufhttp://flashthusiast.com/2010/05/05/buttons-in-flash-using-actionscript-3-0-going-to-next-frame-and-previous-frame/#sthash.OX1LIA0u.dpufhttp://flashthusiast.com/2010/05/05/buttons-in-flash-using-actionscript-3-0-going-to-next-frame-and-previous-frame/#sthash.OX1LIA0u.dpufhttp://flashthusiast.com/2010/05/05/buttons-in-flash-using-actionscript-3-0-going-to-next-frame-and-previous-frame/#sthash.OX1LIA0u.dpufhttp://flashthusiast.com/2010/05/05/buttons-in-flash-using-actionscript-3-0-going-to-next-frame-and-previous-frame/#sthash.OX1LIA0u.dpufhttp://flashthusiast.com/2010/05/05/buttons-in-flash-using-actionscript-3-0-going-to-next-frame-and-previous-frame/#sthash.OX1LIA0u.dpufhttp://flashthusiast.com/2010/05/05/buttons-in-flash-using-actionscript-3-0-going-to-next-frame-and-previous-frame/#sthash.OX1LIA0u.dpufhttp://flashthusiast.com/2008/02/25/making-a-button-work-in-flash-cs3-with-actionscript-30-its-not-too-bad/http://flashthusiast.com/2008/02/25/making-a-button-work-in-flash-cs3-with-actionscript-30-its-not-too-bad/http://flashthusiast.com/2008/02/25/making-a-button-work-in-flash-cs3-with-actionscript-30-its-not-too-bad/http://flashthusiast.com/2008/02/25/making-a-button-work-in-flash-cs3-with-actionscript-30-its-not-too-bad/http://flashthusiast.com/2010/05/05/buttons-in-flash-using-actionscript-3-0-going-to-next-frame-and-previous-frame/#sthash.OX1LIA0u.dpufhttp://flashthusiast.com/2010/05/05/buttons-in-flash-using-actionscript-3-0-going-to-next-frame-and-previous-frame/#sthash.OX1LIA0u.dpufhttp://flashthusiast.com/2010/05/05/buttons-in-flash-using-actionscript-3-0-going-to-next-frame-and-previous-frame/#sthash.OX1LIA0u.dpufhttp://flashthusiast.com/2010/05/05/buttons-in-flash-using-actionscript-3-0-going-to-next-frame-and-previous-frame/#sthash.OX1LIA0u.dpufhttp://flashthusiast.com/2008/03/13/adding-more-than-one-button-to-a-fla-file-while-rocking-it-in-actionscript-30/
  • 7/27/2019 Flash Action 3

    2/26

    So that code assumes that you have a button with the instance name button1, and a scene in your document called

    Scene 2 in the Scenes panel. The number "1" in that code points to frame 1 of the scene.

    So what if you want to, say, link to a particular frame? Lets link to frame 5 of a scene called monkeyScene:

    stop();button2.addEventListener(MouseEvent.MOUSE_DOWN, monkeyDownHandler);

    function monkeyDownHandler(event:MouseEvent):void{

    gotoAndStop(5, "monkeyScene");

    }

    Hope that answers the question. Ive put anFLA file online that links each scene using buttonsso you can see this in

    action.

    Linking to buttons within a scene

    There have also been questions about linking to frames within a scene. Im not positive what the specific problem is,

    but Ill take a stab at it (or at least show what seems to work for me.

    Now, what causes many of the problems with Scenes in Flash (and why they are officially discouraged from use inFlash best practicesI never use em unless I have next to no code in a FLA), is as follows. From what I understand,

    when you publish your SWF file, all of the scenes in a FLA are made into one big giant string of frames. Kind of like

    sticking all of your scenes into one big timeline (one big scene, essentially) and pushing it out as a SWF. Therefore,

    this can mess up your code. If youre pointing to a frame 56 which one? To you it may be frame 56 of scene 3, but

    to Flash that may be frame 56 of the giant new timeline in the SWF thats published.

    So, its good to avoid scenes.

    But I digress. So if youre linking to buttons within the same scene, you could specify what scene youre pointing to in

    each button. So if youre in a scene called monkeyScene, you could make your button thats on frame 1 point to

    frame 2 of monkeyScene as follows:

    stop();

    mbutton1.addEventListener(MouseEvent.MOUSE_DOWN, monkeyHandler1);

    function monkeyHandler1(event:MouseEvent):void{

    gotoAndStop(2, "monkeyScene");

    }

    - See more at:http://flashthusiast.com/2008/07/31/creating-buttons-that-link-to-different-scenes-using-actionscript-

    30/#sthash.FC4zIFKj.dpuf

    One of my frequently asked questions in the comments is how to control what window a button click opens using

    ActionScript 3.0. For example, you might want your button to open in the same window, a particular part of your

    frames layout, or a new window. Its similar to ActionScript 2.0, but there is a bit of a difference.

    If youre wondering how to just make a button work, read this post:http://flashthusiast.com/2008/02/25/making-a-button-work-

    in-flash-cs3-with-actionscript-30-its-not-too-bad

    http://flashthusiast.com/wp-content/uploads/2008/07/buttons-scenes.flahttp://flashthusiast.com/wp-content/uploads/2008/07/buttons-scenes.flahttp://flashthusiast.com/wp-content/uploads/2008/07/buttons-scenes.flahttp://flashthusiast.com/2008/07/31/creating-buttons-that-link-to-different-scenes-using-actionscript-30/#sthash.FC4zIFKj.dpufhttp://flashthusiast.com/2008/07/31/creating-buttons-that-link-to-different-scenes-using-actionscript-30/#sthash.FC4zIFKj.dpufhttp://flashthusiast.com/2008/07/31/creating-buttons-that-link-to-different-scenes-using-actionscript-30/#sthash.FC4zIFKj.dpufhttp://flashthusiast.com/2008/07/31/creating-buttons-that-link-to-different-scenes-using-actionscript-30/#sthash.FC4zIFKj.dpufhttp://flashthusiast.com/2008/02/25/making-a-button-work-in-flash-cs3-with-actionscript-30-its-not-too-badhttp://flashthusiast.com/2008/02/25/making-a-button-work-in-flash-cs3-with-actionscript-30-its-not-too-badhttp://flashthusiast.com/2008/02/25/making-a-button-work-in-flash-cs3-with-actionscript-30-its-not-too-badhttp://flashthusiast.com/2008/02/25/making-a-button-work-in-flash-cs3-with-actionscript-30-its-not-too-badhttp://flashthusiast.com/2008/02/25/making-a-button-work-in-flash-cs3-with-actionscript-30-its-not-too-badhttp://flashthusiast.com/2008/02/25/making-a-button-work-in-flash-cs3-with-actionscript-30-its-not-too-badhttp://flashthusiast.com/2008/07/31/creating-buttons-that-link-to-different-scenes-using-actionscript-30/#sthash.FC4zIFKj.dpufhttp://flashthusiast.com/2008/07/31/creating-buttons-that-link-to-different-scenes-using-actionscript-30/#sthash.FC4zIFKj.dpufhttp://flashthusiast.com/wp-content/uploads/2008/07/buttons-scenes.fla
  • 7/27/2019 Flash Action 3

    3/26

    If youre wondering how to make multiple buttons work together, read this post:http://flashthusiast.com/2008/03/13/adding-

    more-than-one-button-to-a-fla-file-while-rocking-it-in-actionscript-30/

    If youre wondering how to make a button click between scenes, read this post:http://flashthusiast.com/2008/07/31/creating-

    buttons-that-link-to-different-scenes-using-actionscript-30/

    In ActionScript 2.0, you set a target for your button using code such as the following:

    The following steps for ActionScript 3.0 will apply to either Flash CS3 or Flash CS4, just make sure that your

    document is an ActionScript 3.0 button and youre adding the code to a frame.

    1. Create your button in your FLA, and give it an instance name in the Property inspector, such as my_btn.

    2. Select a frame on the timeline at the same frame number of your button.

    3. Open the Actions panel, and add the following code:

    my_btn.addEventListener(MouseEvent.MOUSE_DOWN, myHandler);function myHandler(event:MouseEvent):void{

    navigateToURL(new URLRequest("http://www.adobe.com/devnet/flash/"), "_self");}

    4. Publish preview your work in HTML (File > Publish Preview > HTML). Note: When testing locally, you will need to set your

    security to allow access to the SWF. If you havent set this up, click Settings in the dialog that opens when you first test your

    FLA, select a directory on your hard drive, and save the FLA to that same directory and test again.

    By default, without adding this parameter, ActionScript assumes _blank which opens a new window. You can modify the _self in

    the code above to be _top or _parent (or _blankif you want). Heres what each of them does:

    o _self opens the link in the current frame of the current browser window.

    o _blankopens the link in a new window (or tab if thats what the user has their browser set to do).

    o _parent opens the link in the parent of the current frame.

    o _top opens the link in the top-level frame of the current browser window.- See more at:http://flashthusiast.com/2009/07/24/controlling-the-window-a-button-click-opens-using-actionscript-30-

    in-flash/#sthash.rIw7m2vH.dpuf

    http://flashthusiast.com/2008/03/13/adding-more-than-one-button-to-a-fla-file-while-rocking-it-in-actionscript-30/http://flashthusiast.com/2008/03/13/adding-more-than-one-button-to-a-fla-file-while-rocking-it-in-actionscript-30/http://flashthusiast.com/2008/03/13/adding-more-than-one-button-to-a-fla-file-while-rocking-it-in-actionscript-30/http://flashthusiast.com/2008/03/13/adding-more-than-one-button-to-a-fla-file-while-rocking-it-in-actionscript-30/http://flashthusiast.com/2008/07/31/creating-buttons-that-link-to-different-scenes-using-actionscript-30/http://flashthusiast.com/2008/07/31/creating-buttons-that-link-to-different-scenes-using-actionscript-30/http://flashthusiast.com/2008/07/31/creating-buttons-that-link-to-different-scenes-using-actionscript-30/http://flashthusiast.com/2008/07/31/creating-buttons-that-link-to-different-scenes-using-actionscript-30/http://flashthusiast.com/2009/07/24/controlling-the-window-a-button-click-opens-using-actionscript-30-in-flash/#sthash.rIw7m2vH.dpufhttp://flashthusiast.com/2009/07/24/controlling-the-window-a-button-click-opens-using-actionscript-30-in-flash/#sthash.rIw7m2vH.dpufhttp://flashthusiast.com/2009/07/24/controlling-the-window-a-button-click-opens-using-actionscript-30-in-flash/#sthash.rIw7m2vH.dpufhttp://flashthusiast.com/2009/07/24/controlling-the-window-a-button-click-opens-using-actionscript-30-in-flash/#sthash.rIw7m2vH.dpufhttp://flashthusiast.com/2009/07/24/controlling-the-window-a-button-click-opens-using-actionscript-30-in-flash/#sthash.rIw7m2vH.dpufhttp://flashthusiast.com/2009/07/24/controlling-the-window-a-button-click-opens-using-actionscript-30-in-flash/#sthash.rIw7m2vH.dpufhttp://flashthusiast.com/2008/07/31/creating-buttons-that-link-to-different-scenes-using-actionscript-30/http://flashthusiast.com/2008/07/31/creating-buttons-that-link-to-different-scenes-using-actionscript-30/http://flashthusiast.com/2008/03/13/adding-more-than-one-button-to-a-fla-file-while-rocking-it-in-actionscript-30/http://flashthusiast.com/2008/03/13/adding-more-than-one-button-to-a-fla-file-while-rocking-it-in-actionscript-30/
  • 7/27/2019 Flash Action 3

    4/26

    GETTING STARTED WITH THE TLFTEXTFIELD CLASSIN ACTIONSCRIPT 3.0 AND FLASH CS5

    5 May, 2010ActionScript 3.0Flash CS5Flash CS5: new featurestextTLFPeter deHaan

    (ActionScriptExamples.com)Permalink

    The following examples show how you can get started with the TLFTextField class in ActionScript in Adobe Flash

    Professional CS5.

    Download ZIP

    1. The following example shows how you can create a simple TLFTextField instance using ActionScript:

    import fl.text.TLFTextField;

    ar tlfTxt:TLFTextField = new TLFTextField();tlfTxt.border = true;tlfTxt.text = "The quick brown fox jumps over the lazy dog.";tlfTxt.x = tlfTxt.y = 20;addChild(tlfTxt);

    2. If you want to set word wrap on a TLFTextField instance, you can set the Boolean wordWrap property, as seen in the following

    example:

    import fl.text.TLFTextField;

    ar tlfTxt:TLFTextField = new TLFTextField();tlfTxt.border = true;tlfTxt.text = "The quick brown fox jumps over the lazy dog.";tlfTxt.wordWrap = true;tlfTxt.x = tlfTxt.y = 20;addChild(tlfTxt);

    3. By default a TLFTextField instance is 100px by 100px. If you want to automatically resize the TLFTextField instance to the

    measured text width/height, you can set the autoSize property to one of the static constants from the flash.text.TextFieldAutoSize

    class, as seen in the following example:

    import fl.text.TLFTextField;importflash.text.TextFieldAutoSize;

    ar tlfTxt:TLFTextField = new TLFTextField();tlfTxt.border = true;tlfTxt.text = "The quick brown fox jumps over the lazy dog.";tlfTxt.wordWrap = true;tlfTxt.autoSize = TextFieldAutoSize.LEFT;tlfTxt.x = tlfTxt.y = 20;addChild(tlfTxt);

    4. If you want to set rich text formatting, you can set the htmlText instead of the text format, as seen in the following example:

    http://flashthusiast.com/category/actionscript-30/http://flashthusiast.com/category/actionscript-30/http://flashthusiast.com/category/flash-cs5/http://flashthusiast.com/category/flash-cs5/http://flashthusiast.com/category/flash-cs5-new-features/http://flashthusiast.com/category/flash-cs5-new-features/http://flashthusiast.com/category/text/http://flashthusiast.com/category/text/http://flashthusiast.com/category/tlf/http://flashthusiast.com/category/tlf/http://flashthusiast.com/author/pdehaan/http://flashthusiast.com/author/pdehaan/http://flashthusiast.com/author/pdehaan/http://flashthusiast.com/2010/05/05/getting-started-with-the-tlftextfield-class-in-actionscript-3-0-and-flash-cs5/http://flashthusiast.com/2010/05/05/getting-started-with-the-tlftextfield-class-in-actionscript-3-0-and-flash-cs5/http://flashthusiast.com/2010/05/05/getting-started-with-the-tlftextfield-class-in-actionscript-3-0-and-flash-cs5/http://dl.dropbox.com/u/4509565/ActionScriptExamples_com/GettingStartedTLF/GettingStartedTLF.ziphttp://dl.dropbox.com/u/4509565/ActionScriptExamples_com/GettingStartedTLF/GettingStartedTLF.ziphttp://dl.dropbox.com/u/4509565/ActionScriptExamples_com/GettingStartedTLF/GettingStartedTLF.ziphttp://flashthusiast.com/2010/05/05/getting-started-with-the-tlftextfield-class-in-actionscript-3-0-and-flash-cs5/http://flashthusiast.com/author/pdehaan/http://flashthusiast.com/author/pdehaan/http://flashthusiast.com/category/tlf/http://flashthusiast.com/category/text/http://flashthusiast.com/category/flash-cs5-new-features/http://flashthusiast.com/category/flash-cs5/http://flashthusiast.com/category/actionscript-30/
  • 7/27/2019 Flash Action 3

    5/26

    import fl.text.TLFTextField;importflash.text.TextFieldAutoSize;

    ar tlfTxt:TLFTextField = new TLFTextField();tlfTxt.border = true;tlfTxt.htmlText = "

    The quick brown fox jumps over the

  • 7/27/2019 Flash Action 3

    6/26

    import fl.text.TLFTextField;importflash.text.TextFieldAutoSize;importflash.text.TextFormat;

    ar defaultFmt:TextFormat = newTextFormat();defaultFmt.font = "Arial";defaultFmt.size = 32;

    ar redFmt:TextFormat = newTextFormat();redFmt.color = 0xFF0000;// red

    ar tlfTxt:TLFTextField = new TLFTextField();tlfTxt.border = true;tlfTxt.defaultTextFormat = defaultFmt;tlfTxt.text = "The quick brown fox jumps over the lazy dog.";tlfTxt.setTextFormat(redFmt,4,9);tlfTxt.wordWrap = true;tlfTxt.width = 300;tlfTxt.autoSize = TextFieldAutoSize.LEFT;tlfTxt.x = tlfTxt.y = 40;

    addChild(tlfTxt);8. To set the text alpha on the TLFTextField instance you can set the alpha property, as seen in the following example:

    import fl.text.TLFTextField;importflash.text.TextFieldAutoSize;

    ar tlfTxt:TLFTextField = new TLFTextField();tlfTxt.border = true;tlfTxt.text = "The quick brown fox jumps over the lazy dog.";tlfTxt.wordWrap = true;tlfTxt.autoSize = TextFieldAutoSize.LEFT;tlfTxt.x = tlfTxt.y = 40;tlfTxt.alpha = 0.3;addChild(tlfTxt);

    Unlike the TextField class which only supports setting text alpha on a TextField with an embedded font, the TLFTextField class

    supports setting text alpha on device (non-embedded) fonts.

    9. To set the text rotation on the TLFTextField instance you can set the rotation property, as seen in the following example:

    import fl.text.TLFTextField;importflash.text.TextFieldAutoSize;

    ar tlfTxt:TLFTextField = new TLFTextField();tlfTxt.border = true;tlfTxt.text = "The quick brown fox jumps over the lazy dog.";tlfTxt.wordWrap = true;tlfTxt.autoSize = TextFieldAutoSize.LEFT;tlfTxt.x = tlfTxt.y = 40;

    tlfTxt.rotation = 15;addChild(tlfTxt);

    Unlike the TextField class which only supports setting text rotation on a TextField with an embedded font, the TLFTextField

    class supports setting text retotation on device (non-embedded) fonts.

    10. Similar to setting the htmlText property, setting the tlfMarkup allows you to set rich text formatting on the TLFTextField

    instance, as seen in the following example:

    import fl.text.TLFTextField;

  • 7/27/2019 Flash Action 3

    7/26

    importflash.text.TextFieldAutoSize;

    ar tFlow:String = "

    The quick brown fox jumps over the lazy dog.

    ar tlfTxt:TLFTextField = new TLFTextField();tlfTxt.border = true;tlfTxt.tlfMarkup = tFlow;tlfTxt.autoSize = TextFieldAutoSize.LEFT;tlfTxt.x = tlfTxt.y = 40;addChild(tlfTxt);

    Or, if you want to apply some more complex formatting (such as hyperlinks, bold, italics, superscript/subscript, or strike through

    text, you can use a more complex TextFlow string object, as seen in the following example:

    import fl.text.TLFTextField;importflash.text.TextFieldAutoSize;importflash.events.Event;

    ar tFlow:String = "

    The over the lazy

  • 7/27/2019 Flash Action 3

    8/26

    href='http://actionscriptexamples.com/'>lazy dog.

    - See more at:http://flashthusiast.com/2010/05/05/getting-started-with-the-tlftextfield-class-in-actionscript-3-0-and-

    flash-cs5/#sthash.vANVSBmH.dpuf

    http://flashthusiast.com/2010/05/05/getting-started-with-the-tlftextfield-class-in-actionscript-3-0-and-flash-cs5/#sthash.vANVSBmH.dpufhttp://flashthusiast.com/2010/05/05/getting-started-with-the-tlftextfield-class-in-actionscript-3-0-and-flash-cs5/#sthash.vANVSBmH.dpufhttp://flashthusiast.com/2010/05/05/getting-started-with-the-tlftextfield-class-in-actionscript-3-0-and-flash-cs5/#sthash.vANVSBmH.dpufhttp://flashthusiast.com/2010/05/05/getting-started-with-the-tlftextfield-class-in-actionscript-3-0-and-flash-cs5/#sthash.vANVSBmH.dpufhttp://flashthusiast.com/2010/05/05/getting-started-with-the-tlftextfield-class-in-actionscript-3-0-and-flash-cs5/#sthash.vANVSBmH.dpufhttp://flashthusiast.com/2010/05/05/getting-started-with-the-tlftextfield-class-in-actionscript-3-0-and-flash-cs5/#sthash.vANVSBmH.dpuf
  • 7/27/2019 Flash Action 3

    9/26

    LOADING AND DISPLAYING VIDEO IN FLASH CS3USING ACTIONSCRIPT 3.0, NO MORE VIDEOOBJECTS

    2 Mar, 2008ActionScript 2.0ActionScript 3.0Flash CS3FLVMigrationVideoJen deHaanPermalink

    A pretty common thing to do with Flash is to play an FLV file. In ActionScript 2.0, you would do the following:

    1. Create a new Video object in your Library (choose New Video from the Librarys Options menu).

    2. Drag the video onto the Stage, and give it an instance name.

    3. Add the following code to frame 1 of your document:

    / ActionScript 2.0ar nc:NetConnection = newNetConnection();nc.connect(null);ar ns:NetStream = newNetStream(nc);

    ns.onMetaData = function(item:Object):Void {trace("metaData");

    // Resize video instance.myVideo._width = item.width;myVideo._height = item.height;

    // Center video instance on Stage.myVideo._x = (Stage.width-myVideo._width)/2;myVideo._y = (Stage.height-myVideo._height)/2;

    };

    ns.onCuePoint = function(item:Object):Void {trace("cuePoint");trace(item.name+"\t"+item.time);

    };

    myVideo.attachVideo(ns);ns.play("http://www.helpexamples.com/flash/video/cuepoints.flv");

    That will play your video and also trace a couple cuepoints. Sample file:Load video with ActionScript 2.0

    Its kind of cool in ActionScript 3.0 in that you can open an empty AS3 FLA file, paste this code onto frame 1 of your

    document, and youre off to the races (meaning, thats all you have to do). As you can see, the code isnt that much

    different either so if you added video in AS2, things should seem pretty familiar. This is the same thing as above

    it will also play a video and trace some cuepoints.

    / ActionScript 3.0

    arvideo:Video = newVideo();addChild(video);

    ar nc:NetConnection = newNetConnection();nc.connect(null);

    ar ns:NetStream = newNetStream(nc);ns.client = {onMetaData:ns_onMetaData, onCuePoint:ns_onCuePoint};

    video.attachNetStream(ns);

    http://flashthusiast.com/category/actionscript-20/http://flashthusiast.com/category/actionscript-20/http://flashthusiast.com/category/actionscript-30/http://flashthusiast.com/category/actionscript-30/http://flashthusiast.com/category/flash-cs3/http://flashthusiast.com/category/flash-cs3/http://flashthusiast.com/category/flv/http://flashthusiast.com/category/flv/http://flashthusiast.com/category/migration/http://flashthusiast.com/category/migration/http://flashthusiast.com/category/video/http://flashthusiast.com/category/video/http://flashthusiast.com/author/admin/http://flashthusiast.com/author/admin/http://flashthusiast.com/2008/03/02/loading-and-displaying-video-in-actionscript-30-no-more-video-objects/http://flashthusiast.com/2008/03/02/loading-and-displaying-video-in-actionscript-30-no-more-video-objects/http://flashthusiast.com/2008/03/02/loading-and-displaying-video-in-actionscript-30-no-more-video-objects/http://flashthusiast.com/wp-content/uploads/2008/03/loadvideo-as2.flahttp://flashthusiast.com/wp-content/uploads/2008/03/loadvideo-as2.flahttp://flashthusiast.com/wp-content/uploads/2008/03/loadvideo-as2.flahttp://flashthusiast.com/wp-content/uploads/2008/03/loadvideo-as2.flahttp://flashthusiast.com/2008/03/02/loading-and-displaying-video-in-actionscript-30-no-more-video-objects/http://flashthusiast.com/author/admin/http://flashthusiast.com/category/video/http://flashthusiast.com/category/migration/http://flashthusiast.com/category/flv/http://flashthusiast.com/category/flash-cs3/http://flashthusiast.com/category/actionscript-30/http://flashthusiast.com/category/actionscript-20/
  • 7/27/2019 Flash Action 3

    10/26

    ns.play("http://www.helpexamples.com/flash/video/cuepoints.flv");

    function ns_onMetaData(item:Object):void{trace("metaData");

    // Resize video instance.video.width = item.width;video.height = item.height;

    // Center video instance on Stage.video.x = (stage.stageWidth - video.width)/2;video.y = (stage.stageHeight - video.height)/2;

    }

    function ns_onCuePoint(item:Object):void{trace("cuePoint");trace(item.name + "\t" + item.time);

    }

    - See more at:http://flashthusiast.com/2008/03/02/loading-and-displaying-video-in-actionscript-30-no-more-video-

    objects/#sthash.X3qLqUNu.dpuf

    http://flashthusiast.com/2008/03/02/loading-and-displaying-video-in-actionscript-30-no-more-video-objects/#sthash.X3qLqUNu.dpufhttp://flashthusiast.com/2008/03/02/loading-and-displaying-video-in-actionscript-30-no-more-video-objects/#sthash.X3qLqUNu.dpufhttp://flashthusiast.com/2008/03/02/loading-and-displaying-video-in-actionscript-30-no-more-video-objects/#sthash.X3qLqUNu.dpufhttp://flashthusiast.com/2008/03/02/loading-and-displaying-video-in-actionscript-30-no-more-video-objects/#sthash.X3qLqUNu.dpufhttp://flashthusiast.com/2008/03/02/loading-and-displaying-video-in-actionscript-30-no-more-video-objects/#sthash.X3qLqUNu.dpufhttp://flashthusiast.com/2008/03/02/loading-and-displaying-video-in-actionscript-30-no-more-video-objects/#sthash.X3qLqUNu.dpuf
  • 7/27/2019 Flash Action 3

    11/26

    Building Flash forms

    Adding text, images, rules, and space with the cfformitem tag

    Using the cfformgroup tag to structure forms

    Controlling sizes in Flash forms

    Determine the sizes of a Flash form and its controls

    Repeating Flash form elements based on query data

    Creating complex forms with accordion and tab navigator containers

    You build Flash forms using standard ColdFusion form tags, plus the cfformgroup and cfformitem tags.

    These tags create the elements of the form, as follows:

    The cfcalendar, cfgrid, cfinput, cfselect, cftextarea, and cftree tags create controls for data

    display and user input.

    The cfformitem tag lets you add formatted or unformatted text, spacers, and horizontal and vertical

    rules without using HTML.

    The cfformgroup tag creates containers, such as horizontally aligned boxes or tabbed navigators,

    that let you group, organize, and structure the form contents.

    Flash forms follow a hierarchical structure of containers and children.

    1. The cfform tag is the master container, and its contents are child containers and controls.

    2. The cfformgroup tag defines a container that organizes its child elements.

    3. All other tags create individual controls, including display elements such as rules.

    For example, the image in theAbout Flash formssection has the following hierarchical structure of

    containers and children. (This outline only shows the structure of the page that is visible in the

    image. It omits the structure of the Preferences tab.)

    1 cfform

    2 cfformgroup type="tabnavigator" -- Tab navigator container

    3 cfformgroup type="page" -- Tabbed page container, child of

    tabnavigator

    4 cfformgroup type="horizontal" -- Aligns its two children

    horizontally

    5 cfinput type="text" -- First name input control

    5 cfinput type="spacer" -- Space between the name input

    controls

    5 cfinput type="text" -- Last name input control

    4 cfformitem type="hrule" -- Displays a rule

    4 cfformitem type="html" -- Displays formatted text

    4 cffinput type="text" -- E-mail input control

    4 cfformitem type="hrule" -- Displays a rule

    4 cfinput type="text" -- Phone number input control

    4 cfinput type="spacer" -- Space between the phone and date

    http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff4.html#WSc3ff6d0ea77859461172e0811cbec22c24-730chttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff4.html#WSc3ff6d0ea77859461172e0811cbec22c24-730chttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff4.html#WSc3ff6d0ea77859461172e0811cbec22c24-730bhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff4.html#WSc3ff6d0ea77859461172e0811cbec22c24-730bhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff4.html#WSc3ff6d0ea77859461172e0811cbec10372-7ff1http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff4.html#WSc3ff6d0ea77859461172e0811cbec10372-7ff1http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff4.html#WSf01dbd23413dda0e7d2c7fb11200fc8d95f-8000http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff4.html#WSf01dbd23413dda0e7d2c7fb11200fc8d95f-8000http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff4.html#WSc3ff6d0ea77859461172e0811cbec10372-7ff3http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff4.html#WSc3ff6d0ea77859461172e0811cbec10372-7ff3http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff4.html#WSc3ff6d0ea77859461172e0811cbec22c24-7a39http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff4.html#WSc3ff6d0ea77859461172e0811cbec22c24-7a39http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a41.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a41.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a41.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a41.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff4.html#WSc3ff6d0ea77859461172e0811cbec22c24-7a39http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff4.html#WSc3ff6d0ea77859461172e0811cbec10372-7ff3http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff4.html#WSf01dbd23413dda0e7d2c7fb11200fc8d95f-8000http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff4.html#WSc3ff6d0ea77859461172e0811cbec10372-7ff1http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff4.html#WSc3ff6d0ea77859461172e0811cbec22c24-730bhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff4.html#WSc3ff6d0ea77859461172e0811cbec22c24-730c
  • 7/27/2019 Flash Action 3

    12/26

    controls

    4 cfinput type="datefield" -- Date input control

    3 cfinput type="page" -- Second tabbed page container for preferences

    .

    .

    2 cfformgroup type="horizontal" -- Follows the tabnavigator in the form

    3 cfinput type="submit" -- Submit button control

    3 cfinput type="reset" -- Reset button control

    Adding text, images, rules, and space with the cfformitem tag

    Because Flash forms do not support inline HTML, you use the cfformitem tag to add text blocks and

    horizontal and vertical rules to your form. (Flash form controls, such as cfinput, use

    the label or value attribute to specify text labels.) You can also use the cfformitem tag to add spacers

    between visual form elements.

    The cfformitem type="hrule" and cfformitem type="vrule" tags put horizontal and vertical rules in the

    form. You can specify the rule thickness, color, and shadow characteristics by using style specifications. For

    more information on specifying rule styles, seeStyles for cfformitem with hrule or vrule type

    attributesinColdFusion Flash Form Style Referencein the CFML Reference.

    The cfformitem type="spacer" tag puts a blank space of the specified height and width on the form. This

    tag type does not use styles; it can be useful in improving the form appearance by helping you control the

    form layout.

    The cfformitem type="text" tag lets you insert plain text in the form You can use the style attribute to

    apply a consistent format to the text.

    The cfformitem type="html" tag lets you insert formatted text and images in the form. You can include

    basic HTML-style formatting tags in the body of this tag to add images and to format and style the text.

    You can use the following formatting tags and attributes in the body of a cfformitem type="html" tag:

    Tag Valid attributes

    a href URL to link to.

    target window name; can be a standard HTML window name such as _blank.

    b None.

    br None.

    font color Must be in hexadecimal format, such as #FF00AA. Use a single number sign (#) character.

    faceC an be a comma-delimited list of font face names; Flash uses the first font that is available on the client

    system.

    size In pixels; + and -relative values are allowed.

    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7a42.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7a42.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7a42.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7a42.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7a3f.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7a3f.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7a3f.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7a3f.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7a42.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7a42.html
  • 7/27/2019 Flash Action 3

    13/26

    i None.

    img See the attribute table for the img tag.

    Note: Close this tag with /> or an tag.

    li None.

    p align Must be one of the following: left, right, center.

    textformat See the attribute table for the textformat tag.

    u None.

    The img tag supports the following attributes:

    Attribute Description

    src

    (Required) URL or path to a JPEG or SWF file. Images are not displayed until they have downloaded completely.Flash Player does not support progressive JPEG files.

    width Width of the image, in pixels.

    height Height of the image in pixels.

    align Horizontal alignment of the embedded image within the text field. Valid values are left and right. The default

    value is left.

    hspace Number of pixels of horizontal space that surround the image where no text appears. The default value is 8.

    vspace Number of pixels of vertical space that surround the image where no text appears. The default value is 8.

    Note: Because of the Flash dynamic sizing rules, to ensure that the image displays properly, you sometimes

    have to specify the formitem tag height attribute and the width andheight attributes for the form or the

    containing cfformgroup tag. Also, the image always displays on a new line, not inline with text, and text

    that follows the image in your code occupies any available space to the right of the image.

    The textformat tag is specific to Flash, and has the following attributes:

    Attribute Description

    blockindent Block indentation, in points.

    indent Indentation from the left margin to the first character in the paragraph.

    leading Amount of leading (vertical space) between lines.

    leftmargin Left margin of the paragraph, in points.

    rightmargin Right margin of the paragraph, in points.

    tabstops Custom tab stops as an array of nonnegative integers. To specify tabs in text, use the \t escape character.

  • 7/27/2019 Flash Action 3

    14/26

    For detailed descriptions of these tags, see the Flash documentation.

    The following code creates a simple Flash form that consists of a formatted text area surrounded by

    horizontal rules:

    Flash form with formatted text and rules

    This form has formatted text, including:

    colored text

    italic and bold text

    a bulleted list in an indented block

    The text is preceded and followed by horizontal rules

    It also has a link to a web page.

    This link displays the Adobe home page in a new browser window

  • 7/27/2019 Flash Action 3

    15/26

    Using the cfformgroup tag to structure forms

    ColdFusion provides form group container types that provide basic structure to a Flash form. You specify

    these types in the type attribute of thecfformgrouptag. Use the following container types to control the

    layout of controls and groups of controls:

    Type Description

    horizontal Arranges individual controls horizontally, and optionally applies a label to the left of the controls. Use only for

    arranging ColdFusion form controls, including cfformitem controls. As a general rule, do not use to

    organize cfformgroup containers; use the hboxattribute instead.

    If you put othercfformgroup tags inside a horizontal form group, the controls inside the

    included cfformgroup tag do not align with other controls in the horizontal group.

    vertical Arranges individual controls vertically, and optionally applies a label to the left (nottop) of the controls. Use

    only for groups of ColdFusion form controls, including cfformitem controls. As a general rule, do not use

    to organize cfformgroup containers; use thevbox attribute instead.

    If you put othercfformgroup tags inside a vertical form group, the controls inside the

    included cfformgroup tag do not align with other controls in the vertical group.

    hbox Arranges groups of controls horizontally. Does not apply a label. Use this attribute value to arrange

    othercfformgroup containers. This tag does not enforce alignment of child controls that have labels, so

    you should not use it to align individual controls.

    vbox Arranges groups of controls vertically. Does not apply a label. Use this attribute value to arrange

    othercfformgroup containers. This tag does not enforce alignment of child controls that have labels, so do

    not use it to align individual controls.

    hdividedbox Arranges two or more children horizontally, and places divider handles between the children that users can

    drag to change the relative sizes of the children. Does not apply a label. The direct children of

    an hdividedbox container must be cfformgroup tags withtype attributes other

    than horizontal orvertical.

    vdividedbox Arranges two or more children vertically, and places divider handles between the children that users can drag

    to change the relative sizes of the children. Does not apply a label. The direct children of

    a vdividedbox container must be cfformgroup tags with typeattributes other

    than horizontal orvertical.

    tile Arranges its children in a rectangular grid in row-first order. Does not apply a label.

    panel Consists of a title bar containing the label attribute text, a border, and a content area with vertically arranged

    children.

    accordion Places each of its child pages in an accordion pleat with a label bar. Displays the contents of one pleat at a

    time. Users click the labels to expand or contract the pleat pages. Does not apply a label.

    tabnavigator Places each of its children on a tabbed page. Users click the tabs to display a selected page. Does not apply a

    label.

    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7a48.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7a48.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7a48.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7a48.html
  • 7/27/2019 Flash Action 3

    16/26

    page The immediate child of an accordion or tab navigator container. Specifies the label on the pleat bar or tab, and

    arranges its child containers and controls vertically.

    For more information on using the accordion, tabnavigator, and pagecfformgroup types, seeCreating

    complex forms with accordion and tab navigator containers.

    Example: structuring with the cfformgroup tagThe following example shows a form with an hdividedbox container with two vbox containers. The left box

    uses a horizontal container to arrange two radio buttons. The right box uses a tile container to lay out

    its check boxes. You can drag the divider handle to resize the two boxes. When you submit the form, the

    ColdFusion page dumps the Form scope to show the submitted data.



    Tell us your preferences

    Pets:

    http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a39.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a39.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a39.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a39.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a39.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a39.html
  • 7/27/2019 Flash Action 3

    17/26

    Fruits:

    Controlling sizes in Flash forms

    Sizing elements in a Flash form is something of an art, rather than a science. As a general rule, if you dont

    specify the height and width attributes, Flash tends to do a good job of laying out the form. However, keep

    in mind the following considerations:

  • 7/27/2019 Flash Action 3

    18/26

    If you do not specify the height and width attributes in thecfformtag, Flash reserves the full

    dimensions of the visible browser window, if the form is not in a table, or the table cell, if the form is

    in a table, even if they are not required for the form contents. Any HTML output that precedes or

    follows the form causes the output page to exceed the size of the browser window.

    If you do not specify the height or width of a control, including a form group, Flash adjusts the

    dimensions, trying to fit the controls in the available space. For example, Flash often extends input

    boxes to the width of the containing control, if not otherwise specified.

    In general, it is best to use the following process when you design your Flash form.

    Determine the sizes of a Flash form and its controls

    1. When you first create the form, dont specify anyheight and width attributes on the form or its child

    tags. Run the form and examine the results to determine height and width values to use.

    2. Specify height and width attributes in the cfform tag for the desired dimensions of the form. You

    can specify absolute pixel values, or percentage values relative to the size of the containing window.

    3. Specify any height or width attributes on individual tags. These values must be in pixels.

    4. Repeat step 3 for various tags, and possibly step 2, until your form has a pleasing appearance.

    Repeating Flash form elements based on query data

    The repeatercfformgroup type tells Flash Player to iterate over a query and create a set of

    the cfformgrouptags child controls for each row in the query. For each set of child

    controls, bind attributes in the child tags can access fields in the current query row. This cfformgrouptype

    lets you create Flash forms where the number of controls can change based on a query, without requiring

    ColdFusion to recompile the Flash SWF file for the form. This significantly enhances server performance.

    Note: For more information on binding data, seeBinding data in Flash forms.

    Optionally, you can specify a start row and a maximum number of rows to use in the repeater. Unlike most

    ColdFusion tags, repeater index values start at 0, not 1. To specify a repeater that starts on the first line of

    the query object and uses no more than 15 rows, use a tag such as the following:

    One example that can use a repeater is a form that lets a teacher select a specific class and update the

    student grades. Each class can have a different number of students, so the form must have a varying

    number of input lines. Another example is a shopping cart application that displays the product name and

    quantity ordered and lets users change the quantity.

    The following example uses the cfformgroup tag with a repeatertype attribute value to populate a form. It

    creates a query, and uses the repeater to iterate over a query and create a firstname and lastname input

    box for each row in the query.



    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7fb7.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7fb7.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7fb7.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a46.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a46.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a46.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a46.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7fb7.html
  • 7/27/2019 Flash Action 3

    19/26

    q1 = queryNew("id,firstname,lastname");

    queryAddRow(q1);

    querySetCell(q1, "id", "1");

    querySetCell(q1, "firstname", "Rob");

    querySetCell(q1, "lastname", "Smith");

    queryAddRow(q1);

    querySetCell(q1, "id", "2");

    querySetCell(q1, "firstname", "John");

    querySetCell(q1, "lastname", "Doe");

    queryAddRow(q1);

    querySetCell(q1, "id", "3");

    querySetCell(q1, "firstname", "Jane");

    querySetCell(q1, "lastname", "Doe");

    queryAddRow(q1);

    querySetCell(q1, "id", "4");

    querySetCell(q1, "firstname", "Erik");

    querySetCell(q1, "lastname", "Pramenter");

  • 7/27/2019 Flash Action 3

    20/26

    Creating complex forms with accordion and tab navigator containers

    The accordion and tabnavigator attributes of the cfformgroup tag let you construct complex forms that

    would otherwise require multiple HTML pages. With accordions and tab navigator containers, users can

    switch among multiple entry areas without submitting intermediate forms. All data that they enter is

    available until they submit the form, and all form elements load at one time.

    An accordion container places each logical form page on an accordion pleat. Each pleat has a label bar;

    when the user clicks a bar, the current page collapses and the selected page expands to fill the available

    form space. The following image shows a three-pleat accordion, open to the middle pleat, Preferences:

    A tab navigator container places each logical form page on a tabbed frame. When the user clicks a tab, the

    selected page replaces the previous page. The image inAbout Flash formsshows a tab navigator container.

    The following example generates a two-tab navigator container that gets contact information and

    preferences. You can change it to an accordion container by changing the type attribute of the

    first cfformgroup tag from tabnavigator to accordion. To prevent the accordion from having scroll bars,

    increase the cfform tag height attribute to 310 and the tabnavigator tag height attribute to 260.




    http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a41.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a41.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a41.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a41.html
  • 7/27/2019 Flash Action 3

    21/26

    Flash fills this field in automatically.

    You can replace the text.

    Tell us your preferences

  • 7/27/2019 Flash Action 3

    22/26

    Pets:

    Fruits:

  • 7/27/2019 Flash Action 3

    23/26

    Using ActionScript in Flash forms

    Using ActionScript code in CFML

    Custom ActionScript functions

    ActionScript 2.0 is a powerful scripting language that is used in Flash and other related products and is like

    JavaScript. You can use a subset of ActionScript 2.0 code in your Flash forms.

    Information on how to include ActionScript in your Flash forms, and restrictions and additions to

    ActionScript that apply to ColdFusion Flash forms are described here. However, information on writing

    ActionScript is not provided. For details on ActionScript and how you can use it, see the Flash ActionScript2.0 documentation, including the documents available in the Flash and Flex sections of LiveDocs

    atwww.adobe.com/go/learn_cfu_docs_en.

    Using ActionScript code in CFML

    You can use ActionScript in the following attribute of tags in CFML Flash format forms:

    Form and control events, such as the onSubmit attribute of the cfform tag, or

    the onChange and onClick attributes of the cfinput tag. The attribute description on the tag

    reference pages in the CFML Reference list the event attributes.

    Bind expressions, which you can use to set field values. For more information on binding data,

    seeBinding data in Flash forms.Your ActionScript code can be inline in the form attribute specification, you can make a call to a

    custom function that you define, or you can use the ActionScript include command in the attribute

    specification to get the ActionScript from a .as file.

    The following example shows a simple Fahrenheit to Celsius converter that does the conversion

    directly on the client, without requiring the user to submit a form to the ColdFusion server.

    http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff0.html#WSc3ff6d0ea77859461172e0811cbec10372-7fe5http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff0.html#WSc3ff6d0ea77859461172e0811cbec10372-7fe5http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff0.html#WSc3ff6d0ea77859461172e0811cbec10372-7fe4http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff0.html#WSc3ff6d0ea77859461172e0811cbec10372-7fe4http://www.adobe.com/go/learn_cfu_docs_enhttp://www.adobe.com/go/learn_cfu_docs_enhttp://www.adobe.com/go/learn_cfu_docs_enhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a46.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a46.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a46.htmlhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a46.htmlhttp://www.adobe.com/go/learn_cfu_docs_enhttp://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff0.html#WSc3ff6d0ea77859461172e0811cbec10372-7fe4http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec10372-7ff0.html#WSc3ff6d0ea77859461172e0811cbec10372-7fe5
  • 7/27/2019 Flash Action 3

    24/26

    Note: You do not use the text property (for example, fieldname.text) to access hidden fields. To

    access a hidden field, use the formatformname.fieldname = 'value'.

    Custom ActionScript functions

    Custom ActionScript functions are the equivalent of CFML UDFs. You can define your own functions in

    ColdFusion by using the cfformitem tag with a type attribute value ofscript, or you can define the

    functions in an ActionScript (.as) file. Also, ColdFusion includes a small number of predefined custom

    ActionScript functions that you can use in your Flash form controls.

    You can use the following custom functions in the ActionScript for all form controls to reset or submit the

    form:

    resetForm()

    submitForm()

    You can use the following custom functions in cfgrid tags only to insert and delete rows in the grid:

    GridData.insertRow(gridName)

    GridData.deleteRow(gridName)

    The following example shows how you can use the two GridData functions to add custom buttons that add

    and delete rows from a Flash form. These buttons are equivalent to the buttons that ColdFusion creates ifyou specify insert="yes" and delete="yes" in the cfgrid tag, but they allow you to specify you own

    button text and placement. This example puts the buttons on the side of the grid, instead of below it and

    uses longer than standard button labels.

    You can edit this grid as follows:

    To change an item, click the field and type.

    To add a row, click the Insert Row button and type in the fields

    in the highlighted row.

    To delete a row, click anywhere in the row and click the

    Delete Row button

  • 7/27/2019 Flash Action 3

    25/26

    When you are done, click the submit button.

  • 7/27/2019 Flash Action 3

    26/26