# An ActionScript 2.0 questions.



## test84 (Jul 6, 2008)

Hi,
I used tiles for my platform game and they are placed on different depths.
I wanted to have my HUD (like score and lives) on a different layer so I could move them around with mouse and dont mess with AttachTextField's properties like x and y when I can't actually see them.

But even if I drag the layer over my script layer, its still overrides it and shows the depths.

So I wanted to someway access that Layer that I make with Flash's Interface New Layer icon (not programitacally, just by clicking on new layer in timeline) and then move them to like depth of 13000 so it will be over everything.


----------



## Psyfira (Jul 6, 2008)

test84 said:
			
		

> But even if I drag the layer over my script layer, its still overrides it and shows the depths.


I'm a little confused by what you mean here, are you saying the layers don't appear in the movie in the same order they are in the .fla file?


----------



## CockroachMan (Jul 6, 2008)

You want to attach movies dynamically on your file, but keeping them under some static movies that you already have.. is that it?

Clips attached by attachMovie will be always over everything you have on stage, doesn't matter what layer are them. 

I suggest you to create a movie clip for your game and a different movie clip, on a higher layer, for the HUD. Them attach stuff to the game movie clip, instead of using _root.


----------



## test84 (Jul 8, 2008)

I wanted to have my UI arranged by mouse, not by assigning X and Y by code and thus wanted to have a Layer and put/arrange my UI there.

My game (based on TonyPaa's tutorial) is made of tiles that I place at runtime on screen and at this point I'm adding HUD (Heads Up Display, to show score or lives of player) but instead of adding game.HUD.attachTextField and mess with X and Y's that I dont actually see where they actually will be when I'm setting them and to escape from constantly trials and errors to find proper place for my HUD items, I thought why not use them Layers and add my everything there and just move depth of that Layer to be on top of everything.

I hope that clarifies.


----------



## CockroachMan (Jul 8, 2008)

So, you have a "game" clip where you attach your tiles right?
Create a separated "HUD" clip on a higher layer.. so you access through HUD.attachTextField


----------



## test84 (Jul 8, 2008)

Thats exactly what I did but that doesnt solve the problem of positioning HUD elements, I still have to use trial and error setting X and Y of HUD elements positioned, I was after ease of drag and drop which Flash UI gives you and just passing whatever you want to it.


----------



## Psyfira (Jul 8, 2008)

If it's a drag-and-drop text box you're after, it's on the text tool with the setting "dynamic text" (a text box which can be accessed by a script to change the contents, as long as you name each element so the script can access it). 

I'll confess I'm a complete beginner to Flash, so I might be way off here, but if I've understood the question properly then google for "dynamic text box", someone else probably explains it far better than I can


----------



## CockroachMan (Jul 8, 2008)

test84 said:
			
		

> Thats exactly what I did but that doesnt solve the problem of positioning HUD elements, I still have to use trial and error setting X and Y of HUD elements positioned, I was after ease of drag and drop which Flash UI gives you and just passing whatever you want to it.



Check the "localToGlobal" and "globalToLocal" functions to convert your x,y coordinates.. you're probably using local ones..


----------



## test84 (Jul 8, 2008)

Thank you both Psyfira and my favourite insect,

A-
@RochGuy: 
My problem is not with local X or global X, my problem is that I dont like to imagine what x=120 y=200 will be and try to see how bad/good it turned out, I want to drag around txtBoxes and set them to my game's variables, thats all doable the problem is I want to put all my HUD stuff in a seperate layer and put it on top of everything else, thats not doable since I can put my HUD stuff on a layer and its working but it will get buried under my game's tiles, so I have to change its depth to something like 20000 in order to have it on top of anything else, but I cant access layer's deptr.

I'm gonna stick with my game.HUD mode, which I dont like

Someone somewhere else answered someone's question that layers are nothing but some depth that flash is wrapping in Layers, I think thats why I cant find proper methods for it.

------------------
B-
Another question.

I'm blinking my character at certain condition and as I investigated, the best solution around is using setInterval and clearInterval but as far as I read, most if not all's solution for clearInterval's ID number was to make it public in the form.

That solution is working but I was after a better one (since global variables is obsolete and will/would cause problem when your program is increasing in size AND ) so I made this topic to ask about other's opinions about a better solution for dealing with the scope of number needed in clearInterval.


Another reason is that I'm having my enemies killed by a fading animation which I
use and I need to keep track of setInterval ID's properly for them too.


----------



## jeklnoo (Jul 8, 2008)

if you want to do animations via code (fading, moving, rotating, etc) you need some kind of 'Tween' library. I think there's one built in by macromedia, but it's pretty inefficient. Here's a pretty decent one, but there are tons of them: http://blog.greensock.com/tweenliteas2/


----------



## test84 (Jul 9, 2008)

thnx,
If you are answering my B question, actually the problem is in scope of IntervalID's.

I think the best solution is to add the ID to each object and access it via that whenever needed.


----------

