Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7827095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:43:13+00:00 2026-06-02T09:43:13+00:00

I have a flex code that i got from a friend. But i want

  • 0

I have a flex code that i got from a friend. But i want to customize this code to solve my needs. I want to pass a width and height to the flex code from jsp when it is loading probably on an applet. This width and height will determine the width and height of the captured image. After the image is captured, a “Done” button is clicked which calls a server url passing a java byte[] of the captured image. Below is the code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application initialize="videoDisplay_creationComplete();" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" x="149" y="131">
    <mx:Script>
        <![CDATA[
            import mx.graphics.ImageSnapshot;
            import mx.controls.Alert;

        public var cam:Camera = Camera.getCamera();
        public var video:Video = new Video(320,240);
        public var bitmapData:BitmapData = new BitmapData(video.width,video.height);
        public var snapshot:BitmapData;

    public function init():void
    {
        videoDisplay.visible=false;
    }
        public function start():void{
            if (cam == null)
            {
                Alert.show("No camera is installed","Unable to start capture!!!!");
                return;
            }
            video.attachCamera(cam);
            video.x = 20;
            video.y = 20;
            addChild(video);


            var bitmap:Bitmap = new Bitmap(bitmapData);
            bitmap.x = 360;
            bitmap.y = 20;
            addChild(bitmap);


        }   

        private function captureImage(e:MouseEvent):void 
        {
            bitmapData.draw(video);
        }

        private function videoDisplay_creationComplete():void 
        {               
            btnRestartCapture.enabled=false;
                if (cam!=null) {
                    videoDisplay.attachCamera(cam);
                } else {
                    Alert.show("You don't seem to have a camera.");
                }
            }

           public function takeSnapshot():void
            {
                snapshot = ImageSnapshot.captureBitmapData(videoDisplay);
                var bitmap:Bitmap= new Bitmap(snapshot);
                img.source=bitmap;
                videoDisplay.visible=false;

                btnRestartCapture.enabled=true;
            }


            public function sendToServer():void{
                 var loader:URLLoader= new URLLoader();
                loader.dataFormat = URLLoaderDataFormat.BINARY; 
                loader.data=snapshot.getPixels(new Rectangle(0,0,img.width,img.height));
            }
            private function callJavaScript():void {
                ExternalInterface.call("recievePictureFromFlex",snapshot.getPixels(new Rectangle(0,0,img.width,img.height)));
            }

            public function restartCap():void{
                videoDisplay.visible=true;
                btnRestartCapture.enabled=false;                
            }

            public function done():void
            {
                Alert.show("Done taking pix", "Done");
            }
        ]]>
    </mx:Script>
    <!--<mx:Button label="Capture Image" click="captureImage(null);"  id="capture_mc"/>-->

     <mx:VBox x="405" y="115" backgroundColor="white" >
         <mx:Canvas width="100%" height="100%">
             <mx:Image width="350" id="img" height="300"/>
             <mx:VideoDisplay id="videoDisplay" 
                creationComplete="videoDisplay_creationComplete();"
                width="350"
                height="300"  x="0" y="0"/>
         </mx:Canvas>
         <mx:HBox>
             <mx:Button id="btnRestartCapture" label="Clear Picture" click="restartCap();"/>
             <mx:Button id="snapButton" label="Snap" click="takeSnapshot()" width="113"/>
             <mx:Button id="doneButton" label="Done" click="done()" width="113"/>
         </mx:HBox> 
     </mx:VBox>
</mx:Application>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T09:43:15+00:00Added an answer on June 2, 2026 at 9:43 am

    For the jsp –> Flex communication, you can use flashvars :
    http://livedocs.adobe.com/flex/3/html/help.html?content=passingarguments_3.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Flex application that needs to grab reporting data from a JasperReports
I have a portlet. Inside of this portlet I have Flex application that displays
I have a Flex application that needs to be able to validate hundreds of
I have a flex application that needs the ability to generate and execute JavaScript.
I have flex sdk 4.6 installed and I want to compile AS3 class that
I have a flex 3 application that creates an Image from a canvas which
i'm converting code project from Flash AS 3 to Flex 4. I've got a
I've got a small client/server test application where I have a Flex app that
I have this piece of code that has a problem. so can you help
I have been trying this from two days but unable to found a solution

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.