It looks to me like Matt avoided the namespace conflict by using a
private variable that differs from the instance name in case only. Note
that he uses all lowercase 'fullscreen' to represent the instance name
'fullScreen'.

Just to provide some background as to what's going on here, Flash CS3 is
automatically declaring variables for all instances on the stage. In
other words, Matt already has access to the instance name in his
document class, without having to declare it in his class. That's why
you get the duplicate name error if you declare it yourself. So Matt's
original code example will work if you simply delete the declaration:
"private var fullScreen:MovieClip".

If you don't want Flash CS3 to automatically declare variables, you can
turn off that feature by going to the Publish Settings dialog box,
selecting the "Flash" tab, and clicking on the "Settings" button. In the
"ActionScript 3.0 Settings" dialog box that appears, uncheck the
checkbox labeled: "Automatically declare stage instances". 

If you disable this feature, note that Flash CS3 still expects those
variables to exist and will still execute assignment statements that
bind those variables to the instances on stage. This means that you
either have to declare the variables yourself (and they have to be
public, by the way) or declare the class as dynamic so that the
variables can be added at runtime (specifically, at the time the
assignment statements are executed).

Francis Cheng | Sr. Technical Writer | Adobe Systems Incorporated

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Sunil
Jolly
Sent: Thursday, July 12, 2007 9:51 AM
To: [email protected]
Subject: RE: [Flashcoders] Accessing MovieClips on a timeline from an
AS3 class

Does that work? I'm getting a namespace conflict.

Sunil

-----Original Message-----

Thanks all, I ended up with something like this...

package com.foo.view.playerSkins {

    import flash.display.MovieClip;
    import com.sky.view.playerSkins.*;

    public class SkinInventory extends MovieClip{

        private var fullscreen:MovieClip;

        public function SkinInventory()
        {
            _init();
        }

        private function _init():void
        {
            fullscreen = getChild(this, "fullScreen");
            fullscreen = (fullscreen as FullScreen);
        }

        public function getChild(stage, _name:String):MovieClip
        {
            return stage.getChildByName(_name);
        }
    }
}

On 7/12/07, Sunil Jolly <[EMAIL PROTECTED]> wrote:
>
> Hi Matt,
>
> AS3 is slightly different.
>
> You need to say:
> private var fullScreen_mc:MovieClip = getChildByName("fullscreen");
>
> Note that the reference (fullscreen_mc) can't be the same as the name
on
> the stage ("fullscreen"). Also in AS3 you can actually set instance
> variables outside of functions.
>
> I'm quite new to AS3 so I'd be interested if there's another way to do
> this. I haven't really worked out a good naming convention for this
yet
> either - anyone have any ideas?
>
> Sunil
>
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to