PDA

View Full Version : error 1151, namespaces


dsdsdsdsd
05-25-2008, 05:30 PM
hello;

I have some code on the timeline:


var mcvo : Object = new Object();

mcvo.mcm_A = function():void
{ var lvo : Object ;
}
mcvo.mcm_B = function():void
{ var lvo : Object ;
}



which generates: 1151: A conflict exists with definition lvo in namespace internal.



I did not have this issue in AS1;

is there a solution other than having different variable names, which would be a messy and would breakdown some of my fundamental nomenclature protocols that I love so much;



any thoughts?


thanks
dsdsdsdsd

wvxvw
05-25-2008, 09:32 PM
Yes, there is a solution =) Use classes instead =)
or
var mcvo:Object = {
mcm_A:function():void {
var lvo:Object;
},
mcm_B:function():void {
var lvo:Object;
}
};This will compile.

BTW, in general your code shouldnt generate error, it's jus very "old-style", but, should be OK, if you fill like writting bug-report about it, you may do it here:
http://www.adobe.com/cfusion/mmform/index.cfm?name=wishform

dsdsdsdsd
05-25-2008, 10:16 PM
wvxvxw, interesting;

I am not sure how your approach is operationally different from mine - it seems to be merely a matter of syntax;

but your way does work;



as to why I am not using classes:
I do use AS3 external classes in some cases;
of course in the past(AS1) I always built applications via a timeline-based programming-environment ( with OOP/classes ) ... and I am not willing to give it up;



thanks
dsdsdsdsd

toddwashere
03-05-2010, 10:44 PM
This may also happen when you are moving code from a movie clip into a proper .as class file and forget to delete the code in the movie clip. Solution, delete the code from the movie clip to avoid duplicate variables and such.

maskedMan
03-05-2010, 11:39 PM
As best I can figure, the difference between the two approaches is that in the original example the function objects are created in the scope of the timeline. Those sorts of functions are "inlined" and as such have access to variables declared in the scope of the timeline... and the converse is true as well as the variables declared in the functions are at the timeline scope instead of the function scope.

In wvxvw's example, the functions aren't defined in the scope of the timeline, but in the definition of the dynamic object, thus removing namespace and scope issues. I think I'll try a test or two...

maskedMan
03-05-2010, 11:48 PM
The truth is stranger than that, even. So, I think this confirms my original guess... to an extent...


// this fails to compile. Same error as original post.
var o:Object;
o = {
a:function():void{var oo:String = "hi";},
b:function():void{var oo:String = "hi";}
}

/// but this succeeds...

var o:Object = {
a:function():void{var oo:String = "hi";},
b:function():void{var oo:String = "hi";}
}






But I'm definitely wrong about access and scope...


var s:String = "String on the Timeline";

var o:Object = {
a:function():void{var oo:String = "hi";},
b:function():void{var oo:String = "hi";},
c:function():void{trace(s)}
}

o.c(); // actually traces s.






This would fail to compile (or even work if it did compile) had I been correct on the count of scope.

wvxvw
03-06-2010, 11:51 AM
I think it's a pure compiler parser issue, not really proving anything about how that should work. I might have tried to set -es to true and -as to false to test what would've happen if the compiler believed it's all dynamic prototyping etc. But, this thread is really to old and I think the OP is no longer interested in the subject :) And you wouldn't probably do it this way either... So, who cares if it doesn't really work, if you don't really want it to work anyway? :)

dsdsdsdsd
06-23-2011, 08:57 AM
oh but I still care ... I care sooo much ... what was the question.