ActionScript Class for Global Variables in Flexfle

2024-02-25 20:08

本文主要是介绍ActionScript Class for Global Variables in Flexfle,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

ActionScript Class for Global Variables in Flex
原文:
[url]http://www.kerkness.ca/?p=4[/url]

I’ve been reading several blogs and forums on how to implement global variables in a Flex application. It’s tough to find an effective example of how to do this as most threads/comments are flooded with people crying foul that good programming doesn’t need global variables.

While I agree for the most part I’m used to having some sort of config file in my applications which hold defined constants that are likely to change depending on the deployment or version of the application. Eg: In my php applications I keep database connection information in a config file so that i can easily switch between a development database or production database.

The best solution I’ve found to do this in a Flex Application is to include in the root directory of your Flex application a ActionScript class that contains properties for all the constants or global variables you’ll need to define.

Action Script : Settings.as

package
{
public class Settings
{
static public var SiteUrl:String="http://www.mydomain.com";
}
}

Example MXML File Using Settings.as

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
xmlns="*">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function testSettings():void
{
Alert.show( Settings.SiteUrl );
}
]]>
</mx:Script>
<mx:Button label="test" click="testSettings()"/>
</mx:Application>


Important things to make note of in this example you’ll need xmlns=”*” in the opening tag of any MXML file or component which needs access to the properties of Settings.as. You’ll also need to make sure Settings.as is the root folder of your application.

这篇关于ActionScript Class for Global Variables in Flexfle的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/746561

相关文章

类型信息:反射-Class

在说反射前提一个概念:RTTI(在运行时,识别一个对象的类型) public class Shapes {public static void main(String[] args) {List<Shape> shapes = Arrays.asList(new Circle(), new Square(), new Triangle());for (Shape shape : shapes

react笔记 8-17 属性绑定 class绑定 引入图片 循环遍历

1、绑定属性 constructor(){super()this.state={name:"张三",title:'我是一个title'}}render() {return (<div><div>aaaaaaa{this.state.name}<div title={this.state.title}>我是一个title</div></div></div>)} 绑定属性直接使用花括号{}   注

泛型参Class、Class、Class的对比区别

1.原文链接 泛型参Class、Class、Class的对比区别 https://blog.csdn.net/jitianxia68/article/details/73610606 <? extends T>和<? super T> https://www.cnblogs.com/drizzlewithwind/p/6100164.html   2.具体内容: 泛型参数Class、

关于OceanBase MySQL 模式中全局索引 global index 的常见问题

在OceanBase的问答区和开源社区钉钉群聊中,时常会有关于全局索引 global index的诸多提问,因此,借这篇博客,针对其中一些普遍出现的问题进行简要的解答。 什么是 global index ? 由于 MySQL 不具备 global index 的概念,因此这一问题会经常被社区版用户提及。就在前几天,就要人询问下面这个语法的意义。 create table part_tes

c++通用模板类(template class)定义实现详细介绍

有时,有两个或多个类,其功能是相同的,仅仅是数据类型不同,如下面语句声明了一个类:class Compare_int { public : Compare(int a,int b) { x=a; y=b; } int max( ) { return (x>y)?x:y; } int min( ) { return (x&... 有时,有两个或多个类,其功能是相同的,仅仅是数

Python方法:__init__,__new__,__class__的使用详解

转自:https://blog.csdn.net/qq_26442553/article/details/82464682 因为python中所有类默认继承object类。而object类提供了了很多原始的内建属性和方法,所以用户自定义的类在Python中也会继承这些内建属性。可以使用dir()函数可以查看,虽然python提供了很多内建属性但实际开发中常用的不多。而很多系统提供的内建属性实际

SpringBoot启动报错Failed to determine a suitable driver class

两种解决办法 1.在Application类上加 ` @EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class}) package com.example.demo3;import org.springframework.boot.SpringApplication;import org.springframewo

easyswoole not controller class match

not controller class match composer.json 注册 App 这个名称空间了吗?执行过 composer dump-autoload 了吗?存在 Index 控制器,但是文件大小写、路径都对了吗? task socket listen fail 注意,在部分环境下,例如 win10 的 docker 环境中,不可把虚拟机共享目录作为 EasySwoole 的 T

JavaBug系列- Failed to load driver class com.mysql.cj.jdbc.Driver in either of HikariConfig class load

JavaBug系列之Mysql驱动问题 Java医生一、关于错误信息二、如何解决问题 Java医生 本系列记录常见Bug,以及诊断过程和原因 Java/一对一零基础辅导/企业项目一对一辅导/日常Bug解决/代码讲解/毕业设计等 V:study_51ctofx 一、关于错误信息 APPLICATION FAILED TO START Description: Fai

【上】java获取requestMapping上所有注解功能实现及取匿名注释类的值及 class com.sun.proxy.$Proxy140 转换出错

java获取requestMapping上所有注解功能实现及取匿名注释类的值及 class com.sun.proxy.$Proxy140 转换出错 1,多人相当然以为类似对象一样直接强转下就可以,结果迎来的是class com.sun.proxy.$Proxy140转换出错【想法很勇敢,现实很骨感】 //Class<A> operatorMappingAnnotationType// 错误