This is beyond retarded. What fixed my problem? Doing something superfluous and stupid looking.

var invToolTemp:Object = toolArea.addTool(false,"InventoryToolMC");
trace("returned value: "+invToolTemp); //returns a clip reference
inventoryTool = invToolTemp; //set the class var to the local var
trace("stored value: "+inventoryTool); //voilà, class var set properly

What the hell?

-

Andreas Rønning wrote:
Yeah, but nm that :) Forgetfulness on my part when typing in this example. Trust me that's not the issue. The actual addTool function has a twotiered conditional that just dictates what clip the new tool be attached to, thought i'd spare you that excess script.

- A

Ian Thomas wrote:

Um - on a really swift look - shouldn't the first parameter be a boolean?

i.e.
inventoryTool = toolArea.addTool(false, "InventoryToolMC");

On 8/30/06, Andreas Rønning <[EMAIL PROTECTED]> wrote:

Kind of stumped here.

I have a class that holds an instance of a toolbar class.
The toolbar class has a method "addTool" that takes a linkage
identifier, attaches a movieclip with it and returns a reference to the
created movieclip as such:


inventoryTool = toolArea.addTool("InventoryToolMC");

toolArea.addTool looks like this:

function addTool(primary:Boolean,identifier:String):Object{ var d =
primary_tools.getNextHighestDepth();
var tool:Object = primary_tools.attachMovie(identifier,identifier+d,d);
        this.addListener(tool);
        tool.addListener(this);
        primaryTools.push(tool);
        updateTools(1);
        return tool;
}

However, this is giving me a whole heap of trouble.
In the case of:

inventoryTool = toolArea.addTool("InventoryToolMC");

inventoryTool is a class variable, and always comes up undefined.
I can do this:

trace(toolArea.addTool("InventoryToolMC"))
inventoryTool = toolArea.addTool("InventoryToolMC");
trace(inventoryTool);

And the first trace will show a movieclip path and the second undefined.

If i do

var inventoryTool:Object = toolArea.addTool("InventoryToolMC");
trace(inventoryTool);

it works fantastically.

So what gives? I can only access a reference to the returned tool clip
in a local var and not a class var? What could cause this? I look at my
script and i've done things like it a thousand times over, and i've
never seen anything like this.

Here's hoping i'm merely stupid.

- Andreas
_______________________________________________
Flashcoders@chattyfig.figleaf.com
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

_______________________________________________
Flashcoders@chattyfig.figleaf.com
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



--

- Andreas Rønning

---------------------------------------
Flash guy
Rayon Visual Concepts, Oslo, Norway
---------------------------------------
_______________________________________________
Flashcoders@chattyfig.figleaf.com
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