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




Dynamically Creating Bitmap Objects / Depth Sorting



Can anyone offer me help on this little drawing API I am developing?I am trying to create a sort of spray paint / drippy marker effect. This part works fine. What I want to do is copy the vector drawing data to a bitmap object so the vector drawings don't slow down the processor. I am planning on having the lines you draw overlap video and several other vector and bitmap objects. I'm thinking it would be best to clear out the vector data. I can't seem to fine a way to layer the bitmap object redraw into depths, is this even possible?You need to uncomment this line for the bitmap drawing to take place (this line draws the vector drawing data into a bitmap object)://bmp.draw(_root["holder"+depth2]);And comment this line (this clears all the vector drawing away):_root["holder"+depth2].clear()Once the first line is uncommented it will draw over the art attached from the library, but on the second pass, everything in the bitmap object pops to the highest depth, over the attached art work. I want each individual paint stroke to stay on its own layer.You also need to create two movie clips in your library with the linkage "drip" and "test2". The drip is the drip movie clip (animated in my movie, a thin line), and the test2 is just a randomly attached movie clip (I have this is a 200x200px square).Any help would be awesome. I'm so lost and frustrated.Here is the code:
ActionScript Code:
Stage.align = "TL"Stage.scaleMode = "noScale"var bmp = new flash.display.BitmapData(Stage.width, Stage.height, true, 0x000000);//var bmpData:MovieClip = _root.createEmptyMovieClip("tmp", 99999);//bmpData.attachBitmap(bmp, 1);    var pts:Array;var isEditing:Boolean = false;var mouseListener:Object = new Object();var quality:Number = 0;var brushDia:Number=0;var particleDepth:Number=0;var seed:Number=0;var color=0x000000;var blur = new flash.filters.BlurFilter(2,2,2);artHolder1.setMask("mask1")artHolder2._xscale*=-1artHolder2._x=1000mouseListener.onMouseDown = function(){depth2=_root.getNextHighestDepth();var drawClip = _root.createEmptyMovieClip("holder"+depth2, depth2);//color=Math.random() * 0xffffff + 0xff000000brushDia=0;pts = new Array();isEditing = true;pts.push([_root["holder"+depth2]._xmouse,_root["holder"+depth2]._ymouse])_root["holder"+depth2].moveTo(_root["holder"+depth2]._xmouse, _root["holder"+depth2]._ymouse)var holder3:MovieClip = _root.createEmptyMovieClip("tmp", _root.getNextHighestDepth());holder3.attachBitmap(bmp, 1);}mouseListener.onMouseUp = function(){    //_root["holder"+depth2].clear()depth3=_root.getNextHighestDepth();_root.attachMovie("test2","art"+depth3, depth3);xpos=Math.random()*Stage.width/2ypos=Math.random()*Stage.height/2_root["art"+depth3]._x=xpos_root["art"+depth3]._y=yposisEditing = false;smooth()}mouseListener.onMouseMove = function(){    if(brushDia<=20) {        brushDia+=1    }_root["holder"+depth2].lineStyle(brushDia, color, 100);if(!isEditing) return;pts.push([_root["holder"+depth2]._xmouse,_root["holder"+depth2]._ymouse]) smooth() }function smooth(){if(!pts) returnvar i = pts.length-1;if(i < 1) return;var ptx = pts[i][0]var pty = pts[i][1]var ancx = pts[i-1][0]var ancy = pts[i-1][1]ptx += ancxpty += ancy_root["holder"+depth2].curveTo(ancx,ancy,ptx/2, pty/2);//bmp.draw(_root["holder"+depth2]);//bmp.applyFilter(bmp, bmp.rectangle, new flash.geom.Point(0,0), blur);seed=Math.random()*300if(seed<20 && brushDia >= 5) {    particleDepth++;    // attach drip particle    var part = _root["holder"+depth2].attachMovie("drip", "drip" + particleDepth, particleDepth);    // position to mouse    part._x = _xmouse;    part._y = _ymouse;}}Mouse.addListener(mouseListener)



ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 05-23-2007, 11:26 PM


View Complete Forum Thread with Replies

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

Depth Issue With Tooltips And Dynamically Placed Objects...
I have a set of dots I am placing on a map dynamically (using attachMovie) with an XML file giving the coordinates. I also am to assign a tooltip for each dot.

Problem:
When I rollover the dots, the tooltip appears fine, but it is under the dots, not at the highest level. I have the level set to getNextHighestDepth():


Quote:




captionFN = function (showTip, job, town, image) {
if (showTip) {
_root.createEmptyMovieClip("hoverCaption", _root.getNextHighestDepth());
cap.photoHolder.loadMovie(image)
cap.jobName.text = job;
cap.townName.text = town;
cap.alphaTo(100, .5);
...
...




and the dots are placed using this code:


Quote:




mapXML = new XML();
mapXML.ignoreWhite = true;
mapXML.onLoad = function(success) {
if (success) {
dots = this.firstChild.childNodes;
for (var i=0; i<dots.length; i++) {
dot = _root.attachMovie("mapDot", "mapDot" + i, i);
dot._alpha = 60;
dot._x = dots[i].attributes.xPos;
dot._y = dots[i].attributes.yPos;
...




Here is the example

Any ideas as to how to have the tooltip site on top of everything?

Thanks

Depth Issue With Tooltips And Dynamically Placed Objects...
I have a set of dots I am placing on a map dynamically (using attachMovie) with an XML file giving the coordinates. I also am using the "hover caption" tutorial (great) to assign a tooltip for each dot.

Problem:
When I rollover the dots, the tooltip appears fine, but it is under the dots, not at the highest level. I have the level set to getNextHighestDepth():


Quote:




captionFN = function (showTip, job, town, image) {
if (showTip) {
_root.createEmptyMovieClip("hoverCaption", _root.getNextHighestDepth());
cap.photoHolder.loadMovie(image)
cap.jobName.text = job;
cap.townName.text = town;
cap.alphaTo(100, .5);
...
...




and the dots are placed using this code:


Quote:




mapXML = new XML();
mapXML.ignoreWhite = true;
mapXML.onLoad = function(success) {
if (success) {
dots = this.firstChild.childNodes;
for (var i=0; i<dots.length; i++) {
dot = _root.attachMovie("mapDot", "mapDot" + i, i);
dot._alpha = 60;
dot._x = dots[i].attributes.xPos;
dot._y = dots[i].attributes.yPos;
...




Here is the example

Any ideas as to how to have the tooltip site on top of everything?

Thanks

Depth Issue With Dynamically Created Textboxes And Ungrouped/non-symbol Objects
wow that was a mouthful...
anyway...
im building a full as anything text-typing-component... easily modified and adapted etc...one problem however... (well at the moment there are several niggling little problems but hey! lol)
i came across a depth issue in testing.... its a little peculiar so you will have to bear with me...
i have 2 layers, called typer layer and plain layer... on the plain layer i have drawn out a shape... like a circle for instance....
if plain layer is on top of typer layer everything works fine.
if plain layer is below typer layer the typer does not type.... it doesnt even show up....
at present the dynamically created text field into which the typing text will be put into has a depth equivalent to that of a guide inside the component (just a plain mc used for determining sizes etc nothing special) +1 i added 1 to its current depth because if i dont i only seem to get EITHER the circle OR the typer.... whereas if i add 1, i get EITHER the typer AND the circle OR just the circle...
but this doesnt make sense does it? i mean if the typer layer is on top then it has a higher depth (ie. closer to zero as depths are currently in the negatives still ) so if i add 1 it shouldnt conflict with anything and i should get it typing and displaying the circle surely?
and if it is below then the circle has a higher depth so in this respect if the typer wouldnt work when it is on the bottom i could understand this as the depths would be conflicting and as such the dynamically created text field couldnt be created in the first place because the depth level is already occupied.... im not entirely sure if that would be true but regardless, the reverse is happening!

what is truly bamboozling me though is that if i convert the circle into a movieclip everything works fine even if they are on the same layer.... like it should....

can anybody help?

if you dont understand what im struggling to ask here, please ask and i will post the beta typer here and then walk you through the problem....

ANY help/input is welcome because i really am stumped....

Prophet.

Depth Issue With Dynamically Created Textboxes And Ungrouped/non-symbol Objects
wow that was a mouthful...
anyway...
im building a full as anything text-typing-component... easily modified and adapted etc...one problem however... (well at the moment there are several niggling little problems but hey! lol)
i came across a depth issue in testing.... its a little peculiar so you will have to bear with me...
i have 2 layers, called typer layer and plain layer... on the plain layer i have drawn out a shape... like a circle for instance....
if plain layer is on top of typer layer everything works fine.
if plain layer is below typer layer the typer does not type.... it doesnt even show up....
at present the dynamically created text field into which the typing text will be put into has a depth equivalent to that of a guide inside the component (just a plain mc used for determining sizes etc nothing special) +1 i added 1 to its current depth because if i dont i only seem to get EITHER the circle OR the typer.... whereas if i add 1, i get EITHER the typer AND the circle OR just the circle...
but this doesnt make sense does it? i mean if the typer layer is on top then it has a higher depth (ie. closer to zero as depths are currently in the negatives still ) so if i add 1 it shouldnt conflict with anything and i should get it typing and displaying the circle surely?
and if it is below then the circle has a higher depth so in this respect if the typer wouldnt work when it is on the bottom i could understand this as the depths would be conflicting and as such the dynamically created text field couldnt be created in the first place because the depth level is already occupied.... im not entirely sure if that would be true but regardless, the reverse is happening!

what is truly bamboozling me though is that if i convert the circle into a movieclip everything works fine even if they are on the same layer.... like it should....

can anybody help?

if you dont understand what im struggling to ask here, please ask and i will post the beta typer here and then walk you through the problem....

ANY help/input is welcome because i really am stumped....

Prophet.

Dynamically Creating Objects
I've got an AS2.0 class with a method in it that will dynamically create new objects.

The rub is that both the name of the object and the class that it instatiates changes over time, and I just need the syntax to make it happen.

I've got two variables:
arg_objName
arg_classToInstantiate

I'm trying to create an object as such:


Code:
var _root.["arg_objName"]:arg_classToInstantiate = new arg_classToInstantiate();
But, obviously, this code doesn't work. What is the proper syntax to get this to work?

Thanks!

Creating Objects In Array, Dynamically.
title says it all..

I have visited this topic before.... and built a small little "ranking' application..

however.. I wanted to go back and update the code.. its was built long ago, using flat text files...with EACH value its own variable.. (not even splitting up the string).... I want to move to XML based (easier to add 'players' as well as update data)..

however I am unclear on how to populate, add to the array then loop through all dynamically?

I guess my confusing comes into play when populating the object with NAME/PAIR values?

So I uess the regular overview question is:

1.) how do you populate an OBJECT using NAME/VALUE pairs?
just like:

object.name = value;

?? Which makes sense like normal..but what about looping and adding each object to the array?

do I create a new object each time? can I just reuse the same one? once I have pushed into the array/stack?

heres my OLD code: (ignore that it is a loadVar() object, I will be switching to XML so I can loop through the nodes and create as many objects)


Code:
var standings=new LoadVars();
//var aLibrary:Array = [];

var aLibrary:Array = [{teamNo:"team1", teamName:"THE CLOPS", coach:"clipclop", wins:10, losses:2, total:190, upsetW:2, upsetL:0, image:"logo3.jpg"}, {teamNo:"team2", teamName:"THE FORESKINZ", coach:"forenzic", wins:8, losses:1, total:130, upsetW:3, upsetL:1, image:"logo2.jpg"}, {teamNo:"team3", teamName:"THE FIXERS", coach:"fixter", wins:41, losses:5, total:50, upsetW:0, upsetL:2, image:"logo.jpg"}, {teamNo:"team3", teamName:"THE FIXERS", coach:"fixter", wins:41, losses:5, total:50, upsetW:0, upsetL:2, image:"logo.jpg"}, {teamNo:"team3", teamName:"THE FIXERS", coach:"fixter", wins:41, losses:5, total:50, upsetW:0, upsetL:2, image:"logo.jpg"}, {teamNo:"team3", teamName:"THE FIXERS", coach:"fixter", wins:41, losses:5, total:50, upsetW:0, upsetL:2, image:"logo.jpg"}, {teamNo:"team3", teamName:"THE FIXERS", coach:"fixter", wins:41, losses:5, total:50, upsetW:0, upsetL:2, image:"logo.jpg"}, {teamNo:"team3", teamName:"THE FIXERS", coach:"fixter", wins:41, losses:5, total:50, upsetW:0, upsetL:2, image:"logo.jpg"}, {teamNo:"team3", teamName:"THE FIXERS", coach:"fixter", wins:41, losses:5, total:50, upsetW:0, upsetL:2, image:"logo.jpg"}, {teamNo:"team3", teamName:"THE FIXERS", coach:"fixter", wins:41, losses:5, total:50, upsetW:0, upsetL:2, image:"logo.jpg"}];


standings.onLoad=function (ok){
if(ok){
//last update
_root.updateDate_txt.text = (this.updateDate);
//team names
_root.aLibrary[0].teamName = (this.team1_name);
_root.aLibrary[1].teamName = (this.team2_name);
_root.aLibrary[2].teamName = (this.team3_name);
_root.aLibrary[3].teamName = (this.team4_name);
_root.aLibrary[4].teamName = (this.team5_name);
_root.aLibrary[5].teamName = (this.team6_name);
_root.aLibrary[6].teamName = (this.team7_name);
_root.aLibrary[7].teamName = (this.team8_name);
_root.aLibrary[8].teamName = (this.team9_name);
_root.aLibrary[9].teamName = (this.team10_name);
//team coach
_root.aLibrary[0].coach = (this.team1_coach);
_root.aLibrary[1].coach = (this.team2_coach);
_root.aLibrary[2].coach = (this.team3_coach);
_root.aLibrary[3].coach = (this.team4_coach);
_root.aLibrary[4].coach = (this.team5_coach);
_root.aLibrary[5].coach = (this.team6_coach);
_root.aLibrary[6].coach = (this.team7_coach);
_root.aLibrary[7].coach = (this.team8_coach);
_root.aLibrary[8].coach = (this.team9_coach);
_root.aLibrary[9].coach = (this.team10_coach);
// team wins
_root.aLibrary[0].wins = (this.team1_wins);
_root.aLibrary[1].wins = Number(this.team2_wins);
_root.aLibrary[2].wins = Number(this.team3_wins);
_root.aLibrary[3].wins = Number(this.team4_wins);
_root.aLibrary[4].wins = Number(this.team5_wins);
_root.aLibrary[5].wins = Number(this.team6_wins);
_root.aLibrary[6].wins = Number(this.team7_wins);
_root.aLibrary[7].wins = Number(this.team8_wins);
_root.aLibrary[8].wins = Number(this.team9_wins);
_root.aLibrary[9].wins = Number(this.team10_wins);
//team losses
_root.aLibrary[0].losses = Number(this.team1_losses);
_root.aLibrary[1].losses = Number(this.team2_losses);
_root.aLibrary[2].losses = Number(this.team3_losses);
_root.aLibrary[3].losses = Number(this.team4_losses);
_root.aLibrary[4].losses = Number(this.team5_losses);
_root.aLibrary[5].losses = Number(this.team6_losses);
_root.aLibrary[6].losses = Number(this.team7_losses);
_root.aLibrary[7].losses = Number(this.team8_losses);
_root.aLibrary[8].losses = Number(this.team9_losses);
_root.aLibrary[9].losses = Number(this.team10_losses);
//team totals
_root.aLibrary[0].total = Number(this.team1_total);
_root.aLibrary[1].total = Number(this.team2_total);
_root.aLibrary[2].total = Number(this.team3_total);
_root.aLibrary[3].total = Number(this.team4_total);
_root.aLibrary[4].total = Number(this.team5_total);
_root.aLibrary[5].total = Number(this.team6_total);
_root.aLibrary[6].total = Number(this.team7_total);
_root.aLibrary[7].total = Number(this.team8_total);
_root.aLibrary[8].total = Number(this.team9_total);
_root.aLibrary[9].total = Number(this.team10_total);
//team upset wins
_root.aLibrary[0].upsetW = Number(this.team1_upsetW);
_root.aLibrary[1].upsetW = Number(this.team2_upsetW);
_root.aLibrary[2].upsetW = Number(this.team3_upsetW);
_root.aLibrary[3].upsetW = Number(this.team4_upsetW);
_root.aLibrary[4].upsetW = Number(this.team5_upsetW);
_root.aLibrary[5].upsetW = Number(this.team6_upsetW);
_root.aLibrary[6].upsetW = Number(this.team7_upsetW);
_root.aLibrary[7].upsetW = Number(this.team8_upsetW);
_root.aLibrary[8].upsetW = Number(this.team9_upsetW);
_root.aLibrary[9].upsetW = Number(this.team10_upsetW);
//team upset losses
_root.aLibrary[0].upsetL = Number(this.team1_upsetL);
_root.aLibrary[1].upsetL = Number(this.team2_upsetL);
_root.aLibrary[2].upsetL = Number(this.team3_upsetL);
_root.aLibrary[3].upsetL = Number(this.team4_upsetL);
_root.aLibrary[4].upsetL = Number(this.team5_upsetL);
_root.aLibrary[5].upsetL = Number(this.team6_upsetL);
_root.aLibrary[6].upsetL = Number(this.team7_upsetL);
_root.aLibrary[7].upsetL = Number(this.team8_upsetL);
_root.aLibrary[8].upsetL = Number(this.team9_upsetL);
_root.aLibrary[9].upsetL = Number(this.team10_upsetL);
//team logo
_root.aLibrary[0].image = (this.team1_logo);
_root.aLibrary[1].image = (this.team2_logo);
_root.aLibrary[2].image = (this.team3_logo);
_root.aLibrary[3].image = (this.team4_logo);
_root.aLibrary[4].image = (this.team5_logo);
_root.aLibrary[5].image = (this.team6_logo);
_root.aLibrary[6].image = (this.team7_logo);
_root.aLibrary[7].image = (this.team8_logo);
_root.aLibrary[8].image = (this.team9_logo);
_root.aLibrary[9].image = (this.team10_logo);
updateClips();
//sortDescendingWins();
}
}
//standings.load("standings.txt?"+random(9999));
standings.load("standings.txt");

function updateClips(){
//for(var j=0;j<aLibrary.length;j++) _root["team"+j].removeMovieClip();
for(var i=0;i<aLibrary.length;i++){
//var mc:MovieClip =_root.attachMovie(aLibrary[i].clip,"team"+i, this.getNextHighestDepth());
//var mc:MovieClip =_root.attachMovie("teamClip","team"+i, this.getNextHighestDepth());
var mc:MovieClip =_root.attachMovie("teamClip","team"+i, i+100);
mc.wins_txt.text = Number(aLibrary[i].wins);
mc.losses_txt.text = Number(aLibrary[i].losses);
mc.teamName_txt.html = true;
mc.teamName_txt.htmlText = "<b>"+aLibrary[i].teamName+"<b>";
mc.coachName_txt.text = aLibrary[i].coach;
mc.total_txt.text = Number(aLibrary[i].total);
mc.upsetW_txt.text = Number(aLibrary[i].upsetW);
mc.upsetL_txt.text = Number(aLibrary[i].upsetL);
mc.imageHolder_mc.loadMovie("teamImages/"+aLibrary[i].image);
var my_fmt:TextFormat = new TextFormat();
my_fmt.bold = true;
my_fmt.color = 0xC10000;
mc[_root.redField].setTextFormat(my_fmt);
//mc.imageVar = aLibrary[i].image;
mc._x = 25;
mc._y = 90;
mc._y += i*63;
}
}
..etc
..etc
..etc
the part in bold is what Im unclear about I suppose.. I can populate the object when I have hardcoded in the .fla (like above) and just replace the values....

but I want to be able to get rid of all that hard coding of the object array, and populate it once the xml loads by just decalring this empty array to begin with:

//var aLibrary:Array = [];

(am I making sense?)

thanks..

Dynamically Creating Moving Objects
Hi all i need so help writing a script.

Basically i am creating a shooting game an need to create movie clips from the library (i have five different objects i want to launch) and then randomly fall. They will also need to test for hits.

so far i have got this so work on one movie pulled onto the stage so that it falls the way i want it to:


Code:
//This gives object a randon x co-ordinate but at a constant y co-ordinate
onClipEvent (load) {
_x = random(400)+50;
_y = 0;
}
onClipEvent (enterFrame) {
//this move the object down by ten pixels each time and
//tells it to remove the movie clip when it goes of stage
this._y -= -10;
if (this._x<0 || this._x>Stage.width || this._y<0) {
this.removeMovieClip();
}

}
I am quite new to this and cant find any helpful working tutorials, i would be grateful for any help.

Cheers
Steve

Creating And Accessing Objects Dynamically
Hi,

I'm experiencing some serious AS2 to AS3 transition problems

I have a movieclip in the library that I place on stage using a custom class. It works fine by all means. The thing is that I want to create six instances (if that's the right word nowadays) that I want to access from other functions (one function is to animate all six instances). My problem is that I would expect all created objects to be accessible via their .name but they are not... Instead, the only way that I can access them is through the variable that I use to create the object instances (var myVariable:myClass = new myClass()). My problem then is that I don't want to predefine six variable names for this (the idea is to make something scalable) and that's when I really get lost. How on earth do I either 1) create dynamic variable names (i.e. "variable_"+i) or 2) access the created object instances on stage (that should be able to get to in one way or another...)?

Thanks a lot in advance.

.cristian

Dynamically Creating Symbols/objects
What I want to do is create a symbol with a set of properties, (x-position,y-position, name, etc.), with the ability to click them to goto another scene with more information. More specifically each symbol will be a star and when you click it it will bring you to a screen with that stars solar system.

Then place these symbols on screen, with pre-determined data from a database with xy corrdinates.

I know how to bring that data into flash, I just don't know where to start looking for information about I guess I would call it an array of objects that inherit the properties of the symbol/object.

Feel free to correct me on my terminology, im mainly a php programmer and some of this actionscript stuff is a bit alien to me.

Any help would be greatly appreciated.

[CS3] Depth Sorting
Hi, I've been having some trouble learning how to depth sort. Everything I seem to find is for AS 2 and not AS 3. I basically want to sort based on the mouse over event. What I have is a stage with grey rectangle on one layer, and AS on a second. When it runs, i want it to add pictures from an external file and then when the mouse goes over them, they come up to the top level.

i was also having trouble figuring out how to pass a variable to my swap position function, so i just made "j" global


var mcArray:Array = new Array();
var j:uint=0;

for(var i:uint=0; i<10; i++)
{
var myMC:MovieClip = new MovieClip();
if(i < 5 ){
myMC.x = i*50;
}
else
{
myMC.y = i*20;
myMC.x = (i-5)*50;
}
addChild(myMC);
var loader:Loader = new Loader();

loader.load(new URLRequest("02"+".jpg"));
myMC.addChild(loader);
mcArray.push(myMC);
}
for(j = 0; j < 10; j++)
{
mcArray[j].addEventListener(MouseEvent.ROLL_OVER,swapPositio n)
}

function swapPosition():void
{
if(numChildren>1)
{
setChildIndex(mcArray[j].,numChildren-1);
}
}

Depth Sorting With AS3?
'With AS3, this is no longer possible since no gaps can exist within the depths display list ("array").'

Is from senocular's AS3 tip of the day...

I was wondering, what will the impact of this be on isometric games, I have an isometric game, and each square is 10 depths apart...

In those 9 depths inbetween each square, I stack my stuff... but not always, how will any of this be possible with AS3 if we can't have gaps... will I have to load all the things, and swap them from an empty movie clip to the one they are currently corelating?? Also by no gaps, can I still start at let's say 500,000 depth? and then use without gaps up to 520,000...

Then when I'm scrolling left, the depths go down, and right they go up? The group won't have any gap, but there will be a big gap from 0 - 500,000

Depth Sorting...I Think
Hi,

I am really new at Flash and could use your help figuring this out. I have a page of logos that I want to change state on roll over, go to full page on click, and then return to the logo page on another click.

The samples are too big to upload so I put them here:
http://www.dingdongnation.com/flash/logos7.swf
http://www.dingdongnation.com/flash/logos7.fla
(sorry if that's not an OK way to do it, I haven't posted here before)
The top 2 logos in the left vertical column are the ones I am testing.

The code I tried was:


-------------------------------

mc1.addEventListener (MouseEvent.CLICK, onClick);
mc1.addEventListener (MouseEvent.ROLL_OVER, onOver);
mc1.addEventListener (MouseEvent.ROLL_OUT, onOut);

function onClick (event:MouseEvent):void

{
event.target.gotoAndPlay("click");
}

function onOver (event:MouseEvent):void

{
event.target.gotoAndPlay("over");
}

function onOut (event:MouseEvent):void

{
event.target.gotoAndPlay("out");
}

mc1.buttonMode = true;


mc2.addEventListener (MouseEvent.CLICK, onClickRumsey);
mc2.addEventListener (MouseEvent.ROLL_OVER, onOverRumsey);
mc2.addEventListener (MouseEvent.ROLL_OUT, onOutRumsey);

function onClickRumsey (event:MouseEvent):void

{
event.target.gotoAndPlay("click");
}

function onOverRumsey (event:MouseEvent):void

{
event.target.gotoAndPlay("over");
}

function onOutRumsey (event:MouseEvent):void

{
event.target.gotoAndPlay("out");
}

mc2.buttonMode = true;

-------------------------------

This sort of worked except the first logo would appear while the second was in full page mode. A friend suggested

swapme = function(mc){
mc.swapDepths(this.getNextHighestDepth());
}
for (i=1; i<5; i++) {
eval("b"+i).onRollOver = function(){
swapme(this);
}
}

but I couldn't make it work and wonder if it isn't an AS2 vs 3 thing?

then I saw your tip on AS3 swap depth

var sortedItems:Array = new Array(mc1, mc2);
function arrange():void {
sortedItems.sortOn("y", Array.NUMERIC);
var i:int = sortedItems.length;
while(i--){
if (getChildAt(i) != sortedItems[i]) {
setChildIndex(sortedItems[i], i);
}
}
}
_______________

I pasted it into the code but I must of done something wrong.

Would appreciate any help.

Thanks!

Leslie

Depth Sorting
I've been trying to sort objects depths based on their Y position but have not been able to do it efficiently. I was able to successfully sort objects with a selection sort algorithm and a quick sort algorithm; however, both have only been partly successful. Selection sort gets about 8-10/30 FPS with 13 objects and gets about 14-18/30 FPS. This is not good enough as I figure I could have as many as a hundred objects to be sorted at once.

After digging around, I found that array.sort() is more efficient than a quick sort implemented in AS3 and that calling swapChildren() or swapChildrenAt() at every swap was bogging it down. So now I am copying the objects array and sorting it with sort() and then comparing the two and swapping displayObjects so as only to call the swapChildren() or swapChildrenAt() method once per element. It appears to be running, and at full speed, though it won't swap correctly. Here is my code:


Code:
public class DepthSorter extends Sprite{

////////////////////////////////////////////////////////////////////
//// Constructor ////
public function DepthSorter() {
this.addEventListener(Event.ENTER_FRAME, SortDepths);
}

////////////////////////////////////////////////////////////////////
//// Sort Depths ////
public function SortDepths(e:Event):void {
var oldArr:Array = MovieClip(root).objectsArr;
// Copy Array
var sortedArr:Array = new Array();
for(var i = 0; i < oldArr.length - 1; i++){
sortedArr.push(oldArr[i]);
}
// Sort on the Y parameter
sortedArr.sort(sortOnY);

//Compare sorted with old and swap indices
for(i = 0; i < oldArr.length - 1; i++){
for(var j = 0; j < oldArr.length - 1; j++){
// Swap when match is found
if(sortedArr[i] == oldArr[j]){
//trace("Swapped children");
MovieClip(root).swapChildren(oldArr[i], sortedArr[i]);
break;
}
}
}
}

////////////////////////////////////////////////////////////////////
//// Sort On Y ////
private function sortOnY(a, b):Number {
if (a.y > b.y) {
return 1;
} else if (a.y < b.y) {
return -1;
} else {
return 0;
}
}
}
I can't figure out where the problem is or even if this algorithm will work at all. I would be very grateful if anyone could tell me what it is that is wrong as I have been working on this for a much longer time than I thought I would be.

Here is the source

Thanks

Depth Sorting
Alright you wise scripting people,

In something that must be a common coding algorthym in most all 2D games -- Essientially, the higher something is on the screen, the lower depth it has and vice versa. But with a dynamic amount of objects on the screen and objects constantly switching depths, what is the catch-all solution to this?

Depth Sorting Issues...
I'm building a replica of the SIMS in flash, and I'm not that experienced either. I'm having a problem with depth for the new objects on the stage (it's in fake 3D). Here is my code:

Code:
if (_global.build == true) {
nextOb = "_root.object"+_global.objects
nextY = this._y
nextX = this._x
obLength = _global.objectY.length+1
thisY = this._y
for (i=0; i<obLength; i++) {
if (thisY<objectY[i]) {
this.swapDepths(_global.objectsOS[i])
} else {
thisOb = _global.objectsOS[i]
thisObY = _global.objectY[i]
thisObX = _global.objectX[i]
_global.objectsOS[i] = nextOb
_global.objectY[i] = nextY
_global.objectX[i] = nextX
nextOb = thisOb
nextY = thisObY
nextX = thisObX
}
}
this.onEnterFrame = null;
_global.build = false;
}


as you can tell, there are 3 arrays for the object string name, object Y, and object X. What the code in the "else" statement should be doing, is sorting the Y array, and the other two according to the Y array, in order from largest to smallest, and the code in the if statement, should be swapping depths with all the objects that have a higher Y than the current object this code is on...

I can't find the problem, and I've been trying this for a long time...please help! Thanx!

[Flash MX] 3D Depth Sorting
I am trying to figure out an algorithm that will give me the perfect depth for polygons being display in a 3D graph. First off, what is the range of depths? From just test it out, I have found that they can not be negative? But was is the maximum? Anyone have prior experience with trying to figure a usable algorithm. All the ones I have come up with end up producing the same depth for different polygons which makes the previous one disappear.

Thanks

Isometric Depth Sorting
I've built several games using isometric display math and they've worked out well enough, but for a new project I've elected to use a method that allows objects to be pushed & raise above the floor. I'm using concepts used in this tutorial:

http://www.kirupa.com/developer/actionscript/isometric_transforms.htm

So far, it's working really well, but depth-sorting has me at a loss. Using traditional methods like the ones described in this tutorial don't work for my purposes:

http://www.kirupa.com/developer/isometric/depth_sorting.htm

I'm using a set of functions to convert x,y,z (3d space) to x,y (screen). I've come up with a way to assign a depth value to every object and then sort them (rather than swapping directly to that number which limits the depth resolution since Flash supports a finite # of layers). That works OK, but I can't seem to get it to take an object's dimensions (a,b,c) into account.

Any ideas? I can post some of the code here, but I fear that it might just confuse the issue.

AS3: Advanced Depth-Sorting (Help Please)
Hi there. I'm kinda new here so please excuse me.

I need some advice on this

I made a simple isometric board, with dynamic placing of entities. Works fine with 1x1 objects (ie chairs) thanks to Senocular's AS3 tip.


But now I'm trying to make it depth sort any size objects (2x2,1x2, 1x3 - 3 is the max dimension) but i have absolutely no idea.


Code:

if (tiles.valid){
var temp:entity = new entity(sel_furni.path, sel_furni.desc, sel_furni.frame);
furn_layer.addChild(temp);
SetObject(temp, evt.target.vx, evt.target.vy);

temp.xPos = evt.target.vx;
temp.yPos = evt.target.vy;
placed_furn.push(temp);
placed_furn.sortOn(["yPos", "xPos"], [Array.NUMERIC| Array.DESCENDING,Array.NUMERIC]);

//Thank you Senocular
var i:uint = placed_furn.length;
while(i--){
if (furn_layer.getChildAt(i) != placed_furn[i]) {
furn_layer.setChildIndex(placed_furn[i], i);
}
}
//Disable the zone
var active:Array = tiles.getActive()
for (i in active)
{
active[i].isOpen = false;
active[i].activate();
}
}
the above code works for all cases except 1. Note that I'm not sorting by y property, rather, sorting by xpos,ypos grid coodinates. Since not all the sprites are the same height, sorting with y would be inaccurate.

The above sorts Y descending, followed by X ascending. This works for all, except for the following case:

an entity of height 2, would cause it to overlap an adjacent entity, as one of its "occupied space" would not be taken into account? trouble abounds.

Been racking my head all day for a solution, but no luck yet. Its 2am so i better konk off. Hope to hear some replies when i wake up. Sorry if my post is confusing

Thanks in advanced for any replies.

3D Depth-sorting Problem
I am making a dynamic 3D API that allows me to create 3D objects using an unlimited number of planes (not taking processor speed into account)... Anyway, It was working fine and it does wire-frame perfectly, but when I tried texturizing it, I had problems sorting the depths of the textures...

I tried many methods, first I looked at the the average "z" value of each plane... This method worked well for simple shapes like cubes... But when I added an extra plane (rectangular) floating above by cube, when I rotated the whole lot, the extra plane's sorting was inaccurate... This is due to the fact that it is much bigger than the cube and that while parts of it was in front of the cube (z index), the rest was far behind it and thus the average z was lower than some sides of that cube...

Then, I tried to fix this by finding the "angle" of the center-point of each plane from the origin... But that basically did the same thing as the z-sorting method... Then I tried doing it by using the normal of each plane, but that failed also because two planes could face the same direction and yet, one could be in front of the other...

So as a last resort I tried using a combination of all the variables and angles described above... But nothing worked.

Does anyone have any idea how I could go about achieving my goal? Even a link to a good math/programming tutorial would be nice... I haven't found any good ones yet.

Thanks.

Dynamic Z Depth Sorting
Does anyone know a quick way of sorting objects depths based on a variable (z depth). I've tried a few things but they seem quite slow -

one method involved pushing each object onto an array and then sorting it each frame using a sort function and then using swapDepths to reorder everything on screen. The swapDepths is quick but I think the array sorting is slow. I could possibly write a quicker sort based on shear or merge sorting - are the default actionscript sorts slow?

Does anyone know if it's any quicker in AS3.0 either?

I could probably work it out given a while, but I thought I'd ask if anyones already done it!

Cheers!

QuadTree's And Depth Sorting
I've been doing some experiments with using a Quadtree to reduce the number of calculations when running collision checks. Pretty nifty way of reducing checks. However, I'm also blitting to the screen instead of using Sprite displayObjects which means I cannot depth sort via displayObjects.


So after some thinking, my way of doing this would be to have not only a Quadtree, but also a linked list. All created sprites would be placed into their proper depth on the linked list and then the Quadtree nodes would have a reference pointing to their corresponding node on the linkedList.

Anyone have any thoughts on this? or perhaps a better way to do it?

Thanks


edit: Ugh, ignore the 's in the thread title. It's late, I'm sleepy.

Problem About Depth Of Objects..(swap Depth) Plse.help
umph..hello i'm nameg sir
i'm trying to do dragging project. drag isomatric object in small room(isomatric view too) for test installation..(so i necessary have foreground objects,background objects ..u know)
now i can drag many objs. in same movie when i press it , by i use swap depth command (for see it above other)and drag it around sometime it works...but sometime it don't!...
1..... some obj. automatic swap its depth! when i release other one....i don't know why
2. some time i dup. new obj. to drag and it del some old obj. that call before
ps. i use swap code from this site tutorial ...s.a.Drag & Drop / Swap DepthsAuthor by : estudioworks

thank u so muchhhhhhhhhhhhh

Depth Sorting Cube Faces.
Hi,
Im coding a 3d rotating cube. it works fine, however, id like to sort the depths of the faces correctly. i.e. the closest one to you has the highest depth.
in my program, the further away something is, the higher its Z value.
What ive been doing is for each face, i make a total of the Z values for the four corners.
I draw that face with depth (1000 - totalZ).
it works ok sometimes, but other times the wrong faces show on top.
is there another way to sort the faces?

Sorting And Rearranging Clips By Depth
hello

i've got a movie which generates a number of clips that then move around in an ellipse to give the illusion of 3d depth:

http://www.vincelee.co.uk/mmc/showca...InArcTest.html

now i want to rearrange the depths of each clip as it spins so the clip that appears closest (is lowest down the stage) has the highest depth so is not obscured by the others.

here's what i've got so far:


Code:
productsByY = new Array();
productsByDepth = new Array();
function changeItemDepths() {
//populate arrays with clip identifiers (strings from other objects)
for(i = 0; i < myArc.productsArray.length; i++) {
currentObj = myArc.productsArray[i];
currentMC = currentObj.mc;
productsByY[i] = currentMC;
productsByDepth[i] = currentMC;
}

// sort in ascending order by depth and y position with custom sort functions
productsByDepth.sort(sortByDepth);
productsByY.sort(sortByY);

// rearrange depths according to clip's current y position
for(i = 0; i < myArc.productsArray.length; i++) {
j = myArc.productsArray.length - 1 - i;
currentDepthMC = productsByDepth[i];
currentYMC = productsByY[i];
_root[currentDepthMC].swapDepths(_root[currentYMC]);
}
trace("depth: " + productsByDepth);
trace("y: " + productsByY);
}


i'm having trouble getting my head around which clip to swap depths with. isn't there a setDepth() somewhere?


cheers in advance

Vince

/edit didn't see the big sticky at the top of the forum....

here is the fixed script if anyone is interested:


Code:
function changeItemDepths() {
for(i = 0; i < myArc.productsArray.length; i++) {
currentObj = myArc.productsArray[i];
currentMC = currentObj.mc;
productsByY[i] = currentMC;
}
productsByDepth.sort(sortByDepth);
productsByY.sort(sortByY);
for(i = 0; i < myArc.productsArray.length; i++) {
currentYMC = productsByY[i];
_root[currentYMC].swapDepths(i * 1000);
}
}

Senocular - Approach To Depth Sorting
Hi, this is a question regarding Senocular's Approach to Depth Sorting tip of the day, but anyone is very welcome to answer it!

I am trying to use his code:


Quote:




var sortedItems:Array = new Array(mc1, mc2, mc3);
function arrange():void {
sortedItems.sortOn("y", Array.NUMERIC);
var i:int = sortedItems.length;
while(i--){
if (getChildAt(i) != sortedItems[i]) {
setChildIndex(sortedItems[i], i);
}
}
}




To automatically sort the depths of my objects depending on their y position. To my delight, this worked. But I have a problem. For some reason the objects I apply it to stop being animated (which defeats the point).

E.G. I have two objects, one stationary (stat_mc), one moving (move_mc). When move_mc moves up over stat_mc it should go behind it when move_mc's y position is less than stat_mc's. However, this code seems to stop move_mc from moving!

I can't understand what is in this code which is causing this.

Thank you so much for any help.

Tile Based Game Depth Sorting
Hey, I've been playing around with ActionScript 3. They have a new way of placing clips onto the stage, "addChild(clip)," which automatically places the clip onto the stage with it's own depth. So here's my problem, when making a tile based game, I have to constantly depth sort to make sure the object lower on the screen has the higher depth than an object higher on the screen. Pretty much, their depth depended on their y-coord. Does ActionScript 3 still let us play with depths? And if yes, how?

Can anyone help?
Thanks

Depth And Dynamic Objects/Attaching Scripts To Objects
I am having some problems with my Flash MMORPG created in Actionscript 3.0 that I am working on, not really errors, but more how to do something, in theory. I have 2 problems. First, my game is at a 45 degree angle, so it requires some depth handling(like one object is over another object when it should be behind that object). I am not sure how to go about this. I was thinking that each object's depth should be it's y position if it's origin was at it's feet. But that idea didn't go well, because the depth is limited by the number of children. What is the average way to do this? Next, I am trying to make dynamic objects, so that all I would do is copy and paste an object, or create a new class of it and it would work. What I mean is, the character checks a collision for each object, but if I copy the object with the same name, it doesn't work. In AS3 you can't attach scripts to objects anymore, so I am running into a lot of problems with that. How would I go about fixing this? Thank you in advance.

Sorting An Array Of Objects
Hi,

I have this array of objects, each element of the array contains 3 properties, (link:String, level:Number, Count:Number). I want to sort my array ascendingly based on the 'level' property. Any idea how to do that?

Best Regards

Sorting An Array Of Objects
I've got an array of objects. I need to know the most efficient way to sort the array. I only need to be able to sort by integers.

For example...


Code:
playerPass = new Array();

playerPass[0] = new Object();
playerPass[0].Name = "T. Bag";
playerPass[0].Att = 3;

playerPass[1] = new Object();
playerPass[1].Name = "A. Nus";
playerPass[1].Att = 5;
Of course i've got way more objects and way more properties inside each object. I need to be able to choose which object property to sort the array by. Your help is appreciated, thanks.

by the way I'm using flash 8

Sorting An Array Of Objects
I know this is probably really easy to do but I'm just stuck... someone plz help me along.. I have an function that accepts an Array of objects and sorts them according to a property that holds a numerical number. However, I don't know what to add exactly so that once the object with the highest property is chosen, it wont be rechosen again.... here is my code...

Code:
function SortBySpeed(array){
var return_order = new Array()
var highestindex = 0
for(var i=0;i<array.length;i++)
{ var highest = 0;
for(var k = 0;k<array.length;k++){
if(array[k].speed > highest){
highestindex = k
highest = array[k].speed
}
}
return_order[i] = array[highestindex]
// i dont know what to put here!!!
}
return return_order
}

Sorting An Array Of Objects
Hello,

i've made an array of objects like :
(code is resumed of course)

Code:
_tab[x] = new ObjectName(..parameters);
_tab[x].z = z;
and I'd like to sort it by it's z property with the help of "sortOn"
but as it's an array of objects the following syntax doesn't work :

Code:
_tab.sortOn("z", Array.DESCENDING );
what is the correct syntax to touch the z property of my objects ?

Sorting An Array Of Date Objects
I need to sort an array of Flash Date
Objects. I have an array that contains several dates, but they may not be in chronological order...

I need those dates to be sorted and put into chronological order every time a new date is added to the array.

I can't think of a good way to do it, and I also know it is going to take me like 4 pages of code to get that to work.

If anyone has anything already written, or would like to help me, I would really appreciate it.

Thanks!

Sorting Multidimensional Arrays/Objects
I have been thinking about this for a while now. I want to be able to sort an array of objects depending on the object index, but, not just one of their indexes.

for example:


Code:
object1 = {streetNum:12, road:'Truro', suburb:'Sandringham', city:'Auckland', price:5000000};
object2 = {streetNum:2, road:'Wayside', suburb:'CBD', city:'Auckland', price:250000};

objectArray = [object1, object2];
As above i need to be able to sort the objectArray by streetNum or road or any combination of indexes.

The objects are being populated from a mysql database using php, would i be better to do it with mysql or php? I would rather do it all in flash so i only have to load the data once then can reshuffle within flash.

Thanks in advance.

Sorting A Collection On Nested Objects
I have a collection of customized Objects I'm trying to sort based on nested objects within the object that is a part of the collection.

I've been trying to .sort the collection using a customized compareFunction, but have been unsuccessful. My objects are Contacts and and within those they there are several properties, one being contact.kvs which is an array, of Key Values(also objects), and I want to sort contacts based on data derived from a certain key/values.

This is for a dataGrid. I'm using a customized labelFunction because dataField does not work with nested data. My labelFunction looks like

ActionScript Code:
private function myLabelFunction(item:Object,column:DataGridColumn):String {
        var keyId:int = _user.userGroup.keys.withPropertyValue('keyName',column.headerText).id;
        for each (var a:Kv in item.kvs) {
          if (a.key.id == keyId) {
            return a.value;
          }
        }
        return '';
      }

at first I tried a sortCompareFunction (part of the DataGridColumn), but I couldn't accomplish what I wanted because there was no way to determine which column (of data) the user is trying to search with. myDataGrid.sortIndex and .sortDirection (are protected property, and cannot be read) by the sortCompareFunction.

My DataGridColumns are created at runtime, so I do not know in advance how many columns I must create, and thus cannot create separate sortCompareFunctions.

It seems like my only other option is totally disabling sorting, but I really don't want to do this. Does anyone have any ideas?

Sorting Labels Dynamically
i have a combo box filled with dynamically loaded labels, and in my php script, I call for it to be alphabetical, however it doesnt pull it in that way.. so, is there a way to mycombobox.sortItems() to make alphabetical?

How Do You Change The Objects Depth?
I have 2 coloured circles i want it so that when you scroll over one it goes on top of the other.

i've seen code like :
on(rollOver)
{
this.swapDepths(500);
}

how do you make it do it.

Better Way To Get A Display Objects Own Depth?
i looked up the props for the DisplayObject class, and i don't see anything that tells you it's current depth.

so what i do, is this


Code:
private function p_getMyDepth():int
{
return parent.getChildIndex(this);
}
that works... but i mean isn't there a better way? i'm probably just missing something

I Can't Change My Objects Depth
I am fooling around with a game, and teaching myself AS2 OOP as I go. I am running into some problems though. I pass my hero class a MovieClip, the problem is that I can't get or change the depth of the movie clip. so my tiles are ontop of it. It is very possible that I am not doing something correctly. When I try to trace the depth it outputs "undefined," and nothing seems to happen when I swapDepths.


Code:

class Hero{
public var name:String = "none";
private var guy:MovieClip;
private var speed:Number = 6;
private var spacing:Number;

function Hero(n:String, s:Number, obj:MovieClip){
name = n;
spacing = s;
guy = obj;
}

function get _speed():Number{
return speed;
}

function set _speed(nuSpeed:Number):Void{
speed = nuSpeed;
}

function followMouse():Void{
var x1 = _root._xmouse;
var y1 = _root._ymouse;
var x2 = guy._x;
var y2 = guy._y;
var delt = (y1-y2)/(x1-x2);
var deg = Math.atan(delt)*180/Math.PI;
if (x1>x2) {
guy._rotation = deg;
} else if (x1<x2) {
guy._rotation = deg + 180;
}
}

function keytrap():Void{
if(Key.isDown(Key.LEFT)){
moveit("left");
}else if(Key.isDown(Key.RIGHT)){
moveit("right");
}
if(Key.isDown(Key.UP)){
moveit("up");
}else if(Key.isDown(Key.DOWN)){
moveit("down");
}
}

function moveit(dir:String):Void{
if(dir=="left"){
guy._x-=speed;
}else if(dir=="right"){
guy._x+=speed;
}else if(dir=="up"){
guy._y-=speed;
}else if(dir=="down"){
guy._y+=speed;
}
}

function get _col():Number{
return Math.ceil(guy._x/spacing);
}

function get _row():Number{
return Math.ceil(guy._y/spacing);
}
}
I would really appreciate any help. Thanks

Overwriting Objects In The Same Depth.
Lets say I had movieclip a located in depth 400. Now, I attach a new movieclip, movieclip b, on to depth 400 (same depth as movieclip a).

When this happens, I know that a is written over with b. Does anyone know if this type of method actually removes movieclip and will not create any memory leaks or anyhting of the sort? Or does it just overwrites what is on that depth, but movieclip a is still in memory?

I know I can remove movieclip a with removeMovieClip(), but I was just wondering if I really had to in the case above.

What I am really worried about is if this operation is performed many times it may cause some errors or flash may soak up resources.

Thanks for your help and time in advance.

All Objects At Depth Of -16384?
for some reason all the objects in my movie seem to be at the depth -16384 and when I try to swap one lower it does not work... any ideas on what is going on here?

I Can't Change My Objects Depth
I am fooling around with a game, and teaching myself AS2 OOP as I go. I am running into some problems though. I pass my hero class a MovieClip, the problem is that I can't get or change the depth of the movie clip. so my tiles are ontop of it. It is very possible that I am not doing something correctly. When I try to trace the depth it outputs "undefined," and nothing seems to happen when I swapDepths.


Code:

class Hero{
public var name:String = "none";
private var guy:MovieClip;
private var speed:Number = 6;
private var spacing:Number;

function Hero(n:String, s:Number, obj:MovieClip){
name = n;
spacing = s;
guy = obj;
}

function get _speed():Number{
return speed;
}

function set _speed(nuSpeed:Number):Void{
speed = nuSpeed;
}

function followMouse():Void{
var x1 = _root._xmouse;
var y1 = _root._ymouse;
var x2 = guy._x;
var y2 = guy._y;
var delt = (y1-y2)/(x1-x2);
var deg = Math.atan(delt)*180/Math.PI;
if (x1>x2) {
guy._rotation = deg;
} else if (x1<x2) {
guy._rotation = deg + 180;
}
}

function keytrap():Void{
if(Key.isDown(Key.LEFT)){
moveit("left");
}else if(Key.isDown(Key.RIGHT)){
moveit("right");
}
if(Key.isDown(Key.UP)){
moveit("up");
}else if(Key.isDown(Key.DOWN)){
moveit("down");
}
}

function moveit(dir:String):Void{
if(dir=="left"){
guy._x-=speed;
}else if(dir=="right"){
guy._x+=speed;
}else if(dir=="up"){
guy._y-=speed;
}else if(dir=="down"){
guy._y+=speed;
}
}

function get _col():Number{
return Math.ceil(guy._x/spacing);
}

function get _row():Number{
return Math.ceil(guy._y/spacing);
}
}
I would really appreciate any help. Thanks

Overwriting Objects In The Same Depth.
Lets say I had movieclip a located in depth 400. Now, I attach a new movieclip, movieclip b, on to depth 400 (same depth as movieclip a).

When this happens, I know that a is written over with b. Does anyone know if this type of method actually removes movieclip and will not create any memory leaks or anyhting of the sort? Or does it just overwrites what is on that depth, but movieclip a is still in memory?

I know I can remove movieclip a with removeMovieClip(), but I was just wondering if I really had to in the case above.

What I am really worried about is if this operation is performed many times it may cause some errors or flash may soak up resources.

Thanks for your help and time in advance.

Merging 2 Bitmap Objects.
Hello,

here is what i am trying to do...

I have 2 diferent bitmap objects.
one with a picture.. and enother with gradiant filll with transparant from 0 to 256.

idea is to merge 2 bitmaps and produse a fog efect on an image.
I tried to play with diferent color channels, but fail with my task.

of course i could run my picture bitmap pixel by pixel and change its chanels acordingly to make them darker. but I gues this metod will be too slow.
(I gues..)

here is little example what I am trying to do..
http://flashmx.puslapiai.lt/BITMAPTEST022.swf [FLASH 8]

I have a MC with transparant gradient put over my bitmap.

eny ideas?

maybe some thoughts ho to make this effent in bitmap level?

Deril

MouseEvents With Bitmap Objects
I am trying to have a mouse event register when the cursor leaves an image, but the listener function never gets entered. In AS3, how does one get the MouseOver event to work for a bitmap like I have?

public class MyClass extends MovieClip {
.
.
.
[Embed(source='orange.jpg')]
public var MyOrange:Class;
.
.
.

public function MyFunction() {
var graphix1:Bitmap = new MyOrange();
graphix1.x = 70;
graphix1.y = 124;
graphix1.addEventListener(MouseEvent.MOUSE_OVER, showOrange);
}

Bitmap Smoothing On Stage Objects
I recently found the smoothing = true property on Bitmaps. I'm using quite a few bitmaps in one projects and turning the smoothing on for the dynamically created ones has improved their quality no end.

I also have some objects that have had a bitmap placed on them when I was building the symbols in the Flash IDE (I build my projects using mxmlc and TextMate). I'd like to be able to smooth these Bitmaps as well but I can't see a simple way to do that beyond finding all the objects that have a bitmap in them, tearing it out, replacing it with a marker point, attaching a bitmap to that marker point in the code and turning smoothing on there. The reason this doesn't work is because I'm using the same bitmap (graphics of paper) in lots of different places and rotations and programatically attaching them all is a right PITA.

Is there some sort of global smoothing switch that I can use to tell a class to smooth any child bitmap objects? A simple way to parse the children of an object and smooth them?

Any help here would be appreciated. The only stuff I have found by googling relates to Bitmaps that are created in the code rather than placed on the stage in the IDE. I have also ticked "Allow Smoothing" in the properties of the bitmaps and they are encoded as PNG's.

Many thanks,

Gaby

Can I Save Masked Objects In A Bitmap?
then save them as jpg/png?

trying to do a virtual character where people can upload their own pictures/

Quote:




var URLReq:URLRequest = new URLRequest("siteb.jpg");
var imageLoader:Loader = new Loader();
imageLoader.contentLoaderInfo.addEventListener(Eve nt.COMPLETE, loadBit);
imageLoader.load(URLReq);



function loadBit(event:Event):void {



myBitmap = Bitmap(imageLoader.content);
addChild(myBitmap);

var b:BitmapData=new BitmapData(maskermc.height, maskermc.width,true,0x00FFFFFF);





var mc:MovieClip = new MovieClip();
mc.addChild(myBitmap.mask=maskermc);




b.draw(mc);





basically im trying to put masked IMAGE into a movie clip then putting that into a bitmap
ive tried converting image and mask into bitmaps then masking and successfully saved that into a bitmap BUT its a rectangle!!!!!


is it possible to save masked images into movieclips/bitmaps

Setting Display Objects To The Highest Depth
Say I have a number of buttons placed on my stage. On roll over - I want this button to expand along both x and y axis. So I want my button to be on top of all the other buttons - otherwise there is high risk that the other buttons will lie on top of my expanded button.

I have found a quick and dirty solution:


ActionScript Code:
private function onMyButtonOver(e:MouseEvent)
{
     removeChild(DisplayObject(e.target));
     addChild(DisplayObject(e.target));
}

In the old days you would use getNextHighestDepth to be sure to put something on top. The solution above works but I find it kinda ugly. Any thoughts?

Dynamically Assign Depth
HI all, I’m making this card and have the movie to remember the card _x _y the scale etc. But I have problem with the depth.

I can assign the movie to remember the depth of every movieclip, but I have problem reassign them, is this part of the script, I wonder anyone can tell me where I go wrong..


Code:
with (this["item"+i]) {
_x = inSingle[0];
_y = inSingle[1];
picture._xscale = inSingle[2];
picture._yscale = inSingle[3];
_rotation = inSingle[4];
picture.gotoAndStop(inSingle[5]);
swapDepths(inSingle[6]); // this line doesn’t work
}


Thanks in advance..

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