我有一个Number类型的变量,我想获得符号(如果是' - '我喜欢-1,如果'+'我想要1).所以,我做了这个:
var sign = Math.abs(n) / n;
Run Code Online (Sandbox Code Playgroud)
但是,还有其他方法吗?比这更好?
如何在全屏模式下在浏览器中制作我的Flash应用程序?我知道舞台可以放在那种模式下,但是当我在任何浏览器中运行应用程序时,这都不起作用.那么,这可以做到,但是怎么做?
我想知道是否有一种方法可以读取批处理文件中的用户输入,因为我有一个名为"fif.bat"的文件,它存储了两个参数(只需将它们称为paramA和paramB),所以我执行这样的文件:
fif paramA paramB
Run Code Online (Sandbox Code Playgroud)
我必须每个月更改一次paramA,但我多次调用这个文件,所以我想打开一个控制台并打印出来:
fif paramA
Run Code Online (Sandbox Code Playgroud)
所以我只需要编写paramB并在需要时更改paramA.
PD:paramA非常大,所以如果我可以在那里而不是每次写作都非常有帮助.而且我不想制作另一个批处理文件来调用fif whit paramA.
在Action Script 3中,您可以编写一个定义动态对象的类(MovieClip和Object是两个示例),可以在运行时修改此对象.我想知道是否有某种方式(当然是在运行时)知道某个对象是否是动态的.
PS:没有这样的东西:
function isDynamic(object) {
try {
object.newProperty = 'someValue'
} catch (e) {
return false
}
return true
}
Run Code Online (Sandbox Code Playgroud) 我用Python 问了同样的问题.
现在我想知道这是否可以在AS3中完成.
如果我有这样的事情:
package
{
public class SomeClass
{
private function A():void { C() }
private function B():void { C() }
private function C():void
{
// who is the caller, A or B ???
}
public function SomeClass()
{
A()
B()
}
}
}
Run Code Online (Sandbox Code Playgroud)
尽管存在设计或其他问题,但这只是一个探究性思维的问题.
注意:我喜欢访问调用函数的实例,所以我可以调用该调用函数(如果我想)
function C()签名的情况下完成有一种方法可以知道在运行带有Action Script 3.0的SWF文件的计算机上安装的Flash播放器版本吗?
我怎么做初始化:
public const int[][,] Map = ...
Run Code Online (Sandbox Code Playgroud)
我想做这样的事情:
public const int[][,] Map = {
{ // Map 1
{1, 1, 1, 1},
{1, 1, 1, 1},
{1, 1, 1, 1},
{1, 1, 1, 1},
},
{ // Map 2
{1, 1, 1, 1},
{1, 0, 0, 1},
{1, 0, 0, 1},
{1, 1, 1, 1},
},
// etc.
};
Run Code Online (Sandbox Code Playgroud)
我不想创建一个int[,,] Map,因为我想做的其他地方:
loader.Load(Map[map_numer]); // Load method recieve an int[,]
Run Code Online (Sandbox Code Playgroud) 如果我有这个:
class A:
def callFunction(self, obj):
obj.otherFunction()
class B:
def callFunction(self, obj):
obj.otherFunction()
class C:
def otherFunction(self):
# here I wan't to have acces to the instance of A or B who call me.
...
# in main or other object (not matter where)
a = A()
b = B()
c = C()
a.callFunction(c) # How 'c' know that is called by an instance of A...
b.callFunction(c) # ... or B
Run Code Online (Sandbox Code Playgroud)
尽管存在设计或其他问题,但这只是一个探究性思维的问题.
注意:必须在不更改 签名的情况下完成此操作otherFunction
可能的重复:
如何并行迭代两个列表?
我有 2 个列表:
l = ["a", "b", "c"]
m = ["x", "y", "z"]
Run Code Online (Sandbox Code Playgroud)
我想同时遍历两者,如下所示:
for e, f in l, m:
print e, f
Run Code Online (Sandbox Code Playgroud)
必须显示:
a x
b y
c z
Run Code Online (Sandbox Code Playgroud)
问题是这完全是非法的。我怎么能做这样的事情?(以 Pythonic 的方式)
我试图理解 go 中的嵌套结构,所以我做了一个小测试:(游乐场)
type A struct {
a string
}
type B struct {
A
b string
}
func main() {
b := B{A{"a val"}, "b val"}
fmt.Printf("%T -> %v\n", b, b) // B has a nested A and some values
// main.B -> {{a val} b val}
fmt.Println("b.b ->", b.b) // B's own value
// b.b -> b val
fmt.Println("b.A.a ->", b.A.a) // B's nested value
// b.a -> a val
fmt.Println("b.a ->", b.a) // B's nested …Run Code Online (Sandbox Code Playgroud) 当我收到服务器响应时如何获取这个值?
当我运行它时,终端没有输出任何信息。
console.log(a);
function findMaxID() {
var a = needle.get(URL, function(err, res){
if (err) throw err;
return 222;
});
return a;
}Run Code Online (Sandbox Code Playgroud)
我找到了这个
window.dataLayer = window.dataLayer || [];
这是什么意思?
flash ×4
javascript ×2
oop ×2
python ×2
apache-flex ×1
arrays ×1
batch-file ×1
browser ×1
c# ×1
callback ×1
dynamic ×1
fullscreen ×1
function ×1
go ×1
list ×1
loops ×1
needle.js ×1
node.js ×1
prompt ×1