Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Drawing On Top Of Display Object



Hi all!

I want to draw lines on top of a display object using the Graphics class.
In the lineTo() documentation it says:

"If the display object in which you are drawing contains content that was created with the Flash drawing tools, calls to the lineTo() method are drawn underneath the content."

I get the same effect when I draw the object with action script.
So my question is, whether is a way to work around this and draw on top of
a display object (a rectangle for example)?

Thanks in advance!
Joost



ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 10-01-2007, 12:23 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Drawing On Top Of A Display Object
Hi all!

I want to draw lines on top of a display object using the Graphics class.
In the lineTo() documentation it says:

"If the display object in which you are drawing contains content that was created with the Flash drawing tools, calls to the lineTo() method are drawn underneath the content."

I get the same effect when I draw the object with action script.
So my question is, whether is a way to work around this and draw on top of
a display object (a rectangle for example)?

Thanks in advance!
Joost

Drawing An Outline Of An Object In Flash And Then Animating The Drawing?
I wish to draw an outline of an object in flash? bit by bit a piece of the outline is drawn until the outline is completed, once this has finished then object then appears and the outline disppears (this part I can manage).

I do not know where to begin? So may need a lot of direction on this one.

Test If A Display Object Has Been Added To The Display List
Is there any way to test if a display object has been added to the display list?

Can't Display Drawing Circle
I try to display a simple circle in the stage but it doesn't work.

Here's the code:

package {

import flash.display.Sprite;
import flash.display.Shape;

public class circles extends Sprite {

public function circles() {

var green:Shape = _createCircle(0x00FF00, 10);
green.x = 25;
green.y = 25;

addChild(green);
}


private function _createCircle(color: uint, radius: int):Shape {
var circle:Shape = new Shape();
circle.graphics.beginFill(color);
circle.graphics.drawCircle(0, 0, radius);
circle.graphics.endFill();
return circle;
}
}
}



What's wrong with the code?

[F8] Flash Object To Display On Top Of An Activex Object
I’m having a problem getting a flash object (menu) to display on top of an activex object. Any ideas?

Display Animated Drawing Lines With Random Direction
What I'm wanting to try and create is a line with a random starting point (within a certain area) and have it set off in a random direction (but keeping it either going vertical or horizontal), then have it change direction at a random interval, but still keep it either vertical or horizontal.

So this is what I've got so far:

var currentX:Number = Math.round.random(200);
var currentY:Number = Math.round.random(200);

function drawLine1(Void):Void{
var lineMC:MovieClip = _root["line"+currentLine];
line1.lineStyle(1,0x000000,100);
line1.moveTo(currentX, currentY);
line1.lineTo(++currentX, currentY);
theTime = random(30);
theTime--;
trace(theTime);
if (theTime > 1){
drawLine2;
}
}


I'm trying to give it a random starting point, and a random straight vertical or straight horizontal destination, and then when the countdown timer reaches to 1 (after starting at a random number from 1-30), it will drawLine2, which will set it in a different direction.

I would've pursued different methods of obtaining this effect, but the randomness is very important to me. I would ultimately like the end of the line to fade out as the line grows, but i'll tackle this one problem at a time.

I've searched through pages and pages of tutorials and haven't found anything useful, so I'm now asking for help. I also greatly appreciate any time and/or effort spent on this. Thanks!

Cant Tell When Merge Drawing Model Vs. Object Drawing Model
I keep drawing shapes on the same layer, overlapping them, and then trying to delete one of the shapes to cut a shape out of the first. This does not work automatically as Help says it does, I have to go to "Modify > Combine Objects > Union" to merge them, THEN I can cut my shape out. When is this supposed to occur "automatically"? How am I supposed to know what mode I'm in?

Cant Tell When Merge Drawing Model Vs. Object Drawing Model
I keep drawing shapes on the same layer, overlapping them, and then trying to
delete one of the shapes to cut a shape out of the first. This does not work
automatically as Help says it does, I have to go to "Modify > Combine Objects >
Union" to merge them, THEN I can cut my shape out. When is this supposed to
occur "automatically"? How am I supposed to know what mode I'm in?

Object Drawing Model / Merge Drawing Model
Recently I reinstalled Macromedia Flash 8, but then it was installed with the "Merge Drawing Model" instead of the "Object Drawing Model". How do I change this?

I've tried to read this, but it doesn't say exactly what to do;

http://livedocs.adobe.com/flash/8/ma...=00000486.html

Thanks

-JPAG

Drawing Object...
i intend to do a drawing object that i can draw a line, circle and erase my drawing.
My "line" button cannot work.
Let's say if i click "line" button, i drag my mouse then the line will appear follow my drag cursor.
If i click the "oval" button,i drag my mouse on stage .A oval will appear.
Anyonw who know pls help...
thankx

Drawing Object
Just wondering why .... when I draw a simple rectangle object it seems to automatically turn into a symbol-like object. IE, I have to click into it to edit it. This doesn't happen for me at work.. just at home. same flash version. ????

thanks

Drawing Object - Help
Ok - this is really daft .. Every time I create a shape, it becomes a 'drawing object' with a MC like blue lined box around it ... Unlike the default 'boxless' shapes ... What on earth I have clicked to make this start happening?! I don't want it - AND I want to know how to make drawing a shape just like Normal!

...please

Drawing Object
Can anyone tell me why I can not get the DRAWING OBJECT box to show. I want to adjust the size of a retangle box that I have drawn. WHen I watch Lee draw a box using the rectangle tool, the drawing object box appears in the property inspector with a box for height and one for width. When I draw a rectangle using the same rectangle tool I don't get a box to adjust the box size. When I draw a rectangle I see "properties" "parameters" and "filters" and underneath I see only the words "rectangle tool" If I double click the rectangle I get a cross hatch pattern then I can adjust size but I can not move the newly sized rectangle anywhere. ANy Ideas?? anyone?? THanks in advance !

Alyn

Object Drawing
I don't get 'object drawing' I know it has to do with grouping.. But why not just use the normal shape option why use 'object drawing' with it ? what purpose does it serve ?

Drawing Lines With Another Object
Hi!

I've managed to get a small grey ball to move around the screen in a certain way but I'd like it to draw a permanent line behind it as goes, any ideas how i'd do this?

Many thanks, Hannah

Can't Move A Drawing Object
Code:
this.createEmptyMovieClip("triangle_mc", 1);
triangle_mc.beginFill(0x0000FF, 30);
triangle_mc.lineStyle(5, 0xFF00FF, 100);
triangle_mc.moveTo(200, 200);
triangle_mc.lineTo(300, 300);
triangle_mc.lineTo(100, 300);
triangle_mc.lineTo(200, 200);
triangle_mc.endFill();

triangle_mc._x=50;
I have a problem! I can't move the mclip triangle_mc to the x=50 coordonate. Please help me!

Drawing Object Mode
I draw two ovals on stage, and I double click on one of the ovals and it
brings me to Drawing Object mode. I did not make this into a symbol, so
I am confused as to where I am? Is this still part of the stage, or will
changes made here not affect what is on my stage?

Thanks!

Simulate Drawing And Object
I'd like to make an object look like it is being drawn as part of the flash animation. Like say i have a square. I want to make it look like it is being drawn from upper left corner to lower left to lower right to upper right back to upper left. I'm not even sure if I am describing the correctly.

Jason

Settings Changed, Everything Becomes A Drawing Object
I just open flash today and make a Circle, an noticed that everything that I put on the artboard is changed to a Drawing Object by default so I have to either break it apart or double click everything before I can edit. Now I didnt change this setting so I have no idea where this setting can be found or how to reverse it
Anyone here know?

Thanks in Advance

Mark Hollas

Object Drawing Mode Question
Hi, Im using flash 8 but my 'object drawing mode' button has disappeared from the 'options' panel in the tool bar. when i select a drawing tool (oval or rectangle'. It was there yesterday but now its gone. Its currently set to object drawing mode on but I want to turn it off as I think this is what I need to be able to draw with the line tool and have the lines connected together. Please help!!

Allways Creating 'Drawing Object'...
Hi there.

When I'm drawing in flash, it allways creates a "Drawing Object" out of the lines. This is really annoying, and I have probably just activated it by accidentally hitting the hotkey for it.

Anybody who knows how to turn it off?

Thanks

Updating Part Of A Drawing Object?
I'm creating a project where I'm dynamically placing a number of movie clips on the stage, getting information from an XML file about which other MCs they are related to, and drawing lines connecting the MCs that are related to one another.

That part is working fine. What I want to do now is I am animating the MCs so that they move a certain amount onEnterFrame. I want to update the connecting lines as the MCs move, but since I am moving them individually, I need to update the connectors one by one. I can't figure out how to only clear the lines that are drawn from the MC that is currently being moved. If I clear the whole canvas, you only see one line being updated.

I hope this makes sense. Is what I'm trying to do possible, and if not, is there another approach I can use?

Thanks!

Disable Drawings Put Into A Drawing Object
hello

in Flash CS3, when you draw anything it automatically puts this into a drawing object which is just stupidly annoying. how do i disable this???

Anyone know??

Thanks

Capturing Drawing As A Shared Object
I am trying to create an online interactive whiteboard application and I have been following the tutorial found at:

http://www.macromedia.com/devnet/mx/...hiteboard.html

I am able to capture lines using starting and ending points as illustrated in the tutorial "drawing with lines", but I need to capture the freehand, like the one on page 4 of the tutorial "drawing with segments":

http://www.macromedia.com/devnet/mx/...teboard_4.html

Is there a way to continuously create starting and ending points, so that the complete drawing is shown istantaneously?

Any help is greatly appreciated.

Thanks

Converting A Shape Into A CS3 Drawing Object
Hello!

I've noticed that when I draw, say a square, in CS3, it becomes a "Drawing object" (like a symbol that doesn't appear in the library), instead of a pure shape like in Flash 8.

But let's say I break a drawing object down into a shape, how do I convert this shape back into a drawing object?

I like drawing objects, they're cool for simple shapes that I don't want in my library, and that I don't want to get distorted like pure shapes (despite being placed at integer positions) particularly in large documents.

Anybody know?

Thanks,
Kyrre

Converting A Shape Into A CS3 Drawing Object
Hello!

I've noticed that when I draw, say a square, in CS3, it becomes a "Drawing object" (like a symbol that doesn't appear in the library), instead of a pure shape like in Flash 8.

But let's say I break a drawing object down into a shape, how do I convert this shape back into a drawing object?

I like drawing objects, they're cool for simple shapes that I don't want in my library, and that I don't want to get distorted like pure shapes (despite being placed at integer positions) particularly in large documents.

Anybody know?

Thanks,
Kyrre

[CS3] Make Button From Drawing Object Group
I have used adobe illustrator to create a vector graphic which is the word "CATALOGUE DOWNLOAD" as I can only get the style I want in illustrator.

I then paste this into Flash CS3 and try to make it a button by doing the following:

- I make a square button over the text with alpha value 0% - this is to stop every character from being a separate part of the button. This works.

- Problem is I want to have an underline as the hover over for the button - Everytime I try and do this, I run the SWF and it never appears. The see through square is making the underline invisible also.

Please suggest how I would tackle this.

Thanks anyone

Drawing Colored Lines Using The Graphics Object
Mornin,

Trying to draw lines dynamically and having difficulty adding color to the lines. The code works fine except for the two lines with <---????? commented after them. They do not produce errors but I was hoping that they would cause the line that I was drawing to be color = 8 instead of black.

thanks!


ActionScript Code:
// First we declare our movieclip object, this is kind of a container for our drawing,
// and we define how to refer to it (my_line).
var my_line:MovieClip = new MovieClip();
           
// here we attach our line movieclip to the main stage using the addChild
addChild(my_line);
           
// Now we give our line some properties, this is just to tell flash that we want our line thickness to be 4
my_line.graphics.lineStyle(4);

//-------------------
//This is the part that I am unsure about I need to set the color of the line
//here but is this the correct method?  I know not
my_line.graphics.beginFill(8); //<--------?????
            
// Here is another property, here we define the first starting point of the first line, (x and y axis)
my_line.graphics.moveTo(5,5);
            
            
//Draw the line
my_line.graphics.lineTo(60, 90);
           

//-------
//Unsure about this too
my_line.graphics.endFill(); <--?????

Why Doesn't Object Drawing Mode Stay On?
Even when I draw shapes using Object Drawing and leave it turned on, some shapes will randomly act as though I'm using Merge mode. For example, if I marquee-select several shapes on a layer and apply a shape tween, some of the objects will become split where I dragged the marquee box and the parts will do their own, separate tweens.

Am I doing something wrong or is this just another quirk?

Getting The Display Object
i have canvas and the child of canvas is display object. when i resize the canvas ,the display object doesnt get resize.so how to do??
Tell me how to get that display object also??? help me out.

About Display Object
Hello all ,I can't find the relationship of display object hierarchy with the structure of flash authoring objects.for example what is the correspondent object of the main time line on flash authoring tool in the display object hierarchy?or what is the correspondent object of the scene that we see on the authoring tool in display object hierarchy?
Sincerely yours Mohsena

About Display Object
Hello all ,I can't find the relationship of display object hierarchy with the structure of flash authoring objects.for example what is the correspondent object of the main time line on flash authoring tool in the display object hierarchy?or what is the correspondent object of the scene that we see on the authoring tool in display object hierarchy?
Sincerely yours Mohsena

Video Display Object
when executing the following code i get this Error:

Code:
1061: Call to a possibly undefined method attachNetStream through a reference with static type Video.
i am missing some thing obvious.. the class:
thank you for your time.


Code:
package {
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.Video;
import flash.display.MovieClip;

public class Video extends MovieClip {

private var nc:NetConnection;
private var ns:NetStream;
private var vid:Video;

public function Video() :void{

nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
vid = new Video();
addChild(vid);
vid.x = 100;
vid.y = 100;
vid.height = 50;
vid.width = 50;
vid.attachNetStream(ns);
ns.play("baby.flv");




}

}

}

Display Object Problem
Hey Flash community,

I'm coding a new company website and I'm having a few issues that I can't wrap my head around. The main issue is when the index page loads one of the words within the boxes doesn't show up but the other 3 do. But it shows up after you scroll over it. It should load initially. Here is the site address:

http://www.jstokes.com/jsa

Leave feedback and comments. Let me know if there are other issues anyone sees. This is all actionscript3.

Display Object Issue
Hi All
I have a menu of buttons. when a button is pressed it loads a image. I have created a image container sprite. when the loader loads the image I add the image to that container using addChildAt in theory if I understand correct each new image should replace the previous since there being loaded into the same level but it does not happen. my code is like this.


ActionScript Code:
//outside of button
var container:Sprite=new Sprite  ;

//code in button
var _loader:Loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);
            var request:URLRequest=new URLRequest("images/thumb/"+imgUrl);
_loader.load(request);

container.addChildAt(_loader,0);

//also tried
var imgHolder:Sprite=new Sprite  ;
imgHolder.addChild(_loader);
container.addChildAt(imgHolder,0);

all I want is to be able to replace the image with the new one and not keep stacking them. In AS2 I would have just loaded the image into a movieClip or the same level and they would have replaced.

Lost Please help

thanx dave

Replace Display Object
Hello,

I've been having this problem for awhile and can't figure out an acceptable solution.

I have a MovieClip, I then assign it a display object and then add it to a displaylist. But if I want to change the graphic I can't simply reassign it. In the following code I assign the movieclip a movieclip from the library and add it to the display list, then I try and change the graphic, but the circle stays on screen even though it is now a square.


Code:
var movieClip:MovieClip = new MovieClip()

movieClip = new Circle();

addChild(movieClip);

movieClip = new Square();
One way I've found to get around this is to remove the movieclip from the displaylist, reassign it, then re add it to the displaylist. This works, but then I have to reposition the movieclip again.

Does anyone know of a simple way to swap the graphics?

Thanks

Display Object Problems ...
Hi - I've done a bunch of searching and googling on this, but I can't figure it out. I want to remove the clip on the the stage when the new one is added. mySprite was the holder. It works the first time, but after that .... I get the

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at MethodInfo-1() error --

and I can't track it down.


Code:

// these are buttons //
CanopyAds.addEventListener(MouseEvent.CLICK, CanopyListener);
GovCircle.addEventListener(MouseEvent.CLICK, GovListener)


function CanopyListener(event:MouseEvent):void {

if(welcomeMC) {
removeChild(welcomeMC) }
if(mySprite) {
removeChild(mySprite); }

var canopyPI = new PortfolioItem();

canopyPI.setText("This is some text.")
addChild(canopyPI);

addChild(mySprite);
mySprite.addChild(canopyPI);


}


function GovListener(event:MouseEvent):void {

if(welcomeMC) {
removeChild(welcomeMC) }

if(mySprite) {
removeChild(mySprite); }

var gcPI = new PortfolioItem();
gcPI.setText("This is some different text")

addChild(mySprite);
mySprite.addChild(gcPI);

}
eventually i'll put this into a function/class so i'm not repeating the code, but right now I'm just trying to get it to work right.

thanks in advance!

Path Of A Display Object
I'll start with an AS2 analogy. In as2, a trace of an object will display not only its name, but also its absolute path from _root. Is there an equivalence in as3? I have tried describeType, and getQualifiedClassName. It's really helpful to know where you are when adding and removing child.

Sound Object Display Time?
Say I'm loading mp3's dynamically with the sound object. I'd like to be able to show total time of the song, and time elapsed. _totalframes and _currentframe don't seem to work on the sound object, so what should I do?

Display Tooltip Over A Flashmovie Object
Hi,
I have a flash menu on the left site of the screen which basically are icons only. The movie is very narrow (only 50 pixels wide), so there is not enough room to display text also in there. My problem is that I want a tooltip to appear when doing a mouseover over one of these icons.

I tried using layers, but they seem to dissapear under the flashmovie itself, as well as other flash elements on the webpage.

Since within the flash movie this can't be done, I am looking for a solution whereby a tooltip appears over the flashmovie.

Help very appreciated.

Kind regards
Patrick

Display Whats In An Unknown Object
Hi

Lets say i have an object returned from a function called retObject.

I dont know what variables are in this object, how can i use actionscript to tell me what variables i can access in that object?

Designing An Interface For A Display Object
I'm working on a series of classes that each distort an input image using a series of parameters. Each class is a Sprite that contains the distorted version of the input image.

I have the parameters defined in an interface that I plan to implement in each class. How can I include in the interface the fact that each implementation should extend Sprite?

I suppose that I could use a getter that returns a Sprite, but it would be nice if the classes themselves could be added to the display list.

Accessing Object In The Display List
I'm trying to add a tween event to external images that I load.
The images load just fine and the tween action work.
However the tween only works on the last item loaded.

when i trace my display list it lokk like this
[object MainTimeline] root1
[object MovieClip] level1
[object Loader] temp1
[object Loader] temp2
[object Loader] temp3
[object Loader] tempt1
[object Loader] tempt2
[object Loader] tempt3

As you can see i have named my loader instances.

how do i reference the individual images loaded by the same object loader
the tween ask for object as the first parameter.

any help would be appreciated

thanks

Display Order OR Target Through Object?
I am encountering a hassle that seems to beg a couple of solution types.

I am working on an inventory system where the user can drag various icons around a grid. One feature is that if the user drops an item on top of another item- the dropped on item would become attached to the mouse pointer. This works- sort of.

My problem is that if the object on the mouse pointer is higher in Z than the object it is over- the ocluded object doesn't recognize the mouse event.

My first glance at controlling Z looks like a major hassle! Everything on my screen has a position in Z, or the display list- whatever. Can I really not say objectName.z = 5; or whatever??? If I could do this I could just drop the Z of the object when it gets picked up and bump it back up when it is dropped. This would allow it to be under the other icons while on the mouse.

OR

Is there a way to let the mouse event penetrate to all layers of Z? Like, be able to click through an object?

Thanks,
T

Trying To Move Display Object Using 'while' Loop
I'm trying to write a simple title screen sequence that will play at the beginning of a simple game I'm writing.

I have a class called NumberTile2 (a square, basically, with a number in it).

I want to place one of these tiles near the top of the stage and have it slowly descend to the bottom of the stage. (Eventually I'll want several of these appearing and falling to the bottom one after the other but for the moment, to demonstrate the problem I'm having, I'm keeping it to just one tile).

I'm using an event listener which moves the tile down one pixel every frame, and a while loop which keeps running all the time the tile has not yet reached its final resting place.

I'm sure this is not the most elegant way of doing things but I'm interested in finding out why it doesn't work. It's obviously highlighting something fundamental that I'm not understanding about how Flash works.

When I test the movie I get Error 1502: A script has executed for longer than the default timeout period of 15 seconds. Behind that, I get a tile moving down the stage but never stopping and disappearing off the bottom(?!)

If anybody can tell me where I'm going wrong I'd be very grateful.
Thank You for reading this.

Here's my code:

Code:
package
{
import flash.display.*;
import flash.events.*;

public class TitleScreen2 extends MovieClip
{
var nextTile:NumberTile2; // the tile we're currently putting in place
var tilePlaced:Boolean; // flag that tells us when tile has reached the bottom

public function TitleScreen2(container:DisplayObjectContainer) // constructor
{
// create a new tile and place it near the top of the stage
nextTile = new NumberTile2();
nextTile.x = 25;
nextTile.y = 25;
container.addChild(nextTile);

// add event listener which will move tile down each frame
nextTile.addEventListener(Event.ENTER_FRAME, moveDown);
// put tile in place
placeNextTile();

} // end constructor

private function placeNextTile()
{
tilePlaced = false;
while(tilePlaced==false)
{
if(nextTile.y == 150) // if tile is now in place
{
nextTile.removeEventListener(Event.ENTER_FRAME, moveDown); // remove event listener for this tile
tilePlaced = true; // set flag equal to true
}
} // end while
} // end placeNextTile

private function moveDown(e:Event)
{
// move tile down 1 pixel
nextTile.y += 1;
} // end moveDown

} // end class
} // end package

Inaccurate Clicking Of A Display Object
I'm a relative noob to Flash, making the transition from OOP in C#.

A few days ago I posted about a problem I was having with clicking on display objects in a simple game I'm writing. Someone suggested I post the application so that people could check it for me and I said I'd try to reproduce the problem in something simpler.

In my library I have a simple display object called NumberTile4 (a coloured square with a stroke) stored as a MovieClip.

I have a .fla file containing nothing but that object in the library. The .fla file has a document class of gridTest.

The gridTest class puts a 5x5 grid of NumberTile4's on the stage.

I have an event listener set up so that when I click on one of the tiles, it's removed from the stage and those tiles above it, in the same column, are all moved down one space.

That seems to work exactly as I want it to.

The fun starts when in my NumberTile4 constructor I add a text field to the tile.

Back in gridTest, when the tiles are created I set that text field to display a separate number in each tile.

This time, when I click on a tile, it is removed from the stage, and the tiles above it move down, as expected, except if I click on the tile near to the text field (which is at 0,0 on each tile) in which case a tile in the column to the left is removed???

I also find that I can click to the right of a tile - on what should be a blank part of the stage - and tiles are still being removed, and the other tiles are moving down. Weird.

It seems that somehow the addition of the text fields is messing with the accuracy of my mouse clicks.

Like I say, if I don't add the text fields, no problems. But with them, something strange is happening when I click on or near to a tile.

If anybody can throw any light on this, I'd really appreciate it.

Thank You for reading this.

Here is my gridTest class:


Code:
package
{
import flash.display.*;
import flash.events.*;
import flash.text.*;

public class gridTest extends MovieClip
{
var i,j:uint; // loop variables
var myTile:NumberTile4;
var tiles:Array = new Array(5);

public function gridTest() // constructor
{
for(i=0; i<25; i++)
{
myTile = new NumberTile4; // create a new number tile
tiles[i] = myTile; // add tile to the tiles array
myTile.tag = i; // give the tile a tag
myTile.x = 30 + 80*(i%5); // set co-ordinates for this tile
myTile.y = 30 + 80*Math.floor(i/5);
myTile.addEventListener(MouseEvent.CLICK, handleMouseClick);
addChild(myTile); // add tile to display list

// if I uncomment the three lines in the NumberTile4 constructor
// plus the following line, problems occur
// myTile.tileLabel.text = i.toString(); // write a label for the tile

} // end for

} // end constructor

private function handleMouseClick(e:Event)
{
var clickedTile:NumberTile4 = e.currentTarget as NumberTile4;

// remove tile from display list
removeChild(clickedTile);

for each(var tile in tiles) // move down tiles above this one in the same column
{
if((tile.x == clickedTile.x) && (tile.y < clickedTile.y))
{
tile.y += 80;
} // end if
} // end for
} // end handleMouseClick

} // end class
} //end package
And this is my NumberTile4 class (linked to my library MovieClip)


Code:
package
{
import flash.display.*;
import flash.text.*;

public class NumberTile4 extends MovieClip
{
var tileLabel:TextField; // the label carried by this tile
var value:int; // the value to be displayed by this tile
var tag:uint;

public function NumberTile4() // constructor
{
// if I un-comment the following three lines, problems occur
//tileLabel = new TextField();
//tileLabel.selectable = false;
//this.addChild(tileLabel);
} // end constructor

} // end class
} // end package

Traversing And Refencing Display Object
Hi,

I'm having some confusing trouble with the Display list. Hopefully someone cna help me out and teach me a thing or 2

Basically what I'm trying to do is reference an instance of a movie clip in from an external class.

Here is the code that Im using to attach 2 movieClips. These are the clips that I want to reference later


ActionScript Code:
// create 2 clip Holder MovieClips And attach them to the stage
        public function buildClipTrackHolders(){
            var clipTrackHolderClass:Object = getDefinitionByName("clipHolder") as Class;
            clipHolderA=new clipTrackHolderClass();
            clipHolderA.x=0;
            clipHolderA.y=50;
            clipHolderB=new clipTrackHolderClass();
            clipHolderB.x=200;
            clipHolderB.y=50;
           
            addChild(clipHolderA);
            addChild(clipHolderB);
           
           
            }


After that I make an instance of my external class and pass a reference to the stage to it (not sure if thats a good way to go about it??)


ActionScript Code:
var clip:Clip=new Clip(obj,this.stage)


Then inside this "clip" class I want to be able to reference the 2 movieClips that I attached previously. Here is the code of the "clip" class (the part I am having trouble with)


ActionScript Code:
package {
    import flash.events.*;
    import flash.display.*;
    import flash.text.*;
    import flash.utils.getDefinitionByName;

    public class Clip extends MovieClip {

        private var cName:String;
        private var clipData:Object;
        private var target;
        private var defaultClipWidth:int=200;
        private var defaultClipHeight:int=50;
        private var xPosition:Number;
        private var yScale:Number;
        private var clipBox:MovieClip;
        private var clipHolder:MovieClip;


        public function Clip(c,target:Stage) {
            this.clipData=c;
            var clipBoxClass:Object = getDefinitionByName("clipBox_mc") as Class;
            clipBox=new clipBoxClass();
            clipBox.info.text=(clipData.Name);
            findTrackHolder();

        }
        //HERE is where I want to get a reference of the MovieClips I attached
        public function findTrackHolder() {

            if (clipData.ID==0) {
                this.clipHolder=DisplayObjectContainer(target).clipHolderA;

            }
            if (clipData.ID==1) {
                this.clipHolder=DisplayObjectContainer(target).clipHolderB;

            }
        }
    }
}

The error that I get is



ActionScript Code:
1119: Access of possibly undefined property clipHolderA through a reference with static type flash.display:DisplayObjectContainer.

So basically I have a movieClip attached to the stage named "clipHolderA" and I want to be able to reference it from a class.

Any pointers, help, education is much appreciated!

Dynamically Know What Display Object You Hit Test
Hi,

I have a bit of a hit test puzzle.

In my main movie I have 2 movie clips A and B.

Both A and B have movieClips inside them of type "clip"(defined by me).

Also in my main movie I have a bar movieClip that scrolls vertically through my movie.

Im trying to find a way to get the "bar" movie clip to tell me when it hits a movie clip of type "clip" that is inside either A or B.

Any ideas at all?

I Want To Find An Object In The Display List?
Is there an easy way to find an object in the display list without looping and looking at each object?

Copyright © 2005-08 www.BigResource.com, All rights reserved