Change BeginFill In Duplicated Mc
hi,can I change the beginFill color in a duplicated movieclip? Code: this.createEmptyMovieClip('col1', 1);with (_root.col1) { lineStyle(0.1, 0x000000); beginFill(0x000000); lineTo(10, 0); lineTo(10, 10); lineTo(0, 10); lineTo(0, 0); endFill();}duplicateMovieClip("col1","col2",2)col2._x=11;//this doesn't work:col2.beginFill(0xFF0000);
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 01-14-2006, 08:54 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
To Change Movieclip Color Should I Use BeginFill?
I'm trying to dynamically set the rgb value of a movieclip, can this be done using 'beginFill'? If not, how can it be done? If so, why doesn't the code below work for me?
topBar.beginFill (0xFF0000);
topBar.endFill ();
Change Color Of BeginFill() Without Losing Dynamic Shape?
Hi,
I am creating an application in Flash MX that dynamically creates drawings of light poles. The main part of the drawing is a tall rectangular shape (the pole), and the coordinates are adjusted based on user input and a bunch of functions.
My question is, can you change the color of a rectangular shape without losing the adjustments that are made by the user? For instance, if the rectangle width starts out 15 pixels wide, and is filled with hex color 336699, using beginFill() and endFill():
code:
_root.createEmptyMovieClip("pole_mc", 100);
with (_root.pole_mc) {
lineStyle(1, 0x000000, 100);
beginFill(0x336699, 100);
moveTo(0, 0);
lineTo(10, 0);
lineTo(10, 200);
lineTo(0, 200);
lineTo(0, 0);
endFill();
}
.
After the default rectangle is drawn, the user can adjust the width to 30 pixels, while the color stays at 336699. Is there a way to change the beginFill color from 336699 to another color, like FF0000, without losing the adjusted width?
The above code is just an example, but not my actual code. I have attached a scaled down version of my .fla if anyone would like to take a stab at it. I apologize if I'm not making myself clear...I don't know how else to explain it, and my actionscript is too complex to post in this message. If you do look at the .fla, click on the "standard" or "decorative" button when you test the movie, and it will draw the pole.
I have looked for other examples of changing the fill color, but they involve redrawing the shape with a different fill color. Since I don't want to lose any dynamic changes, I'd like to avoid redrawing. An adjustment of color is what I'm after.
Thank you for any input you may have.
DuplicateMovieClip -> Change Text In Duplicated MC
Hello Guys,
I not just a newbie, but I have a little problem with my new site:
I load a couple of data from my MySQL-database, and I want to generate a navigation out of buttons.
Ok here is what I have done already: In the first frame I have a loadVariables-action. Then I duplicate one button according to the number of rows I get from the database. so far it's working fine...
But my problem is that inside the MC "box" I have a dynamic textfield which has the variable "button_text", and if I try to update this field via 'bn.button_text = value;' it won't work. Can anyone give me a hint how to solve this rather litte problem?
the variable dbrows is the count for the databaserows...
for (n=1; n<dbrows; n++) {
bn = "box" add n;
duplicateMovieClip ("box", bn, n);
setProperty (bn, _y, (Number(getProperty(bn, _y))+Number(n*(getProperty(bn, _height)))));
set (bn add ":n", n);
}
That's it...
;-)
Txtbox Value (within A Duplicated Mc) Change From _root
is it possible to change the value of a textbox (which is within a duplicated movieclip)
from the _root, without changing the value of the text box in the original movieclip.
if it is possible a example will be appreciated
(i am using flash mx)
thanks in advance
Change Text Of A Duplicated Movie
hi, i'm trying to have the text and position changed of a duplicated movie containing a text button. does any one knows how this would be possible?
so you have the movie "options" thats being duplicated.
in the movie you have the text named sub
for (i=0; i<5; i++) {
option.duplicateMovieClip("option"+i, i)}
probably basic actionscripting, but i've been trying more than an hour without any result.
Change Variable In Duplicated Movie Clip
how can i change a variable in a duplicated movie clip? I want a text box with 1 the next movie clip with 2 etc. I would also like to type in a number (like 7) and have it duplicated that many times with each number in a separate clip
How To Change Text On Duplicated MC Without To Affect The Original?
Hi!
I have a problem with Flash for a long time and never figured out how to solve that.
Suppose I create a new MC and type some text inside that. Ok.
Then I go to the library, right click the new mc and choose duplicate. Ok.
Well, when I enter the new duplicated MC and change the text inside that, the text on the original (from whose I copy this new one) is changed too!
How to avoid it?
Thanks!
Change Width Of Duplicated Clips,setProperty Doesnt Work?
In my movie file i have a "bar" movie clip that is an
instance of "rect" movie clip..I want one bar for each
record of my database table. So i do duplicateMovieClip()
In the frame 3, main timeline where i have code for
duplicating i do a setProperty(_xscale ) to what i get
from the database. this val can be anything between 0
to 100.
I want the individual duplicated bars (bar1, bar2..)
to be as wide depending on what i set _xscale of each
bar..to.. Just setProperty in the main timeline code
doesn't work..i tried alll sorts of things in the clip
too,but no way..
My "rect" movieclip as such is of only width 1...it
remains one when I play it.
I also wanted it to change as a tween from 1 to whatever i set _xscale to...
Thankyou,
shilps.
BeginFill
PHP Code:
this.target_mc.beginFill["0x"+_root.buildcolor+",60"];
What is wrong with this bit of code? I think the "buildcolor" works. just that it doesn't work in that code.
How do I make it work?
BeginFill?
Hi.. I got this .fla where you can draw any shape on the stage using lineTo function.. However I did not manage to fill this shape after I am done drawing it... Can somebody please help?
here is the source: http://www.games4fun.as.ro/draw.fla
tnx,
ovidiu
BeginFill
hi All
Is that possible to fill, or change the fill of an already created movie clip. As far as i have searched the help and forum, i have figure out that everyoen has used this method to fill it with createemptymovieclip method.
or is there any other method to fill an already created movie clip,
please reply urgent
Beginfill()
can you beginfill() with an image for the background?, if so how?
BeginFill
hi,
I want to fill a shape ; with this class .. but when I set this class for any fla. file in flash(properties area ) will work ..
I want to work with this class with import class in action panel ! or use in other class ..
when I import this class; just trace will be display in Output and not any shape to be fill !!!!
whats wrong ??
thanks
Attach Code
package {
import flash.display.*;
import flash.geom.*;
public class tooltip extends MovieClip {
function tooltip():void {
var circle:Sprite = new Sprite();
circle.graphics.beginFill(0xFF794B);
circle.graphics.drawCircle(50, 50, 30);
circle.graphics.endFill();
addChild(circle);
trace("tested worked!!!");
}
}
}
3d Box With Pictures Not With Beginfill
Hi flash world!!!
I'd like to create a 3d box and its sides with a picture over them... I know how to create a 3d box with colors with beginfill sentence but I'd need to fill that space with some photo and not with a color...
Someone could help me? or send me an interesting link to do it? I don't want to use other product as swift3d or 3d flash animator, because with those tools I can create that box but thereafter I can't change the photo on its sides...
I hope someone will be able to help me because I need it!!!!
AS. For A GAME (trying To ;)) Use BEGINFILL
Hi all
I'm trying to make a game in which the player needs to encircle items to collect them. To do this I think I'll do a hittest on a filled line.
Trouble is, the line is dynamically generated, and should be filled when DONE, not constantly... which clashes with the way beginFill is supposed to be used.
If you're so kind to take the time to view my file (I hope you like the controls of the avatar in the game, I certainly do! very smoooooth - check out the skidding behavior, it does so when you try to make an abrupt direction change )
* All / most variables are defined in frame 1
* Code is in frame 2
* GoToAndPlay is in frame 3
CONTROLS:
Arrows: steer avatar
keeping CTRL pressed draws a line
Drawing a new one clears the last
In short:
I'd like to fill my freshly created line once it's done (To go wild on it with hittests 'n stuff, but that's for later) - and right now, it won't. (I got it working once, but then the closing behavior of the fill command screwed up - so the shape turned out terrible)
Thanks a bundle!
greetings,
Sandmen
Sandmen
BeginFill() Inverse?
Hello,
I have a series of coordinates defined by an XML file. These coordinates form a rectangular shape with a "hole" in the middle.
I am able to fill this defined shape using lineTo() and beginFill().
What I would really like to be able to do is fill the INVERSE (inside) or "hole" instead of the rectangular/outside portion, so I may use this as a mask.
Is there any way to do this?
One idea I had would be to draw a normal rectangle first, then draw my plotted shape and fill it, then delete the plotted shape, leaving just the "hole" are with a color fill. Sadly, I do not know how to do this, as clear() deletes everything.
Does anyone have any ideas?
BeginFill On A Movieclip
hi, is there a way to use beginFill on a movie clip that was already created during design time instead of created using AS? I have a movie clip with a circle in it and i just want to see if I can fill that circle with a background color. I know you can create shapes by using createemptymovieclip and then use the beginFill method but I want to know if it is possible for movie clips/shapes that have already been created.
My main goal is to have a bunch of shapes on stage and users (very young kids) use their mouse and click inside those shapes to fill with colors, sort of like paint bucket tool in PhotoShop while having an area selected.
Thanks
AS3 BeginFill Not Working
Hi,
I'm trying to do a simple fill on a manually drawn triangle (or any other custom shape for that matter) The following code draws the triangle, but not the fill. Can anyone help me out with spotting the issue?
Code:
//this is just thrown on the main timeline for testing purposes...
import flash.display.*;
import flash.geom.Point;
var mc:MovieClip=new MovieClip();
addChild(mc);
var p1:Point = new Point(0,0);
var p2:Point = new Point(300,0);
var p3:Point = new Point(150,300);
mc.graphics.lineStyle(2, 0x000000, 1);
mc.graphics.beginFill(0xFF0000,1);
//draw lines
mc.graphics.moveTo(p1.x,p1.y);
mc.graphics.lineTo(p2.x,p2.y);
mc.graphics.moveTo(p2.x,p2.y);
mc.graphics.lineTo(p3.x,p3.y);
mc.graphics.moveTo(p3.x,p3.y);
mc.graphics.lineTo(p1.x,p1.y);
mc.graphics.endFill();
Beginfill Without The Lines
OK a simple question: I've started to use the dynamic drawing bit in flash and I can draw and fill fine but is it possible to just have the fill and no outline?
I'm looking at having 12 dynamic drawn objects on the stage all with a continous gradient fill and the lines around the objects make it look a bit naff, just wondering if I could delete the lines off afterwards or something similar....
cheers
Zen
Circular Preloader W/ BeginFill
Hi there,
I remember reading this tutorial for creating a circular preloader using an MC with a circular ring and its mask that fills up using the beginFill function to reveal the ring. Does anyone know where I could have read this tutorial?? I have looked thru here and flashkit but could'nt find it. Alternatively, if you could point out some place that has a similar tutorial, I would greatly appreciate it.
Regards.
Problem With Drawing With BeginFill In AS3
http://www.bbmercy.com/files/why.jpg
please see the pic above
I can't draw the form I want by as3
here is my code
can any one give me a hint?
Attach Code
var fillMc:Sprite=new Sprite();
fillMc.graphics.beginFill(0x00ff00);
fillMc.graphics.lineTo(15,15);
fillMc.graphics.lineTo(100,0);
fillMc.graphics.lineTo(100,100);
fillMc.graphics.lineTo(0,100);
fillMc.graphics.endFill();
addChild(fillMc);
[AS3] BeginFill And EndFill Weirdness
Ok so I've been working on this 3d engine in flash using AS3, and I got it to the point where I can have it render any set of points, be it an equation, or an array, to x, y, and z variables, and have it draw the correct lines in 3D. I also got it to the point where I can fill in said lines into shapes pretty easily.
Now, last night I decided that I kinda needed to render multiple objects at once. I split the actual points of the thing to draw into one function, and the rendering of said points into another. An array is used to collect the total points from each object to be rendered, and they are all collectively sent to be rendered at once.
However, when it goes to fill them in, something goes wrong, and I seem to be getting one extra triangle per item that shouldn't exist. I really need this thing to work by like, tomorrow, and I've been scratching my head on this one for hours. Does anyone have any ideas?
Here's the .fla: (you'll probabbly have to right-click and hit Save As)
http://www.bulc.org/~onionringofdoom/coltrane7.fla
All the actionscript is on frame 341, and ignore any frames before that; they are just an intro to the movie I will be using my 3d engine in.
In the "Globals/Functions" layer, you will find, well, globals and a few random functions, along with the coordinates for each item to be rendered.
In the "Time" layer, you will find the function that uses the functions which plot and render the points.
In the "Red Ribbon" layer, you'll find all the functions that actually do the plotting and rendering. The problematic fill stuff starts at line 98 in the "Red Ribbon" layer.
Everything is pretty clearly commented, but if you have any questions, feel free to ask. Any help is greatly appreciated!
BeginFill Method Using Specified Colors
Hei!
When i use:
Code:
beginFill(Math.random()*0xffffff, 100)
i get color picked randomly. But mostly they appear to be quite.. ugly, if to be straighforward. How can i use random specified colors? Let's say I set the calues like example below:
Code:
col1 = 0x99cc00
col2 = 0xff6600
And it randomly picks one color of specified ones..
[Drawing API] BeginFill() Weirdness
I'm playing around with dynamic drawing, and creating a very levitated.net'esque piece.
The problem I've run into is with using beginFill(). Basically, I pick a random X, Y and angle then draw a line until it hits the edge of the working area. From that endpoint, I draw a line at a distance of 50 pixels away at 90 degrees. Repeat until I now have a box (I'll post code below, which will probably make more sense).
The box is drawn exactly as I want, however, when I attempt to fill this box, the fill doesn't actually fill the drawn box, but creates an odd skewed pattern bearing almost no resemblance to the box I drew.
Anything I'm doing that's wrong here as far as using the drawing API?
Note that this code is very sloppy -- was just playing with ideas and the weird behavior ticked me off.
ActionScript Code:
class baseLine extends MovieClip {
public var origin_x:Number ;
public var origin_y:Number ;
public var direction:Number ;
public var shadeDirection:Number ;
public var iterations:Number ;
public var intervalID:Number ;
public var shade_rbg:Number ;
public function baseLine() {
this.origin_x = (Math.random() * (Stage.width - 20)) + 10 ;
this.origin_y = (Math.random() * (Stage.height - 20)) + 10 ;
this.direction = Math.random() * 360 ;
this.shadeDirection = ((direction + 90) > 360) ? (direction + 90) - 360 : (direction + 90);
this.shade_rbg = randomColor() ;
if(_global.currentdepth == undefined) {
_global.currentdepth = 1 ;
}
this.iterations = 0 ;
}
public function onLoad() {
this.iterations = 1 ;
moveTo(origin_x, origin_y) ;
this.intervalID = setInterval(this, "draw", 10) ;
}
public function draw():Void {
this.lineStyle (2, 0x000000, 100);
//this.moveTo(this.origin_x, this.origin_y) ;
var upY:Number = getY(this.origin_y, 2* this.iterations, this.direction);
var upX:Number = getX(this.origin_x, 2*this.iterations, this.direction) ;
this.lineTo(upX, upY) ;
if(upY > Stage.height - 10 || upY < 0) {
newOrigin(upX, upY) ;
this.moveTo(origin_x, origin_y) ;
} else if(upX > Stage.width - 10 || upX < 0) {
newOrigin(upX, upY) ;
this.moveTo(origin_x, origin_y) ;
}
this.iterations++ ;
delete upY ;
delete upX ;
}
function randomColor():Number {
return Number( "0x" + Math.round(Math.random() * 255).toString(16) + Math.round(Math.random() * 255).toString(16) + Math.round(Math.random() * 255).toString(16)) ;
}
function drawShading(x:Number, y:Number):Void {
this.lineStyle (1, this.shade_rbg, 100);
var shadeColor = randomColor() ;
this.beginFill(shadeColor, 10) ;
this.moveTo(origin_x,origin_y);
this.lineTo(getX(origin_x, 50, this.shadeDirection), getY(origin_y, 50, this.shadeDirection));
this.lineTo(getX(x, 50, this.shadeDirection), getY(y, 50, this.shadeDirection));
this.lineTo(x, y);
this.lineTo(origin_x,origin_y);
this.endFill();
}
function newOrigin(upX, upY) {
clearInterval(this.intervalID) ;
drawShading(upX, upY) ;
this.origin_y = (this.origin_y + upY) /2
this.origin_x = (this.origin_x + upX) /2
this.direction =Math.random() * 360 ;
this.shadeDirection = ((direction + 90) > 360) ? (direction + 90) - 360 : (direction + 90);
this.iterations = 1 ;
this.shade_rbg = randomColor() ;
this.intervalID = setInterval(this, "draw", 10) ;
}
function getY(y:Number, distance:Number, angle:Number):Number {
return (y + (distance * Math.cos((Math.PI / 180) * angle))) ;
}
function getX(x:Number, distance:Number, angle:Number):Number {
return (x + (distance * Math.sin((Math.PI / 180) * angle))) ;
}
}
BeginFill() Problems With Filling Shape
hi,
what's wrong with this code it wont' work ????
_root.createEmptyMovieClip("shape", 50);
_root.cordXtmp = new Array("");
_root.cordYtmp = new Array("");
//I will not include the code that stores values into array
//I've checked array does contain values but decimals
//so I had to use Math.round()
function shape()
{
shape.moveTo(Math.round(_root.cordXtmp[0]), Math.round (_root.cordYtmp[0]));
beginFill(0xff22ff, 80);
for(i=1;i<32;i++)
{
shape.lineTo(Math.round(_root.cordXtmp[i]), Math.round(_root.cordYtmp[i]));
}
shape.endFill();
}
What's the trick with this beginFill() it works ok if I manually tupe some values but I can't get it to work with array and dynamically populated values. Anyone please ideas ???
cheers
BeginFill() With CreateEmptyMovieClip Doesn't Work
I am able to create the outline shape of the movie clip, but it won't fill:
code:
PoleDrawing_mc.createEmptyMovieClip("Pole_mc",100) ;
with(PoleDrawing_mc.Pole_mc)
{
//draw left side of pole
lineStyle(lineWeight,lineColor,lineOpac);
beginFill(0xff9900, 100);
moveTo(topLeftSide,0);
lineTo(btmLeftSide,poleDisplayHeight);
//draw right side of pole
lineStyle(lineWeight,lineColor,lineOpac);
moveTo(topRightSide,0);
lineTo(btmRightSide,poleDisplayHeight);
//draw top side of pole
lineStyle(lineWeight,lineColor,lineOpac);
moveTo(topLeftSide,0);
lineTo(topRightSide,0);
//draw bottom side of pole
lineStyle(lineWeight,lineColor,lineOpac);
moveTo(btmLeftSide,poleDisplayHeight);
lineTo(btmRightSide,poleDisplayHeight);
endFill();
}
Any ideas? Thank you!
BeginFill Problem With Flash 8.. Need Little Help In This Guys
hello every body
i can't coloring my MC i don't know why
i made movie clip with instant name "my_mc"
am trying to change the color or fill it again with an other color but no hope
ummm
i used this
Code:
my_mc.beginFill(0xCCCCCC);
my_mc.endFill();
am i right in using this function to do what i want ??
fla attached with this post
regards
Movieclip.beginFill Doesnt Seem To Work
Hi im currently working on making and filling closed figures with straight lines.
A portion of my code is as such.
Code:
name = "line"+number_line;
mc0 = _root.createEmptyMovieClip(name, number_line);
mc0.lineStyle(1, 0x1919B3, 100);
number_line++;
name = "line"+number_line;
mc1 = _root.createEmptyMovieClip(name, number_line);
mc0.moveTo(xArray[0], yArray[0]);
mc1.moveTo(_root[state](xArray[0], yArray[0]).x, _root[state](xArray[0], yArray[0]).y);
mc0.beginFill(x0ffffff, 100);
for (var i = 0; i<arrayPos; i++) {
if (xArray[i+1] != undefined || xArray[i+1] != null) {
mc0.lineTo(xArray[i+1], yArray[i+1]);
mc1.lineStyle(1, 0x12127D, 100);
mc1.lineTo(_root[state](xArray[i+1], yArray[i+1]).x, _root[state](xArray[i+1], yArray[i+1]).y);
number_line++;
}
}
xArray and yArray are the arrays that stores each line position and i am wonder why begin fill does nothing, please advise, thanks in adv!
Making A Hexi Value Into A Uint For BeginFill
Im using the kuler API to colour some parts of my site.
The hexi vales recieved are in a 6 figure format (theHexi = 334422 for example). This works fine if I want to colour text, as I can convert the hexi to a String (like "0x" + theHexi ) and add the reference to the text format.color and it works fine. However if I want to colour using a beginFill(), I get stuck, as the value needed is a uint (the format.color value required is an Object). I have tried using parseInt (theHexi ) and parseInt ("0x" + theHexi ) but it just creates a grey fill. Does anyone know how make 334422 into 0x334422 with out turning it into a String first.
Thanks.
Point Validation & Expanding Holes Via BeginFill
so I've got a shape drawn via actionscript's drawing tools. I also have it set up so that dragging the mouse does a moveTo and then uses lineTo to plot the points which are connected as a new path & filled along with the shape since they take place before the shape's endFill occurs.
Thus dragging a circle inside my triangle cuts a hole in that triangle since it's inverting the fill of the triangle. Drawing another shape in the triangle cuts another separate hole. This works fine.
However, that's part of the problem - that each path is an inversion of what lies beneath. So in my above example, drawing a circle in the triangle creates a hole; however, drawing a square within the circle refills the square instead of keeping it hollow.
How can i ensure that every dragged path is removed (and never inverted).
I found this snowflake generator but have no idea how they're always removing & never inverting.
http://www.popularfront.com/snowdays
[F8] TextField Background Covering Up Something I've Drawn Using BeginFill
My road block/mental block is this: I am making a menu system. Submenus (that is, a menu inside a menu) have a small arrow on them indicating that they are submenus. I drew them using the MovieClip.beginFill method. It worked like a charm until I added a background to my TextField object. Once I did that, the drawn arrow does not show up anymore. I am assuming that the TextField.background is covering it up...? The TextField's background is unfortunately necessary. Can anybody help me out on this one and get my little pretty arrows to show up? Thanks a lot! Here's the relative code:
Code:
// the variable "entry" is a MovieClip and the variable "fmt" is a TextFormat
// they were declared earlier
// creating the TextField and setting some properties
var entryTxt:TextField = entry.createTextField("name", entry.getNextHighestDepth(), 0, 0, entry_width + 15, 25);
entryTxt.text = node.childNodes[j].attributes.name;
entryTxt.border = true;
entryTxt.borderColor = 0x990000;
entryTxt.background = true;
entryTxt.backgroundColor = 0xffffff;
entryTxt.setTextFormat(fmt);
...
...
...
if (node.childNodes[j].childNodes.length != 0) {
// draws the triangle indicating a submenu
entry.beginFill(0x000000);
entry.moveTo(entry._width - 10, 17.5);
entry.lineTo(entry._width - 2, 12.5);
entry.lineTo(entry._width - 10, 7.5);
entry.lineTo(entry._width - 10, 17.5);
entry.endFill();
...
...
...
}
BeginFill Without MoveTo Creates Weird Fill
Hi I encountered this weird scenario. Don't know if this is the expected behavior. As far as I could see in the reference manuals, the beginFill() method of the flash.display.Graphics class ends any previous incomplete (i.e., not ending back at the start point) fills by automatically drawing a line to the latest MoveTo() location.
But, it seems it also ends any previous incomplete drawing even without fills, by drawing that final line.
But that's ok. The weird part is, even when I draw just one line and begin a fill immediately after that, I guess it tries to complete that line by drawing one more line back to the starting point and the messes up the display with the fill color in the following beginFill() call.
public class MyContainer extends Container
{
public function MyContainer()
{
1this.graphics.lineStyle(1, 0xFF0000);
2this.graphics.moveTo(5,5);
3this.graphics.lineTo(50,50);
4 // the following line messes up the display with the fill color
5this.graphics.beginFill(0x00FF00);
6this.graphics.drawCircle(20,40,5);
7this.graphics.endFill();
8this.graphics.lineStyle(1, 0xFF0000);
9this.graphics.moveTo(5,65);
10this.graphics.lineTo(50,110);
11this.graphics.moveTo(1000,1000); // this moveTo() prevents the weird fill that is seen in the above case
12this.graphics.beginFill(0x00FF00);
13this.graphics.drawCircle(20,100,5);
14this.graphics.endFill();
}
}
The output is as in the attachment. The first part creates a weird fill along the side of the line till the end of the container object. I even tried a endFill() at line 4, but same result. The only way to prevent this is to explicitly moving to some point as in line 11. Is this the expected behavior?
Thanks,
Ravi
Call To A Possibly Undefined Method BeginFill
I am just getting going in AS3 and can't understand why this doesn't work. I have a static DrawBox method like so:
PHP Code:
package ls
{
import flash.display.*;
public class Utils extends Object
{
public function Utils (){}
public static function DrawBox (sp:Sprite, w:Number, h:Number,pColor:uint, pAlpha:Number):void
{
sp.beginFill(pColor, pAlpha);
sp.lineTo(w, 0);
sp.lineTo(w, h);
sp.lineTo(0, h);
sp.lineTo(0, 0);
sp.endFill();
}
}
}
I call this from a different class like so:
PHP Code:
var bg:Sprite = new Sprite();
Utils.DrawBox (bg, _w, _h, 0xffff00, 1);
but I get the error:
1061: Call to a possibly undefined method beginFill through a reference with static type flash.display:Sprite.
What's the catch? Is it because it's a static function? Do i need to cast something? Any help appreciated.
Creating A Shape With Mouse Co-ordinates - Prob With BeginFill()
Hey guys
I am trying to create a drawing tool kinda like the polygon tool in windows paint. I am almost there but am having problems with beginFill() and endFill()
The user clicks on the polygon btn and then on the canvas, a new MC is created and at this point I state;
"_root.holder.Poly_holder.beginFill(0x00FFFF, 100);"
As I continue to draw lines it fills the incomplete shape!?! Even that I have not used endFill() yet which is in a btn in the MC I created at 0,0. This would not be so bad but for some reason the beginFill() code is causing it ti occasionally (with no real pattern that I can see) draw a line to the start point (take out the beginFill code and the problem stops).
Am I doing something wrong? Is it possible to only fill it when I know the shape is complete?
Thanks in advance
Ol
How To Change Stacking Of Buttons (or How To Change Play To Pause Button)?
My problem is I want to have one button for play and pause music playing in Flash.
Music starts automaticaly, so Pause button is visible. When user presses Pause button, I want to show him Play button on the top of Pause button.
Shortly: Music is playing = visible Pause button
Music is paused = visible Play button
Is anywhere tutorial or explanation.
THX very much for hints
Jan
Button Change Color On Select, Then Change Back
I have 3 buttons, named but,but2,but3. What I want is if you click a button it changes color to show what page your on. But when you click a different button now that one is highlighted and the original one goes back to the original color. Here's the code.
but3.onPress = function () {
_root.createEmptyMovieClip("container", 1);
loadMovie("banner3.swf", "container");
container._x = 0;
container._y = 0 ;
I figure I have to add some kind of if statement?
}
Duplicated MCs Don't Know Who They Are.
Hey everyone-
I'm using duplicatemovieclip to copy a MC text box (with embedded button) onto the stage a variable # of times. This works fine and the dynamic text in the new MCs are updating properly ( option1, option2, option3 ). My problem is how to use these newly-created buttons in the duplicated Mcs. I'd like to be able to have each button call a function like 'dosomething(copynumber)'. But how do you populate the variable 'copynumber' in the duplicated MC? Is there some way for a duplicated clip to know its duplication number?
any thoughts would be appreciated,
thanx in A
Where Did The Duplicated MC Go?
Hey...
I duplicate a MovieClip 25 times containing a textfield with variable name "text".
Then I try to set some text in the new textfield in the new MC, but that's where my luck runs out. Nothing happens!
Code:
for(i=1; i<=25; i++) {
duplicateMovieClip(_root.actions.teksten.stukje, "stukje"+i, i);
set("_root.actions.teksten.stukje"+i+".text", "bla bla bla");
}
Does something happen with the path of the duplicated MC's?
Let me know if you have any idea's!
Duplicated MC's That Are Not In.
I've set up:
duplicateMovieClip (obj0, "obj" + zp, zp);
which makes a duplicate of obj0, but I have to include the instance and name it obj0. I want to be able to make a duplicate of the original instance. I used the linker and exported it to first frame, but it still doesn't catch..
Can This Be Duplicated?
I'm trying to make a similar presentation
http://aboundance.economicpower.com/showme.asp
Is there a way to do this or buy a template, i really like the talking.
Thanks...
How To Contain Duplicated MC?
I'm trying to duplicate a movie clip, no problems, and place it randomly on the canvas. But, I don't want it to get cut off by the edge of the canvas. How can I make sure that when placing the clip, it won't be placed off the edge so it looks cut in half?
Here is what I've got so far:
http://www.stochasticaphelion.com/te.../Flower_2.html
Here is my code:
//intialize variables
var i;
var klip = _root.flower;
var tempX, tempY;
//function to duplicate movie clip
while (i < 40) {
// increment integer count
i += 1;
// duplicate mc klip
duplicateMovieClip(klip, i, i);
// place it
tempX = (Math.random() * 600) +klip._width;
tempY = (Math.random() * 600) +klip._height;
while (tempX > 600 || tempY > 600 || tempX < 0 || tempY < 0) {
tempX = (Math.random() * 600) +klip._width;
tempY = (Math.random() * 600) +klip._height;
* * }
* *
klip._x = tempX - klip._width;
klip._y = tempY - klip._height;
//scale it
klip._xscale = (Math.random() * 100);
klip._yscale = klip._xscale;
}
Anyhelp would be appreciated!
Thanks.
Jeff Seal
How To Change The Website Position With Resolution Change
Hello
Well i just finished my 100% flash based website...the problem im having is that when i view it in 800 x 600 resolution it is postioned at the center of IE 6 browser. But when i view it in 1024 x 768 resolution it is positioned at top left hand corner...i want it in center in 1024 x 768 resolution...plzzz help quickly as i finished evrthing n im stuck with this...thnx...
also you can better understand what im saying if you visit: http://www.playersclubrestaurant.com/
their site position changes with resolution change
Repositioning Duplicated MC's
I have a dynamic number of duplicated movieclips, arranged in a line horizontally.
When you rollover one an OnClipEvent script enlarges the clip, and depending on where it is, alters the clip's _x position, causing potential overlapping.
How do I tell the other movieclips (assume there's five) to shift their own _x in relation to the clip I have rolled over, so that there will be no overlapping?
thanks people.
Can't Set If Statement On Duplicated MCs
That may sound dumb, but..
I'm duplicating MCs within a key.hit condition. That works fine, but later in the code, i want to check a hitTest from ANY of those duplicated MCs with another MC.
My idea was:
x = x + 1
duplicateMovieClip (oneMC, "oneMC"+x, x)
"oneMC"+x.hitTest(otherMC)
in the code these levels range from 50 to 75, then back to 50.
I've tried all combination od dashes, slashs, points and " "'s i could imagine. Somehow i think my logic is flawed. Help me.
Thanks
Duplicated Hittest
I tried to hittest duplicated movie clips but it doesn't work. Is there any way to do that?
thanx
Remove Duplicated Mc`s
Hi all
I have two mc`s 1 is main circle and other is small circle
the small circle gets 25 times duplicated.
coden frame 1
max = 25;
for (i=0; i<=max; i++) {
duplicateMovieClip ("follow", "follow" + i, i);
}
instance
main circle=lead
small circle=follow
everything is placed on frame 1....the animation happens while preloading....after it has finished loading, it jumps to frame three.....(at this time I want both mc to remove from the stage)
the code on small circle:
onClipEvent (load) {
this._x = random(700) + 25;
this._y = random(325) + 25;
speed = random(10) + 10;
diff = 100;
}
onClipEvent (enterFrame) {
rand = random(20);
if (rand == 1) {
overshootx = random(diff) - diff/2;
}
if (rand == 2) {
overshooty = random(diff) - diff/2;
}
// chase
target_x = _root.lead._x + overshootx;
target_y = _root.lead._y + overshooty;
this_x = GetProperty(/:this,_x);
this_y = GetProperty(/:this,_y);
distance_x = target_x - this_x;
distance_y = target_y - this_y;
setProperty (/:this, _x, this_x + (distance_x/speed));
setProperty (/:this, _y, this_y + (distance_y/speed));
// rotate
theta = Math.atan(distance_y/distance_x) * (180/Math.PI);
if (distance_x > 0) {
theta = theta + 90;
}
if (distance_x < 0) {
theta = theta - 90;
}
setProperty (/:this, _rotation, theta);
}
thanks all for the reply
PilotX
[Edited by PilotX on 03-01-2002 at 05:50 AM]
|