# Get access to a stored Sprite in a array

**URL:** <https://forum.kirupa.com/t/get-access-to-a-stored-sprite-in-a-array/264970>\
**Category:** Uncategorized\
**Created:** [July 2, 2008, 5:06pm UTC](https://forum.kirupa.com/t/get-access-to-a-stored-sprite-in-a-array/264970 "2008-07-02T17:06:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pensamente](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/pensamente/32/1208_2.png) [@pensamente](https://forum.kirupa.com/u/pensamente)\
**Post date:** [July 2, 2008, 5:06pm UTC](https://forum.kirupa.com/t/get-access-to-a-stored-sprite-in-a-array/264970/1 "2008-07-02T17:06:54Z")

</div>

i’m not getting how to do this, I create a sprite and then store it’s refence in a array, what I want is to use that refence to call it later… but really don’t know what’s wrong…

here’s the code:  
[AS]// place a moviclip on stage with instance name of: “container”

var storeGraf:Array = new Array();

// draw something in a sprite  
var target1:Sprite = new Sprite();  
target1.graphics.beginFill(0xCCFF00);  
target1.graphics.drawRect(0, 0, 100, 100);  
target1.name = “target1”;

storeGraf[0] = target1 as Sprite;

container.addChild(target1);

[//container.getChildByName](https://container.getChildByName)(‘target1’).alpha = .5;

container.storeGraf[0].alpha = .5;[/AS]

thanks

---

<div class="post-metadata">

**Author:** ![krilnon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/krilnon/32/34_2.png) [@krilnon](https://forum.kirupa.com/u/krilnon)\
**Post date:** [July 2, 2008, 5:41pm UTC](https://forum.kirupa.com/t/get-access-to-a-stored-sprite-in-a-array/264970/2 "2008-07-02T17:41:45Z")

</div>

You probably know this already, but using the line that is commented out would work.

You could also use:

```auto
storeGraf[0].alpha = .5;

```

_storeGraf_ isn’t a property of _container_, which is why you were getting errors before.

---

<div class="post-metadata">

**Author:** ![pensamente](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/pensamente/32/1208_2.png) [@pensamente](https://forum.kirupa.com/u/pensamente)\
**Post date:** [July 2, 2008, 9:23pm UTC](https://forum.kirupa.com/t/get-access-to-a-stored-sprite-in-a-array/264970/3 "2008-07-02T21:23:47Z")

</div>

hey krilnon! really thanks : )

I think I get it, if I store the sprite in the array it will be as simple as call it from the array no matter where the Sprite has been added in the display list?! I feel a bit of fog in my eyes…no?

this is different from the logic that i follow back in as2, if I would attach a movie clip inside another, store it’s name inside an array, then when calling this clip I would “build” up the path by the name of the container and then the name of the clip stored in the array… hummm migrations issues 😛

I’ve to clarify this questions… maybe some reading wouldn’t bad thought.

thanks

---

<div class="post-metadata">

**Author:** ![krilnon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/krilnon/32/34_2.png) [@krilnon](https://forum.kirupa.com/u/krilnon)\
**Post date:** [July 2, 2008, 9:43pm UTC](https://forum.kirupa.com/t/get-access-to-a-stored-sprite-in-a-array/264970/4 "2008-07-02T21:43:23Z")

</div>

> if I store the sprite in the array it will be as simple as call it from the array no matter where the Sprite has been added in the display list?!

Yep!

---

<div class="post-metadata">

**Author:** ![pensamente](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/pensamente/32/1208_2.png) [@pensamente](https://forum.kirupa.com/u/pensamente)\
**Post date:** [July 2, 2008, 10:09pm UTC](https://forum.kirupa.com/t/get-access-to-a-stored-sprite-in-a-array/264970/5 "2008-07-02T22:09:09Z")

</div>

this should be in the front page of adobe!  
the great things of as3 😃 heheh

ok! this will make life really easy, i’ll earn more money next month for sure 😛  
i have lack of basic knowledge about coding. :\
