ActionScript 3.0 :: Shapes Drawn Dynamically Treated Differently
Sep 15, 2009
I was just conducting a little experiment, basically trying to come up with a stage resizing handler that would position everything on the stage with its x and y proportionate to its original position. That's when I discovered a very interesting thing.
Shapes that you draw using flash's drawing tools are treated completely differently than dynamically drawn shapes. Basically shapes you draw on the stage in the authoring tool would seem to have no x and y of their own, and also no matter how many different shapes you draw, to the compiler it's all one "child" object because it's all just one big shape.
To illustrate this difference, I created two separate files, but they both (seemingly) do essentially the same thing. In the first file, I drew a red circle shape dynamically with code, and set its x and y with code:
ActionScript Code:
var circle:Shape = new Shape();
var g:Graphics = circle.graphics;
g.beginFill(0xFF0000);
[code]...
In a second file, I manually drew a similar red circle shape, made it 100 pixels wide and tall, and positioned it at 100, 100 using the properties panel. This time, I took away the code that creates the circle dynamically and just kept the for loop:
ActionScript Code:
for(var i:int = 0; i < this.numChildren; i++) {
var item:DisplayObject = this.getChildAt(i) as DisplayObject;
trace(item); //[object Shape]
trace(item.x); //0
trace(item.y); //0
}
In this second example, no matter how many and what kinds of shapes you draw, there will only ever be one display child and the x and y is always 0,0.
I for one kind of wish there were more of a one-to-one correspondence between the Flash IDE and the code window. Like, if we can create Shapes and name them dynamically, why can't we create Shapes and name them at authoring time? Or why isn't this now the role of the good ol' Graphics symbol? It's kind of like Flash and Actionscript have outgrown the authoring environment.
This would seem to have the effect of further widening the gap between design and development. Just thought I'd throw all this out there and see what kind of comments I get.
View 2 Replies
Similar Posts:
Apr 2, 2011
Is it possible to use a dynamically drawn line as a mask? (graphics.lineTo...) . Is there a way to cast this as a movieClip? I tried adding it to the movieClip, but that did not work.
View 4 Replies
Jan 22, 2010
How can i easily break the shape into two pieces so that I can change them into movie clips?I tried using the selection tool combined with shift key to create selections but the selection tool only does squares so it's very frustrating to select a portion of my drawing precisely using it, i've given up
View 1 Replies
Nov 1, 2010
How do you resize shapes drawn in actionscript?
I need to create a skewed rectangle and on rollover, have the right edge move outwards.. making the skewed rectangle wider.. while keeping the proportions.[code]...
View 1 Replies
Oct 23, 2005
I have been looking for a preloader such as the one at [URL]. The preloader there is just the effect I've been looking for for a long time. I know it's done with scripting, but I could never make it quite right. I even posted here a few times, and found a tutorial, but it used a drag bar to control it, not bytesLoaded. Any tutorials that you could lead me to that focus on making it a preloader
View 14 Replies
Dec 7, 2010
I seached everywhere and try fo find drawing board code that saves after drawing but it seems it's only applicable in AS3, perhaps anyone have any tutorial link or have
View 2 Replies
Jul 17, 2011
I made a rounded rectangle in as3 and would like to expand it on click. This is the code I use:
var lesBg:Sprite = new Sprite();
with (lesBg.graphics) {
lineStyle(3, 0x61b157);[code].....
When I click on it I would like it to expand to twice its size. I'm doing this with TweenLite but when I expand it I get ugly pixelated images and the borders expand too.
Tweenlite.to(lesBg, 1,{width: 380});
Is it possible to expand the image so it stays clean and the borders stay intact?
View 2 Replies
Jul 7, 2010
I am trying to dynamically draw a circle and fill it up with some color. Drawing a circle is pretty easy job for me, but fill it up with some color seems not happening today.
PHP Code:
Circle function starts
function fnDrawArc(mc,x,y,r,angle){
mc.beginFill(0xFF0000); // this is not working....
mc.moveTo(x+r,y);
for(i=1;i<=angle;i++){
[Code] .....
View 1 Replies
Mar 14, 2012
I have a Group on my View, and i'm trying to fill it with some collor and add an mouse event on it, all dynamicaly.the problem is, when i add the mouse event, the group simply turns invisible again. It still exists on the view and responds normally to the mouse event, but i cant see it.here's an code example:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView" creationComplete="onCreationComplete()" >[code]......
without the mouse event, the group is visible, but it vanishes when i try to add it. i've tried with other events, like the ENTER_FRAME Event and it works normaly, but all the mouse events that i tried turn the Group invisible.i've actually solved my problem using the opaqueBackground property, the Group don't vanish when i add the event this whay. But now i'm curious about the reason of this behavior.
View 1 Replies
Feb 23, 2005
I want to make a dynamically (using Drawing API) drawn ellipse rotate around its axis. It involves a lot of trigonometry which I'm not very good in .
View 7 Replies
May 14, 2005
I had to create dynamic with AS some rectangular on stage using moveTO and lineTo. I had a button and when I press it should add a new rectangle on stage but it doesn't. Because the array that I am storing the MovieClip created are overriding I guess
var i:Number =0;
button_name.onRelease = function() {
i++;
var instancename:String ="new_mc"+i;
var mcClip:MovieClip=createEmptyMovieClipinstancename,this.getNextHighestDepth);
[Code] .....
View 1 Replies
Feb 23, 2005
I want to make a dynamically (using Drawing API) drawn ellipse rotate around its axis. It involves a lot of trigonometry which I'm not very good in .
View 7 Replies
Mar 31, 2012
i want to be able to create multiple shapes and store them perhaps in an array to be able to dynamically move them and change them.is there a way to have a shape object and store it an array?so that i can do something like shapeArray[0].x =100 current code
for(var i=0; i<10; i++){
var sprite:Sprite=new Sprite();
sprite.graphics.lineStyle(1)
[code]...
View 1 Replies
Jul 1, 2011
I'm trying to write a little flex app that has a paint/canvas type feature to draw an image, which I then want to post to a rails server side. I'm following the post here, but can't get as far as he did due to the following error: NoMethodError (undefined method `rewind' for #):I googled that and found this which says the problem is due to an empty filename, but I thought I had that from the example. However, I altered the example to simplify the post by reducing the form parameters, but I could have easily messed something up since I really don't know what I'm doing with this multipart form content. I was hoping to at least log the request params, but unfortunately I can't, since it's failing before being routed and due to my inexperience with rails. I'll ask that in a separate question and hopefully be able to edit this question with the request params.
View 1 Replies
Feb 17, 2009
I have a question about shapes (i mean the flash.display.Shape class). Is it possible to import Shapes directly from the library as Shapes and not as Sprites/MovieClips? Shapes are supposed to be faster than MovieClips/Sprites, right? So why is it only possible to import MCs/Sprites from the library? I understand that generally shapes could be created solely by actionscript, but in my case the shape comprises of many points and is curved - so it's quite infeasible.
Is there maybe some sort of plugin to generate code that would draw the desired shape from a drawn shape in CS4? And a last one: Are there any benchmarks out there for performance comparison between sprites/mcs/shapes? How much performance do i loose by using a sprite instead of a shape?
View 2 Replies
Sep 22, 2009
I have an application that is trying to sort of scores. The problem is that when it tries to sort it errors as it is checking if one string is less than another string when it should be doing one number less than another number.
I have played with parseInt but I haven't managed to get it to work?
Code:
this.onEnterFrame = function() {
if (parseInt(yourtime_txt.text)<parseInt(pos1time_txt.text)) {
pos1time_txt.text = parseInt(yourtime_txt.text);
[Code].....
View 7 Replies
Nov 11, 2009
Basically I'm creating two (can be more or less) rows of layered MC treaten as Buttons.In each MC there is a small thumbnail hidden behind a coloured layer. When roll_over the coloured layer, this alpha goes to 0(zero) and entire MC resize +10% over x and y.On roll_out the opposite occurs, everything should get to the original alpha and size.The Problem: when moving the mouse really fast over the MC's and stop suddenly over one of them it starts 'blinking'
Code:
for(var i:uint =0; i<16; i++){
var miniPnt:MovieClip=new LittlePantone();
miniPnt.x=_xc;
miniPnt.y=_yc;
[code]....
View 2 Replies
Aug 24, 2010
I'm linking an XML document to a Flash file to control all sorts of things and it's going quite well until i tried to fill a dynamic text field with a paragraph of type from the XML document. I've done this a million times in AS2 and I've done it in AS3 using attributes, but this time I'm using childNodes. The dynamic text field is in a movieclip. When I tested it using this code:
var oneComments:String=xmlTestOne.firstChild.childNode s[num].childNodes[1];
oneClip.txtComment.text=oneComments;
...it sort of worked but I get the element tags along with the paragraph text.
[code].....
View 4 Replies
Mar 23, 2010
Does anyone have an idea as to why this happens?The dropdown menus work fine (they are a flash app)The dropdown menus do not work.I'm unfamiliar with how to make a redirect if they just type the url without the 'www'
View 4 Replies
Oct 13, 2009
I am loading an xml file using AS2.0. On Mac, all the elements load completely, but as soon as I run it on Windows, only the first element of type item loads. When I run it on Mac, the elements are loaded in and all item's are separate buttons. When I run it on Windows, only one button appears and its name is ch1. Virgin Group Holdings. None of the other item elements load. I don't have a Windows versions of Flash to work on, so I cannot debug.Is there another way to determine if this has to do with the XML file loading incompletely or with the depths of the Movieclips? Here is the URL
Here is my XML:
<?xml version="1.0" encoding="UTF-8"?>
<menu>
<item link="vgh" name="ch1. Virgin Group Holdings" movie="VirleoGH">
[code]....
I am now running this file from a remote server (Linux box), but still only the first element loads on Windows, with no siblings. On Mac, everything loads fine, I am at a dead end, my deadline (draft #2) for this is in about 12hours and I still need to get a night's rest in. Does anyone have the slightest inkling what this could be? Any pointers or advice will be cordially accepted. The url.
I am now debugging in Windows and have found that the XML file does get loaded completely eventually. What is odd is that I trace the _x and _y values of all the movieclips, and all change constantly to an acceptable value, but still only the first-added movieclip is visible on the stage. I have traced their depths which do in fact differ, they are enabled (traced), they are _visible (traced that also), everything works perfect on Mac, except when I run it on Windows, so clearly, Flash Player in Windows in doing something unexpected, has anybody encountered this before?
View 3 Replies
Jul 27, 2009
ave anyone run into a SWF acting differently when loaded in IE8? I just finished a banner/header for a client that is working perfectly except when loaded in IE8, here is what is happening...
[URL]
Basically my masks are not being loaded on init()... I'm loading external XML so I'm thinking it might have something to do with that.
View 2 Replies
Feb 3, 2010
Player :Flash 9Script : AS3IDE : Adobe Flash CS3I have 9 dynamic text fields; each is filled with text (a title). When you click one it updates two larger text fields at the top to display the title in the first one and the description in the second. When you hover over the text fields, the cursor remains an arrow.In the IDE, this script works just fine. However, when I upload it to my website, clicking on the titles does not change the large fields above them. Also, when I hover the mouse over any of the text fields but the very first one, the pointer changes to a text editing line.
View 6 Replies
Sep 22, 2007
this code for a thumbnail gallery, the data is loaded from an XML file, [URL].. All the thumbnails are loading on the stage correctly and in the correct order when playing movie locally, but as soon as I try Simulate Download or view the movie from the web page the thumbnails lose there order.
[Code]..
View 1 Replies
Feb 4, 2009
I am programming in AS3. I've made a game that functions correctly every time on every computer I've tried except for one.I don't get any errors, but a movie clip that should be stopped seems to be playing through its sounds. The animation doesn't play, though! I can't reproduce the problem on any other machines, but it happens every time on that one.
View 1 Replies
Apr 28, 2009
I have one swf, and roughly 4 or 5 classes. when the swf loads, the document class places 3 movieclips onto the stage- one of them animates across the screen. Using the tween class, I listen for the COMPLETE tweenEvent, which when triggered, instatiates a slideshow class. the slideshow class loads in a series of pics.On safari(mac), linux, no issues. on firefox(mac), the 3 mc's never appear, but instead, there is the same time delay as if the animation did play, and then the pics DO load. my client says everything works fine on first load, but returning back to the page after navigating away causes the same problem I described above. THey are on IE- probably 7.
View 4 Replies
Sep 7, 2009
When I try to import an MP3 file (specs below) I just bought off Amazon into Flash CS4, I get an error that reads "One or more files were not imported because there were problems reading them." I tried other MP3 files and they worked no problem. Does anyone know if there's a specific type of MP3s that Flash hates? Maybe I need to convert my MP3 to be encoded differently?
[Code]...
View 2 Replies
Dec 24, 2010
I have an SWF file that works great when I publish it or view it in the Flash Player. However, when I use Simulate Download, all the buttons' functionality gets messed up - for some reason, clicking them results in the playhead going to other frames than it's supposed to. I've tried uploading the file to my website and the buttons don't work well there either.
View 3 Replies
Dec 24, 2010
I have an SWF file that works great when I publish it or view it in the Flash Player. However, when I use Simulate Download, all the buttons' functionality gets messed up - for some reason, clicking them results in the playhead going to other frames than it's supposed to. I've tried uploading the file to my website and the buttons don't work well there either. Is there any reason for this to happen?
View 2 Replies
Apr 8, 2011
if I drew a line or something, it would just be the line and I could immediately edit the shape. Now, there is a blue box surrounding it. what purpose the blue box serves. However, when this started, my fill stopped working.
I can fill a shape I have hand-drawn, but not when I use the line tool. I have included a screen shot of the blue box surrounding a line. I have assured that all sections of a shape are touching before trying to fill.
View 2 Replies
May 23, 2011
Are Flex swc file encoded differently from say movies file encode in SWC?
View 1 Replies