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 7601247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:07:19+00:00 2026-05-30T23:07:19+00:00

I have been making huge strides in learning Flex and I am very much

  • 0

I have been making huge strides in learning Flex and I am very much enjoying it, however, one thing I cannot find much help on is how to bind results from a query in Flex. I have managed to create lists etc no problem but when I try to bind one specific value to a variable, it does not work.

First off, here is my PHP function:

public function getRepnameByUsername($itemID) {

        $stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename where Username=?");
        $this->throwExceptionOnError();

        mysqli_stmt_bind_param($stmt, 'i', $itemID);        
        $this->throwExceptionOnError();

        mysqli_stmt_execute($stmt);
        $this->throwExceptionOnError();

        mysqli_stmt_bind_result($stmt, $row->RepID, $row->Username, $row->FirstName, $row->Surname, $row->SerialKey);

        if(mysqli_stmt_fetch($stmt)) {
          return $row;
        } else {
          return null;
        }

    }

Then of course, my function in Flex I have not included all the variables as they are pretty obvious and the only one I am having trouble with is the repServ one declared inside this function.

            protected function btnSubmitUser_clickHandler(event:MouseEvent):void
        {
            username = txtUsername.text;
            password = txtPassword.text;
            serialno = txtSerialNo.text;
            userName.writeUTFBytes(username);
            passWord.writeUTFBytes(password);
            serialNo.writeUTFBytes(serialno);
            EncryptedLocalStore.setItem("Username", userName);
            EncryptedLocalStore.setItem("Password", passWord);
            EncryptedLocalStore.setItem("Serial", serialNo);
            var repServ:Repname = new Repname();
            getRepnameByUsernameResult.token = repnameService.getRepnameByUsername(username);
            repServ = getRepnameByUsernameResult.lastResult;
            repid = repServ.RepID;
            RepID.writeInt(repid);
            EncryptedLocalStore.setItem("Rep", RepID);
        }

The line that is throwing errors is repid = repServ.RepID and I think it is something to do with how I am trying to bind it by the line above. What is the best way of doing this?

Thanks
J

  • 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-05-30T23:07:20+00:00Added an answer on May 30, 2026 at 11:07 pm

    I see a few things wrong with your code. First, the remote calls are asynchronous. That means the they run in a different thread. So if we look at this code:

            getRepnameByUsernameResult.token = repnameService.getRepnameByUsername(username);
            repServ = getRepnameByUsernameResult.lastResult;
    

    There is an extremely high probability that the getRepnameByUsername service will not have finished exection, or returned anything, by the time that you try to access the results. Instead you should listen for the result event on the service. Conceptually like this:

            getRepnameByUsernameResult.addEventListener(ResultEvent.RESULT, onMyResult);
            getRepnameByUsernameResult.token = repnameService.getRepnameByUsername(username);
    

    Then in your result handler, you can process the results:

    protected function onMyResult(event:ResultEvent):void{
                repServ = getRepnameByUsernameResult.lastResult as Repname;
                repid = repServ.RepID;
                RepID.writeInt(repid);
                EncryptedLocalStore.setItem("Rep", RepID);
    }
    

    The second thing I see wrong is that you are not casting the lastResult as an actual object type. I would have expected that to throw a runtime error. I added the conversion in the above code.

    You didn’t tell us what type of service you’re using. ( HTTPService, RemoteObject, or WebService).

    It doesn’t look like you ever create an object named Repname with the result data. If you are using AMF (RemoteObject), then you can automatically translate the server side object to a client side object. But, you’ll probably have to turn your query into that object on the server so it can be translated automatically. If you’re using WebService or HTTPService, you’ll have to parse the data in the client to turn it into a Repname object.

    The results of lastResults are most likely a generic object. You can access specific properties using syntax like this:

    getRepnameByUsernameResult.lastResult['repid']
    

    You could either use it as a generic object or convert it manually.

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

Sidebar

Related Questions

I have been making a matrix class (as a learning exercise) and I have
I have been making a button which (hopefully) looks fairly realistic. One part of
I have been making a database and learning along the way. I recently got
I have been making a little toy web application in C# along the lines
I have been making a threaded comment system as a way to learn php
I'm relatively new to java (specifically swing) and have recently been making some fairly
I have been using the Rails console a fair bit lately and its making
I am making a game that needs a crosshair. I have been playing with
I have been making a program that creates multiple CSV's from another source CSV
I have been making a volunteer sign up sheet for our hockey club. I

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.