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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:49:52+00:00 2026-05-12T16:49:52+00:00

I am just learning actionscript, so come across the problem In my application I

  • 0

I am just learning actionscript, so come across the problem

In my application I often call to different web services, and because I don’t want to hardcode urls to them in my code, I am passing urls to the services as flashvars.

Currently I am doing it this way:

        public var siteUrl:String;
        public var gameId:String;

            public function main():void
            {
                siteUrl = Application.application.parameters.siteurl;
                gameId = Application.application.parameters.gameid;

Where main is a function, which is called on application’s creation complete event.

This way I can call both variables from main file of the application but I want to access them from other files. (other as classes)

So is there a way to create class with constants and init values there with flashvars so I can use them everywhere (after importing of course)

  • 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-12T16:49:52+00:00Added an answer on May 12, 2026 at 4:49 pm

    The parameters are just stored in that Application.application.parameters object, and that’s static. There’s no reason you couldn’t access that from other classes in your code.

    If you want to write a class that wraps the parameters (maybe validates them or something) you could do that fairly easily. You can use a for each loop to loop over all the parameters. Something like:

    var params:Object = Application.application.parameters
    for(var name:String in params) {
      var value:String = params[name] as String;
      /* do something with the param */
    }
    

    If you want your class to actually verify things then it could just check for each parameter it expects and store it in a local variable.

    It really just depends on your own preferences. Some people are fine with accessing the parameters object when they need it. Some people like having the extra code-completion by having a config class that actually defines all the expected config variables.

    Update in response to comment:

    Instead of having one module declare the variable and have other modules have to depend on that one to access the property it would be cleaner to have a single config module that everything that needs it would all use.

    You could use a static class or singleton or some IoC stuff. Just for simplicity I’ll show you a way you can do it with a static class.

    class MyConfig {
      private static var _infoService:String;
      private static var _someOtherParam:int;
    
      public static function get infoService():String { return _infoService; }
      public static function get someOtherParam():int { return _someOtherParam; }
    
      public static function initParams():Void {
        var params:Object = Application.application.parameters;
    
        _infoService = params.infoservice;
    
        // just assuming you have a method to convert here.  don't remember the
        // code off the top of my head
        _someOtherParam = convertToInt(params.someOtherParam);
      }
    }
    

    Make sure when your app initializes it calls MyConfig.initParams(). You can have that method actually validate that it gets everything it expects and throw exceptions (or return an error) if there’s a failure if you want.

    Then wherever you need to use that config within your code you just import your config class and access the param. So getting infoService would just be:

    var infoService:String = MyConfig.infoService;
    

    Personally I wouldn’t use a static class, but it was the easiest to show.

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

Sidebar

Ask A Question

Stats

  • Questions 207k
  • Answers 207k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you're using Perl 5.10, you can use the smart… May 12, 2026 at 9:16 pm
  • Editorial Team
    Editorial Team added an answer You're trying to call the ifstream's () operator (which doesn't… May 12, 2026 at 9:16 pm
  • Editorial Team
    Editorial Team added an answer It is something you use potentially many times within a… May 12, 2026 at 9:16 pm

Related Questions

I am from a programming background ,and newbie to flex3 . i would like
I am just learning about app.config in respect of creating custom sections. I have
I am just learning C# through Visual Studio 2008? I was wondering what exactly
I am just learning Ruby and I don't quite understand the difference between several
I am just learning python and is interested in how this can be accomplished.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.