AddChild Button

This is probably something very simple but I can't find anything on it.  So I would appreciate any insight you may have.
It's a very simple program that is dynamically creating buttons at runtime based on XML data which will eventually get served by a database query.
Problem:  I can't seem to add a newButton.click = clickHandler() type function through the process of addChild.  Any suggestions?
<mx:Script>
<![CDATA[
import mx.controls.Alert; 
import mx.controls.Button; 
 [Bindable]
var buttons:XML =<Buttons>
<Button label="Yes" link="http://papajohns.com"/>
<Button label="No" link="http://google.com"/>
</Buttons>
private function makeButtons():void { 
for each ( var button : XML in buttons.Button ){
var newButton:Button = new Button();  
//Modify Properties
newButton.label = button.@label;
//Add the new button to the stage (Screen)
this.buttonsBox.addChild(newButton); 
]]>
</mx:Script>

I found Repeater accomplished what I was intending to do.
<mx:Repeater id="myrep" dataProvider="{buttons.Button}">
    <mx:Button label={myrep.currentItem.@label} click="clickHandler({myrep.currentItem.@link})"/>
</mx:Repeater>
It was something like that.  I'll add the code tomorrow when I get back to the office.
Thanks for your reply!

Similar Messages

  • Problems using addchild method to dynamically load buttons

    Hello,
    I have researched the internet for about a week now losing sleep trying to figure this out.  Can someone help me?  I have an fla file with Quiz question.  For example:
    on frame 50 I have images and radio buttons, a submit button with an instance name of submit_btn with the question The first capital of the United States
    was New York City as a static text.  The action for this frame is:
    stop();
    import fl.controls.RadioButtonGroup;
    var radioGroup1:RadioButtonGroup = new RadioButtonGroup("TriviaQuestion 1");
    rb3.textField.autoSize = TextFieldAutoSize.LEFT;
    rb1.label="True";
    rb2.label="False";
    rb3.label="NY is not in the US";
    rb4.label="NY is a City";
    rb1.group=radioGroup1;
    rb2.group=radioGroup1;
    rb3.group=radioGroup1;
    rb4.group=radioGroup1;
    submit_btn.addEventListener(MouseEvent.CLICK, submitClick);
    function submitClick(event:MouseEvent):void {
    if(radioGroup1.selection == null) {
    return;
    if(radioGroup1.selection.label == "True") {
    status_txt.text=radioGroup1.selection.label+ " is correct! Well done.  The first capital of the United States was New York City in 1789.";
    }else {status_txt.text=radioGroup1.selection.label+ " is incorrect! Try Again.";
    next_btn.addEventListener(MouseEvent.CLICK, nextOnClick);
    function nextOnClick(event:MouseEvent):void
    gotoAndPlay(55);
    Now my movie works fine this way.  What I want to do is practice adding the navigations (prevButton, nextButton and finishButton) with the addchild button in an AS file (linking it in the document properties).  I have done this if I add the questions as well but a little confused on how to make the navigation work if the questions are already on a time line.  So far this is what my ClassButton.as file looks like  (can't figure out how to import the questions);  If I get the prevhandler correct, the rest will be easy.
    package
    import flash.display.MovieClip;
    //import flash.display.Sprite;  <<fla file went crazy when I used Sprite verses MovieClip
    import fl.controls.Button;
    import flash.events.MouseEvent;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import fl.controls.RadioButtonGroup;
    public class ClassButton extends MovieClip {
    //handling questions: --this is the big problem..don't know how to import RadioButtonGroups
    private var quizQuestions:RadioButtonGroup;
    //private var currentQuestion:QuizQuestions;
    //private var radioGroup:RadioButtonGroup;
    private var currentIndex:int = 0;
    //buttons:
    private var prevButton:Button;
    private var nextButton:Button;
    private var finishButton:Button;
    //scoring and messages:
    private var score:int = 0;
    private var status:TextField;
    public function ClassButton() {
    createButtons();
    //createQuestions();
    /* little confused on what function to create to add questions
    private function createQuestions() {
    radioGroup = new RadioButtonGroup;
    //create previous, next and finish button
    private function createButtons() {
    var yPosition:Number = 505;
    prevButton = new Button();
    prevButton.label = "Previous";
    prevButton.x = 50.35;
    prevButton.y = yPosition;
    prevButton.addEventListener(MouseEvent.CLICK, prevHandler);
    addChild(prevButton);
    nextButton = new Button();
    nextButton.label = "Next";
    nextButton.x = prevButton.x + prevButton.width + 40;
    nextButton.y = yPosition;
    //nextButton.addEventListener(MouseEvent.CLICK, nextHandler);
    addChild(nextButton);
    finishButton = new Button();
    finishButton.label = "Finish";
    finishButton.x = nextButton.x + nextButton.width + 40;
    finishButton.y = yPosition;
    //finishButton.addEventListener(MouseEvent.CLICK, finishHandler);
    addChild(finishButton);
    private function showMessage(theMessage:String) {
    status.text = theMessage;
    status.x = finishButton.x + finishButton.width + 40;
    status.y = 505;
    /* blocked this out because it's incorrect.  the problem is the property (currentQuestion and quizQuestion)
    private function prevHandler(event:MouseEvent) {
    showMessage("");
    if(currentIndex > 0) {
    currentQuestion.visible = false;
    currentIndex--;
    currentQuestion = quizQuestions[currentIndex];
    currentQuestion.visible = true;
    else {
    showMessage("There are no previous quesions. This is the first question.");
    How do I make these buttons - next, prev and finish -  work for the questions using the addchild method in a separate AS file linked to the FLA file?  Is there a way to import the RadioButtons?  Is this possible.

    Check out this Nugget.
    It contains code that should help you get started.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How to dynamically add button to a movie/stage?

    I am using Flex Developer and I am designing a Flash Lite app
    which uses AS2. However I cant find anyway of adding a control such
    as a button to the stage from code. Do I need to buy a tool to do
    that or can I add controls/containers from code?
    E.g. in AS3 you create the button object then do an
    addChild(button) and it adds.
    Any sample docs apprecietd..

    You would create a movie clip button and from your library
    make sure the linkage identifier is set then call a function in
    your action script to attach the button(s) to the stage, the code
    should look something like such:

  • Anchor a button upper right in a panel?

    Have to anchor a button upper right in a panel.  Need it to stay anchored even when I use resize and move effects on the panel.  Want the button up top, not in the panel's content pane.
    The only way I know to get a button up there is to put it in the panel's titleBar.  If I want it to be anchored I'll have to put it in a container that supports constraints, like a Canvas, before putting it in the titleBar.  When I do this, constraints seem to go out the window.  They work somewhat but behave abnormally. 
    Here's a sample app (2 files) implementing this approach.  Compile and click the button down below.  The large panel with the button in its titleBar is supposed to shrink and hide behind the little video window.  It does, but the button in its titleBar doesn't go along for the ride.  It's not constrained.  Is there another approach to this?
    Main app file (constraints.mxml) followed by custom panel file (CustomPanel.mxml)...
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        xmlns:custom="*"
        layout="absolute"
        initialize="init()">
        <mx:Script>
            <![CDATA[       
                [Bindable]
                private var vidX:Number;
                [Bindable]
                private var vidY:Number;
                [Bindable]
                private var vidW:Number;
                [Bindable]
                private var vidH:Number;
                [Bindable]
                private var panelX:Number;
                [Bindable]
                private var panelY:Number;
                [Bindable]
                private var panelW:Number
                [Bindable]
                private var panelH:Number;
                private var open:Boolean = true;
                public function init():void
                    vidX = 20;
                    vidY = 20;
                    vidW = 180;
                    vidH = 120;
                    panelX = 202;
                    panelY = 20;
                    panelW = 500;
                    panelH = 350;               
                private function onButtonClick(e:MouseEvent):void
                    if(open)
                        inAndDownSize.play();
                        open = false;
                    else
                        outAndUpSize.play();
                        open = true;
            ]]>
        </mx:Script>
        <!--  Effects -->
        <mx:Parallel id="outAndUpSize"
            duration="200">
            <mx:Move
                target="{panel}"
                xFrom="{vidX}" xTo="{panelX}"/>
            <mx:Resize
                target="{panel}"
                widthTo="{panelW}" heightTo="{panelH}"/>   
        </mx:Parallel>
        <mx:Parallel id="inAndDownSize">
            <mx:Move
                target="{panel}"
                xFrom="{panelX}" xTo="{vidX}"/>
            <mx:Resize
                target="{panel}"
                widthTo="{vid.width}" heightTo="{vid.height}"/>
        </mx:Parallel>
        <!--UI elements -->
        <custom:CustomPanel id="panel"
            x="{panelX}" y="{panelY}"
            width="{panelW}" height="{panelH}"
            layout="absolute">
        </custom:CustomPanel>   
        <mx:VideoDisplay id="vid"
            x="{vidX}" y="{vidY}"
            width="{vidW}" height="{vidH}"/>
        <mx:Button
            label="Click"
            horizontalCenter="0"
            bottom="10"
            click="onButtonClick(event)"/>
    </mx:Application>
    CustomPanel.mxml...
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="absolute"
        initialize="init()"
        creationComplete="onCreationComplete()">   
        <mx:Script>
            <![CDATA[
                import mx.containers.Canvas;
                import mx.controls.Button;       
                private var button:Button = new Button();
                private var canvas:Canvas = new Canvas();
                private var style:CSSStyleDeclaration = new CSSStyleDeclaration();   
                private function onCreationComplete():void
                    canvas.width = parent.width;
                    canvas.height = parent.height;               
                    style.setStyle("left", 400);
                    button.id = "button";
                    button.label = "b";
                    button.width = 30;
                    button.height = 30;               
                    button.styleDeclaration = style;
                    canvas.addChild(button);
                    this.titleBar.addChild(canvas);
            ]]>
        </mx:Script>   
    </mx:Panel>

    Hi,
    There is not need to use Canvas to position it. override the updateDisplayList method and move the button. Check the code below.
    <mx:Script>
            <![CDATA[
                import mx.controls.Button;
                private var button:Button;
                private var style:CSSStyleDeclaration = new CSSStyleDeclaration();  
                   override protected function createChildren():void
                       super.createChildren();
                       button = new Button();
                       button.label = "b";
                    button.styleDeclaration = style;
                    titleBar.addChild(button);
                override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
                    super.updateDisplayList(unscaledWidth,unscaledHeight);
                    button.width = 30;
                    button.height = 30;
                    //move button to the top right
                    button.move(width - button.width - 5, 5);
            ]]>
        </mx:Script>

  • How do I create a button in AS3?

    Hello Everyone
    How do I create a button in action script 3 and handle the click event?
    Thanks

    Maybe this will help you get started.
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.display.Graphics;
    var button:Sprite = new Sprite();  //Sprite to act as the button graphic.
    //Set the color of the button graphic
    button.graphics.beginFill(0xFFCC00);
    //Set the X,Y, Width, and Height of the button graphic
    button.graphics.drawRect(10, 10, 200, 60);
    button.graphics.endFill(); //Apply the fill
    this.addChild(button);  //Add Button Sprite to stage
    button.useHandCursor = true;
    button.buttonMode = true;
    button.mouseChildren = false;
    button.addEventListener(MouseEvent.CLICK, buttonClickHandler);
    function buttonClickHandler(event:MouseEvent):void
               trace("Button clicked!");

  • Controlling sound file with play, stop and mute button in AS3.0?

    the method for stopping/playing sound in 2.0 don't work for 3.0.  i can stop the sound by going to a different page/frame on the site.  but i want the buttons. 
    1. play button?
    2.stop button?
    3.mute button?
    thanks in advance!

    for pause (example 2) :
    for volume -mute (example 1) :
    package
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.*;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.media.SoundTransform;
    import flash.net.URLRequest;
    import flash.utils.Timer;
    public class SoundTransformExample extends Sprite
      private var url:String = "MySound.mp3";
      private var soundFactory:Sound;
      private var channel:SoundChannel;
      private var positionTimer:Timer;
      public function SoundTransformExample()
       stage.align = StageAlign.TOP_LEFT;
       stage.scaleMode = StageScaleMode.NO_SCALE;
       var request:URLRequest = new URLRequest(url);
       soundFactory = new Sound();
       soundFactory.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
       soundFactory.load(request);
       channel = soundFactory.play();
       stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
      private function ioErrorHandler(event:Event):void
       trace("ioErrorHandler: " + event);
      private function setPan(pan:Number):void
       trace("setPan: " + pan.toFixed(2));
       var transform:SoundTransform = channel.soundTransform;
       transform.pan = pan;
       channel.soundTransform = transform;
      private function setVolume(volume:Number):void
       trace("setVolume: " + volume.toFixed(2));
       var transform:SoundTransform = channel.soundTransform;
       transform.volume = volume;
       channel.soundTransform = transform;
      private function mouseMoveHandler(event:MouseEvent):void
       var halfStage:uint = Math.floor(stage.stageWidth / 2);
       var xPos:uint = event.stageX;
       var yPos:uint = event.stageY;
       var value:Number;
       var pan:Number;
       if (xPos > halfStage)
        value = xPos / halfStage;
        pan = value - 1;
       else if (xPos < halfStage)
        value = (xPos - halfStage) / halfStage;
        pan = value;
       else
        pan = 0;
       var volume:Number = 1 - (yPos / stage.stageHeight);
       setVolume(volume);
       setPan(pan);
     package
    import flash.display.Sprite;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.text.TextField;
    import flash.events.MouseEvent;
    import flash.text.TextFieldAutoSize;
    public class SoundChannel_stopExample extends Sprite
      private var snd:Sound = new Sound();
      private var channel:SoundChannel = new SoundChannel();
      private var button:TextField = new TextField();
      public function SoundChannel_stopExample()
       var req:URLRequest = new URLRequest("MySound.mp3");
       snd.load(req);
       button.x = 10;
       button.y = 10;
       button.text = "PLAY";
       button.border = true;
       button.background = true;
       button.selectable = false;
       button.autoSize = TextFieldAutoSize.CENTER;
       button.addEventListener(MouseEvent.CLICK, clickHandler);
       this.addChild(button);
      private function clickHandler(e:MouseEvent):void
       var pausePosition:int = channel.position;
       if (button.text == "PLAY")
        channel = snd.play(pausePosition);
        button.text = "PAUSE";
       else
        channel.stop();
        button.text = "PLAY";

  • Referencing buttons in AS3

    I am trying to figure out a way to reference a specific button out of a large group of buttons in AS3. I’ll explain. Let’s say, for instance, I have a lot of buttons on the stage (let’s say 100.) Each of these buttons causes something to happen. Instead of creating an event listener and a function for all 100 buttons, I want to do it more dynamically. I want to have some kind of variable which will equal the instance name of whatever button was pressed, and then an event listener that will check that variable’s value, and, depending on what it is equal to, it will issue a command. Any ideas on how to reference a button in that way? Thanks in advance.

    import fl.controls.Button;
    var buttons:Array = new Array();
    for(var i:uint = 0; i < 10; i++) {
    buttons[i] = new Button();
    buttons[i].move(0, i * 22);
    buttons[i].label = 'hi ' + i;
    buttons[i].addEventListener(MouseEvent.CLICK, onClick);
    addChild(buttons[i]);
    function onClick(event:MouseEvent):void {
    trace(event.target.label);

  • Create Dynamic button

    can anyone guide me to create dynamic button? Thank you,

    Hi Pankaj,
    This is what you need:
      public static void wdDoModifyView(IPrivateStamappView wdThis, IPrivateStamappView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
        //@@begin wdDoModifyView
        if (firstTime){
             IWDButton button = (IWDButton) view.createElement(IWDButton.class,"myButtomid");
                 IWDTransparentContainer myCont = (IWDTransparentContainer) view.getRootElement();      
             myCont.createLayout(IWDMatrixLayout.class);
             myCont.addChild(button,0);
        //@@end
    Regards
    Nir

  • Creating Buttons Dynamically

    Hi All,
    I have a problem with button."How to create the group of
    buttons(not ButtonBar,ToggleButtonBar) dynamically
    I have one Application under that, i have one component,in
    that i'm developing the Buttons dynamically.
    while adding the button to container am getting the error
    Here am sending the code,
    <?xml version="1.0" encoding="utf-8"?>
    <mx:VBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="100%" height="100%"
    creationComplete="init()">
    <mx:Script>
    <![CDATA[
    import mx.controls.Button;
    import mx.core.Application;
    import mx.controls.Label;
    import mx.controls.Text;
    import mx.controls.Alert;
    private var arrButtons:Array = new
    Array("Button1","Button2","Button3","Button4");
    private var button:Button = new Button();
    private function init():void
    for(var i:uint = 0;i<arrButtons.length;i++)
    button.id = arrButtons
    .toLowerCase();
    button.label = arrButtons;
    Alert.show("Button Value: "+button.label+""+button.id);
    btn.addChild(button);
    ]]>
    </mx:Script>
    <mx:HBox id="btn">
    </mx:HBox>
    </mx:VBox>
    The above component am adding to the Application using
    namespaces.
    If u have any ideas in this issue plz tel me...
    Thanks & Regards,
    Srinivas,
    Bangalore,
    9945081041.

    What is the error you are getting?

  • Dynamic Creation of Buttons and Actions HELP

    Hi there,
    I have got a problem (or maybe even two) with the dynamic Creation of buttons. The code below creates the buttons.
    My main problem is, that the parameter created for the button's action isn't propagated to the assigned event handler. I get a null, though the name of the parameter in the event handler and the name of the parameter added to the action are the same.
    Could it also be that I'm always using the same action? I.e. does wdThis.wdGetAddElementAction() always return the same action instance? If yes, how can I create individual actions for each button?
    Any help is appreciated!
    Cheers,
    Heiko
    "    for(int i=rootContainer.getChildren().length; i<wdContext.nodeFeature().size();i++)
                   IPrivateVCT_Feature.IFeatureElement featureElement = wdContext.nodeFeature().getFeatureElementAt(i);
                   IWDTray featureTray = (IWDTray) view.createElement(IWDTray.class, featureElement.getName());
                   IWDCaption header = (IWDCaption) view.createElement(IWDCaption.class, featureElement.getName()+"_Header");
                   header.setText(featureElement.getName());
                   featureTray.setHeader(header);
                   featureTray.setExpanded(false);
                   rootContainer.addChild(featureTray);
                   IWDButton button = (IWDButton) view.createElement(IWDButton.class, featureElement.getName()+"_Button_AddElement");
                   IWDAction actionAddElement = wdThis.wdGetAddElementAction();
                   actionAddElement.getActionParameters().addParameter("featureIndex", new Integer(i).toString());
                   button.setOnAction(actionAddElement);
                   button.setText("Add Element");
                   featureTray.addChild(button);

    Hi Heiko,
    You have done everything correctly....except for 1 line
    in the code...
    Replace the following line in your code:
    actionAddElement.getActionParameters().addParameter("featureIndex", new Integer(i).toString());
    Replace the above line with this code:
    button.mappingOfOnAction().addParameter("featureIndex",i);
    Actually in your code, you are not associating the parameter with the button...
    Note that addParameter(...) comes with two signatures: addParameter(String param, String value) and addParameter(String param, int value). You can use any of them based on yuor need.
    Hope it helps,
    Thanks and Regards,
    Vishnu Prasad Hegde

  • Problem with minimize and maximize of the AIR WIndow

    If I execute the below code I will get an window with 100 buttons. With vertical scrolling on.
    If I bring the vertical scroll down say positioned at some button. Minimize it using minimize button and maxmize it . The vertical scroll position is resetting to the top.
    I am not able to figureout how to resolve this issue. I appreciate any help in this regard.
    Regards,
    Penugondac
    <?xml version="1.0" encoding="utf-8"?><mx:WindowedApplication 
    xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="init()">
    <mx:Script>
    <![CDATA[
    import mx.controls.Button; 
    public function init():void{
    for(var i:int =0; i< 100; i++){
    var button:Button = new Button();button.width=50;
    button.height=50;
    vbox.addChild(button);
    ]]>
    </mx:Script>
    <mx:VBox id="vbox" />
     </mx:WindowedApplication>

    imaginebeth, not all ppl have set it up the iMessage feature they just turn off the option on their apple devices, i had few friends that i know they have iPhone iPad , iPod and they just do not use iMessage because they said are using the same apple ID in all their devices and the imessages drop in they message app, i know that happend but just some do not like use that feature, if u send a text to one of ur contacts that has iPhone and the message go in green color that is because they are not using iMessage feature or some are out range from cellphone towers signal sometimes happend with few of my contacts.

  • Multiple Rows in HBox in Flex

    Hi,
          I am using an Hbox that is populated with simple button controls at runtime. The HBox and buttons to be populated inside are both of fixed width. But the problem is that it only populates the buttons in a straight horizotal way, though as it should.
    But I need it to populate the buttons until the width of HBox and then in the second row until it fills till the width of HBox so that no scroll bar appears.
    I'm using a simple code as below.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
                    minWidth="955" minHeight="600"
                    backgroundColor="white">
        <mx:Script>
            <![CDATA[
                import mx.controls.Alert;
                private var counter:int        =    0;
                protected function button1_clickHandler(event:MouseEvent):void
                    var button:Button    =    new Button();
                    hbButtons.addChild(button);
                    button.width    =    80;
                    button.height    =    25;
                    button.label    =    "button " + counter++;
                    button.addEventListener(MouseEvent.CLICK, onButtonClick);               
                private function onButtonClick(event:MouseEvent):void {
                    Alert.show(" Hello Brother! I'm inside the Horizontal Box ",(event.target as Button).label);
            ]]>
        </mx:Script>
        <mx:Button x="74" y="102" label="Add Button" height="36" width="121"
                   click="button1_clickHandler(event)"/>
        <mx:HBox id="hbButtons" x="74" y="146" width="586" height="100"
                 paddingLeft="10" paddingTop="10"
                 borderStyle="solid" borderThickness="2"
                 borderColor="black">
        </mx:HBox>
    </mx:Application>
    Is there any way of doing this.

    If you are using flex 3,you can try the Tile container.
    http://livedocs.adobe.com/flex/3/html/help.html?content=layouts_11.html
    For flex 4, take a look at TileLayout.
    http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7e4f.html

  • Error 1046: Type was not found or was not a compile-time constant: Component Event.

    Hi Everyone..
    I am getting an Error 1046: Type was not found or was not a compile-time constant: Component Event.
    The ComponentEvent class has been imported,and also the event handling code is there. I am not sure what else is wrong, hope somebody can advise me. Thanks. The code is below, the point where the error occurs as indicated by the compiler has been highlighted.
    package 
    import flash.display.Sprite;
    import flash.media.Camera;
    import flash.media.Microphone;
    import flash.media.Video;
    import fl.controls.TextArea;
    import fl.controls.Button;
    import fl.controls.TextInput;
    import flash.events.SyncEvent;
    import flash.events.MouseEvent;
    import flash.events.FocusEvent;
    import flash.net.SharedObject;
    import flash.net.NetConnection;
    import flash.net.NetStream;
    import flash.events.NetStatusEvent;
    import flash.events.FocusEvent;
    import flash.events.ComponentEvent;
    public class VideoChat extends Sprite
      private var button:Button;
      private var text_so:SharedObject; 
      private var textArea:TextArea;
      private var textInput:TextInput;
      private var chatName:TextInput; 
      private var nc:NetConnection;
      private var nsOut:NetStream;
      private var nsIn:NetStream;
      private var rtmpNow:String;
      private var msg:Boolean; 
      private var cam:Camera;
      private var mic:Microphone;
      private var vid:Video;
      public function VideoChat ()
       //Set up UI
       textArea = new TextArea();
       textArea.setSize(500,280);
       textArea.move(20,54);
       addChild(textArea);
       textInput = new TextInput();
       textInput.setSize(500,24);
       textInput.move(20,340);
       textInput.addEventListener(ComponentEvent.ENTER,checkKey);
       addChild(textInput);
       button = new Button();
       button.width=50;
       button.label="Send";
       button.move(20,370);
       button.addEventListener(MouseEvent.CLICK, sendMsg);
       addChild(button);
       chatName = new TextInput;
       chatName.setSize (100,24);
       chatName.move (80,370);
       chatName.text="<Enter Name>";
       chatName.addEventListener (FocusEvent.FOCUS_IN, cleanName);
       addChild(chatName); 
       //Connect
       rtmpNow="rtmp:/VideoChat ";  
       nc=new NetConnection;
       nc.connect (rtmpNow);
       nc.addEventListener(NetStatusEvent.NET_STATUS,doSO);
       cam = Camera.getCamera();
       mic=Microphone.getMicrophone();
       //Camera Settings
       cam.setKeyFrameInterval(15);
       cam.setMode (240, 180, 15, false);
       cam.setMotionLevel(35,3000);
       cam.setQuality(40000 / 8,0);
       //Microphone Settings
       mic.gain = 85;
       mic.rate=11;
       mic.setSilenceLevel (25,1000);
       mic.setUseEchoSuppression (true);
       //Video Setup
       vid=new Video(cam.width, cam.height);
       addChild (vid);
       vid.x=10, vid.y=20;  
       //Attach local video and camera
       vid.attachCamera(cam);  
      private function doSO(e:NetStatusEvent):void
       good=e.info.code == "NetConnection.Connect.Success";
       if(good)
        //Set up shared object
        text_so=SharedObject.getRemote("test", nc.uri, false);
        text_so.connect (nc);
        text_so.addEventListener(SyncEvent.SYNC, checkSO);
      private function checkSO(e:SyncEvent):void
       for (var chung:uint; change<e.changeList.length; chng++)
        switch(e.chageList[chng].code)
         case "clear":
          break;
         case "success":
          break;
         case "change":
          textArea.appendText (text_so.data.msg + "\n");
          break;
      private function cleanName(e:FocusEvent): void
       chatName.text="";
      private function sendMsg(e:MouseEvent):void
       noName=(chatName.text=="<Enter Name>" || chatName.text=="");
       if (noName)
         textArea.appendText("You must enter your name \n");
       else
        text_so.setProperty("msg", chatName.text +": " + textInput.text);
        textArea.appendText (chatName.text +": "+textInput.text +"\n");
        textInput.text="";
      private function checkKey (e:ComponentEvent):void
       noName=(chatName.text=="<Enter Name>" || chatName.text=="");
       if (noName)
         textArea.appendText("You must enter your name \n");
       else
        text_so.setProperty("msg", chatName.text +": " + textInput.text);
        textArea.appendText (chatName.text +": "+textInput.text +"\n");
        textInput.text="";
      //Create NetStream instances
      private function checkConnect  (e:NetStatusEvent):void
       msg=e.info.code == "NetConnection.Connect.Success";
       if(msg)
        nsOut=new NetStream(nc);
        nsIn=new NetStream(nc);
        //NetStream
        nsOut.attachAudio(mic);
        nsOut.attachCamera(cam);
        nsOut.publish("camstream");
        nsIn.play("camstream");

    Hi Guys...
    I have found out what is wrong. I was importing the wrong package the correct one should have been:
    import fl.events.ComponentEvent;
    instead of
    import flash.events.ComponentEvent;
    I hope this is helpful for anyone caught in a simillar situation as me...Thanks..

  • How to Make Dreamweaver CS4/Flash CS4 Website Function on all Latest Mobile Devices

    Hello!
    I am trying to add code into my Dreamweaver CS4 file and/or Flash CS4 file in order to have the website I have created work across all of the latest mobile devices as well as traditional online systems. My flash file has a transparent stage, and my dreamweaver file has a full-screen background image. I have reviewed various tutorials and articles available online, and some advocate simply adding code, which does not seem to be working for me, while others suggest having a similar separate site created solely for mobile devices. If this is the best option, I don't know how that should be set up. What is the best path to take with this?
    This is the collection of various pieces of code I have tried adding to my files:
      <meta name="viewport" content="width=device-width" user-scalable="yes" initial-scale="1.0" /> <!-- iphone,android -->
       <meta name="HandheldFriendly" content="true" /> <!-- blackberry -->
    </style>
       <param name="allowScriptAccess" value="sameDomain" />
          <param name="allowFullScreen" value="true" />
    <param name="allowScriptAccess" value="sameDomain" />
            <param name="allowFullScreen" value="true" />
            <param name="var params = {          id: "flashID", name: "flashcontent", menu: "false", allowFullScreen: "true", fullScreenOnSelection: "true", scale:"noscale", salign:"middle"};"
    stage.scaleMode = StageScaleMode.NO_SCALE;
    stage.align = StageAlign.TOP_LEFT;
    //or//
    this.stage.scaleMode = StageScaleMode.NO_SCALE;
    this.stage.align = StageAlign.TOP_LEFT;
    next_btn.width = 133 * .5;
    next_btn.height = 133 * .5;
    //flash//
    next_btn.width = Capabilities.screenDPI * .5;
    next_btn.height = Capabilities.screenDPI * .5;
    //flash//
    this.stage.addEventListener(Event.RESIZE, doLayout);
    //flash://
    <initialWindow>
       <width>320</width>
       <height>480</height>
       <!-- several other properties... -->
    </initialWindow>
    * Convert inches to pixels.
    private function inchesToPixels(inches:Number):uint
       return Math.round(Capabilities.screenDPI * inches);
    var button:Sprite = new Sprite();
    button.x = 20;
    button.y = 20;
    button.graphics.beginFill(0x 003037);
    button.graphics.drawRect(0, 0, this.inchesToPixels(.75),
       this.inchesToPixels(.25));
    button.graphics.endFill();
       this.addChild(button);
    //hard-code title://
    var titleBar:Sprite = new Sprite();
    titleBar.x = 0;
    titleBar.y = 0;
    //stage width determines width of title://
    var titleBar:Sprite = new Sprite();
    titleBar.x = 0;
    titleBar.y = 0;
    titleBar.graphics.beginFill(0x003037);
    titleBar.graphics.drawRect(0, 0, this.stage.stageWidth,
       this.inchesToPixels(.3));
    titleBar.graphics.endFill();
    this.addChild(titleBar);
    //footer://
    var footer:Sprite = new Sprite();
    footer.graphics.beginFill(0x003037);
    footer.graphics.drawRect(0, 0, this.stage.stageWidth,
       this.inchesToPixels(.3));
    footer.graphics.endFill();
    footer.x = 0;
    footer.y = this.stage.stageHeight - footer.height;
    this.addChild(footer);
    * Center one DisplayObject relative to another.
    private function center(foreground:DisplayObject,
       background:DisplayObject):void
          foreground.x = (background.width / 2) -
             (foreground.width / 2);
          foreground.y = (background.height / 2) +
             (foreground.height / 2);
    //cont.//
    var title:SimpleLabel = new SimpleLabel("My Application",
       "bold", 0xffffff, "_sans", this.inchesToPixels(.15));
    this.center(title, titleBar);
    this.addChild(title);
    //override width and height getters
    public override function get width():Number
       return this.textLine.textWidth;
    public override function get height():Number
       return (this.textLine.ascent - 1);
    if (Capabilities.manufacturer == "Android Linux" && Capabilities.screenResolutionY == 1024)
    next_btn.width = 85;
    next_btn.height = 85;
    This is the code for my Dreamweaver CS4 file (without the additional erogenous code attempts):
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN"
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>My Website Title and Slogan.</title>
    <style type="text/css">
    <!--
    body {
              background-image: url(bground%20_img3.jpg);
              background-repeat: no-repeat;
    -->
    <script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
    </head>
    <body>
    <img src ="image.gif"  width=90% height=auto>
    <script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
    <meta name="Keywords" content="keywords…" />
    <div align="center"></div>
    <div align="center">
      <p> </p>
      <p>
        <object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="900" height="630">
          <param name="movie" value="FlashFile.swf" />
          <param name="quality" value="high" />
          <param name="wmode" value="transparent" />
          <param name="swfversion" value="6.0.65.0" />
          <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
          <param name="expressinstall" value="Scripts/expressInstall.swf" />
          <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
          <!--[if !IE]>-->
          <object type="application/x-shockwave-flash" data="FlashFile.swf" width="900" height="630">
            <!--<![endif]-->
            <param name="quality" value="high" />
            <param name="wmode" value="transparent" />
            <param name="swfversion" value="6.0.65.0" />
            <param name="expressinstall" value="Scripts/expressInstall.swf" />
            <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
            <div>
              <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
              <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
            </div>
            <!--[if !IE]>-->
          </object>
          <!--<![endif]-->
        </object>
      </p>
    </div>
    <div align="center"> </div>
    <script type="text/javascript">
    <!--
    swfobject.registerObject("FlashID");
    swfobject.registerObject("FlashID");
    //-->
    </script>
    </body>
    </html>
    I have tried various combinations of the code listed above, but nothing seems to be working. I am not sure as to the positioning of the code, and maybe that is the problem, or maybe it is because this code in not for CS4, or not appropriate for my project. I also do not know what code should be inside the Flash file, nor what should should be inside the Dreamweaver file.
    Thank you in advance for any assistance!

    Hi
    To add to what Gramps has said, Adobe has ceased developing its flash player for ALL mobile devices so do not use Flash for any mobile device.
    Depending on the complexity of your Flash program you may be able to recreate it using Edge, but the code generated by Edge does not work in IE8 or below.
    For details on Edge, see - http://labs.adobe.com/technologies/edge/
    PZ

  • How to Make Flash CS4/Dreamweaver CS4 Website Function on all Latest Mobile Devices

    Hello!
    I am trying to add code into my Dreamweaver CS4 file and/or Flash CS4 file in order to have the website I have created work across all of the latest mobile devices as well as traditional online systems. My flash file has a transparent stage, and my dreamweaver file has a full-screen background image. I have reviewed various tutorials and articles available online, and some advocate simply adding code, which does not seem to be working for me, while others suggest having a similar separate site created solely for mobile devices. If this is the best option, I don't know how that should be set up. What is the best path to take with this?
    This is the collection of various pieces of code I have tried adding to my files:
      <meta name="viewport" content="width=device-width" user-scalable="yes" initial-scale="1.0" /> <!-- iphone,android -->
       <meta name="HandheldFriendly" content="true" /> <!-- blackberry -->
    </style>
       <param name="allowScriptAccess" value="sameDomain" />
          <param name="allowFullScreen" value="true" />
    <param name="allowScriptAccess" value="sameDomain" />
            <param name="allowFullScreen" value="true" />
            <param name="var params = {          id: "flashID", name: "flashcontent", menu: "false", allowFullScreen: "true", fullScreenOnSelection: "true", scale:"noscale", salign:"middle"};"
    stage.scaleMode = StageScaleMode.NO_SCALE;
    stage.align = StageAlign.TOP_LEFT;
    //or//
    this.stage.scaleMode = StageScaleMode.NO_SCALE;
    this.stage.align = StageAlign.TOP_LEFT;
    next_btn.width = 133 * .5;
    next_btn.height = 133 * .5;
    //flash//
    next_btn.width = Capabilities.screenDPI * .5;
    next_btn.height = Capabilities.screenDPI * .5;
    //flash//
    this.stage.addEventListener(Event.RESIZE, doLayout);
    //flash://
    <initialWindow>
       <width>320</width>
       <height>480</height>
       <!-- several other properties... -->
    </initialWindow>
    * Convert inches to pixels.
    private function inchesToPixels(inches:Number):uint
       return Math.round(Capabilities.screenDPI * inches);
    var button:Sprite = new Sprite();
    button.x = 20;
    button.y = 20;
    button.graphics.beginFill(0x 003037);
    button.graphics.drawRect(0, 0, this.inchesToPixels(.75),
       this.inchesToPixels(.25));
    button.graphics.endFill();
       this.addChild(button);
    //hard-code title://
    var titleBar:Sprite = new Sprite();
    titleBar.x = 0;
    titleBar.y = 0;
    //stage width determines width of title://
    var titleBar:Sprite = new Sprite();
    titleBar.x = 0;
    titleBar.y = 0;
    titleBar.graphics.beginFill(0x003037);
    titleBar.graphics.drawRect(0, 0, this.stage.stageWidth,
       this.inchesToPixels(.3));
    titleBar.graphics.endFill();
    this.addChild(titleBar);
    //footer://
    var footer:Sprite = new Sprite();
    footer.graphics.beginFill(0x003037);
    footer.graphics.drawRect(0, 0, this.stage.stageWidth,
       this.inchesToPixels(.3));
    footer.graphics.endFill();
    footer.x = 0;
    footer.y = this.stage.stageHeight - footer.height;
    this.addChild(footer);
    * Center one DisplayObject relative to another.
    private function center(foreground:DisplayObject,
       background:DisplayObject):void
          foreground.x = (background.width / 2) -
             (foreground.width / 2);
          foreground.y = (background.height / 2) +
             (foreground.height / 2);
    //cont.//
    var title:SimpleLabel = new SimpleLabel("My Application",
       "bold", 0xffffff, "_sans", this.inchesToPixels(.15));
    this.center(title, titleBar);
    this.addChild(title);
    //override width and height getters
    public override function get width():Number
       return this.textLine.textWidth;
    public override function get height():Number
       return (this.textLine.ascent - 1);
    if (Capabilities.manufacturer == "Android Linux" && Capabilities.screenResolutionY == 1024)
    next_btn.width = 85;
    next_btn.height = 85;
    This is the code for my Dreamweaver CS4 file (without the additional erogenous code attempts!):
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN"
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>My Website Title and Slogan.</title>
    <style type="text/css">
    <!--
    body {
              background-image: url(bground%20_img3.jpg);
              background-repeat: no-repeat;
    -->
    <script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
    </head>
    <body>
    <img src ="image.gif"  width=90% height=auto>
    <script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
    <meta name="Keywords" content="keywords…" />
    <div align="center"></div>
    <div align="center">
      <p> </p>
      <p>
        <object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="900" height="630">
          <param name="movie" value="FlashFile.swf" />
          <param name="quality" value="high" />
          <param name="wmode" value="transparent" />
          <param name="swfversion" value="6.0.65.0" />
          <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
          <param name="expressinstall" value="Scripts/expressInstall.swf" />
          <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
          <!--[if !IE]>-->
          <object type="application/x-shockwave-flash" data="FlashFile.swf" width="900" height="630">
            <!--<![endif]-->
            <param name="quality" value="high" />
            <param name="wmode" value="transparent" />
            <param name="swfversion" value="6.0.65.0" />
            <param name="expressinstall" value="Scripts/expressInstall.swf" />
            <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
            <div>
              <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
              <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
            </div>
            <!--[if !IE]>-->
          </object>
          <!--<![endif]-->
        </object>
      </p>
    </div>
    <div align="center"> </div>
    <script type="text/javascript">
    <!--
    swfobject.registerObject("FlashID");
    swfobject.registerObject("FlashID");
    //-->
    </script>
    </body>
    </html>
    I have tried various combinations of the code listed above, but nothing seems to be working. I am not sure as to the correct positioning of the code, and maybe that is the problem, or maybe it is because this code in not for CS4, or not appropriate for my project. I also do not know what code should be inside the Flash file, nor what should should be inside the Dreamweaver file.
    Thank you in advance for any assistance!

    There is no simple code to add that will display the same on all mobile devices....
    you do know that the iProducts (iPhone, iPad, etc) don't display Flash at all, right?
    So as a start for "functioning on all latest mobile devices" you should drop any Flash content you have and move on.
    Adninjastrator

Maybe you are looking for

  • Hard Drives Bare After Forced Restart!!! HELP!!!

    Running new Mac Pro w/ plenty of RAM, and the latest OS. Was installing Xcode with a few programs running in the background. Time Machine appeared to have kicked in during the install and Xcode just seemed to hang. Then, suddenly all text disappeared

  • SRM PO Status "Error in Process"

    Hi, SRM 3.0 Extended classic scenario EBP Purchase order goes in to Status "Error in process" after making some ammendments. Getting following error 1) EEP\Business to Business Procurement(100)\...\Purchase Order\Backend application errors 2)Business

  • Connect my nokiax2-01 to my HD TV

    Can you tell me the steps i have to do to connect my nokiax2-01 to my HD TV to view videos in my memory card through nokia USB cable Solved! Go to Solution.

  • Paragon NTFS for MAC vs HFS for Windows?

    Hey fellas! Which of these 2 would you say it makes more sense to have in a bootcamp environment with a drive exclusively for data storage: NTFS for MAC or HFS for Windows? My setup is drive 1 for both OSs, MAC and WINDOWS, and drive 2 would be then

  • Install/upgrade issue - xfree86

    Hi, I noticed something when installing/upgrading the xfree86 package... pacman appears to only download a portion (<20%) of the package, then it installs it.  This isn't really a critical issue, since everything seems to work just fine, regardless.