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

  • Home
  • SEARCH
  • 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 6964595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:56:40+00:00 2026-05-27T15:56:40+00:00

AS3 code, from a sample, I want to have the value in the string

  • 0

AS3 code, from a sample, I want to have the value in the string ‘location’ available to other parts of the main program. It returns fine in the completed handler, but how do I make it available to the first part?

package  {

import flash.display.MovieClip;
import flash.display.MovieClip;
import flash.events.*
import flash.net.*;
import flash.net.URLVariables;  

public class turl extends MovieClip {

public var location:String = new String();

public function turl() {
    // constructor code 
var variables:URLVariables = new URLVariables();
variables.url = String("xxxxxxxxx");
sendAndLoad("xxxxxxxx", variables)
// THIS TRACE WILL NOT DISPLAY THE LOCATION _ A TINY URL
trace("TinyURL: " + location);
    }

function sendAndLoad(url:String, _vars:URLVariables ):void {

var request:URLRequest = new URLRequest(url);
var _urlloader:URLLoader = new URLLoader();
_urlloader.dataFormat = URLLoaderDataFormat.TEXT;
request.data = _vars;
request.method = URLRequestMethod.POST;
_urlloader.addEventListener(Event.COMPLETE, handleComplete);
_urlloader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
_urlloader.load(request);


}
function handleComplete(event:Event):void {
    var loader:URLLoader = URLLoader(event.target);
    location = loader.data;
    trace("TinyURL: " +  location);

}
function onIOError(event:IOErrorEvent):void {
    trace("Error loading URL.");
}


    }

}
  • 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-27T15:56:41+00:00Added an answer on May 27, 2026 at 3:56 pm

    The trace statement in the constructor doesn’t work because that trace happens immediately after the data request is made, before the data has been downloaded and location has been set. The constructer is meant for setting the initial conditions of an object. The only way to make the result of the data request immediately available to the constructor is to pass it in directly, but I think this would defeat the point of the class.

    public function TURL(value:String)
    {
        location = value;
    
        // Now this will work like you think.
        trace("TinyURL: " + location);
    }
    

    I’m guessing you have other objects relying on this TURL class having a proper location. If that’s the case, have the TURL class dispatch an event when it sets the location variable, indicating that it is ready to be used.

    function handleComplete(event:Event):void
    {
        var loader:URLLoader = URLLoader(event.target);        
        location = loader.data;
    
        dispatchEvent(new Event(Event.COMPLETE));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I create a document class Main and use Adobe Sample code from http://help.adobe.com/en_US/as3/components/WS5b3ccc516d4fbf351e63e3d118a9c65b32-7f9f.html and
I've done most of my code in as3, working from either document class or
I am a AS3 novice learning PureMVC and want to write code following best
I have couple of questions about AS3 variables handling by AVM/compiler/scope .1. This code
Hey all, let's jump straight to a code sample to show how ECMAScript/JavaScript/AS3 can't
In AS3 you have a function on a string with this signature: function replace(pattern:*,
I'm trying to call Tamarin's ESC Compiler from AS3 code. I've got the ESC
Is it possible to enable the show redraw regions programmatically? From AS3 code, I
I am new to AS3. When learning AS3, I get the below code from
I'm trying to protect my as3 .swf flash file code from decompilation. I cannot

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.