views:

31

answers:

1

I'd really appreciate a point in the right direction, actionscript and flashbuilder are pretty new to me and i feel my knowledge has some pretty fundamental gaps in it still and I'm struggling to plug them.

Anyway.

So I have some rather simple circles based on an AS class called CircleA:

> Package components {  

>               import flash.display.Shape; 
>               import flash.display.Sprite;
>       
>               public class CircleA extends Sprite{
>       
>                   [Bindable] public var cirRadius:Number;
>                   [Bindable] public var cirX:Number;
>                   [Bindable] public var cirY:Number;
>                   [Bindable] public var cirColour:uint;
>               
>                   public function CircleA(cirRadius:Number, cirX:Number,
> cirY:Number, cirColour:uint){
>                       
>                       this.cirRadius = cirRadius;
>                       this.cirX = cirX;
>                       this.cirY = cirY;
>                       this.cirColour = cirColour;
>                       
>                       // creating a new shape instance
>                       var circle:Shape = new Shape( ); 
>                       // starting color filling
>                       circle.graphics.beginFill(this.cirColour , 1 );
>                       // drawing circle 
>                       circle.graphics.drawCircle( 0 , 0 ,this.cirRadius );
>                       // repositioning shape
>                       circle.x = this.cirX;                                 
>                       circle.y = this.cirY;
>                       
>                       // adding displayobject to the display list
>                       addChild( circle ); 
>                   
>               }
>               
>       }
> }

I've then taken a few of these and piled them into a spritevisualelement component of a flash builder mxml project:

>     <?xml version="1.0" encoding="utf-8"?>
>     <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
> 
>                  xmlns:s="library://ns.adobe.com/flex/spark"
> 
>                  xmlns:mx="library://ns.adobe.com/flex/mx"
>                  initialize="init();"
>                  minWidth="955" minHeight="600">
>       <fx:Declarations>
>       </fx:Declarations>
>       <fx:Script>
>           <![CDATA[       
>       
>               import components.*;
>               
>               import flash.display.Shape;
>               import flash.display.Sprite;        
>               
>               public var myCircleA:CircleA= new CircleA(15, 100, 50, 0x66990ff);
>               public var myCircleB:CircleA= new CircleA(20, 230, 30, 0x3399ff);
>               public var myCircleC:CircleA= new CircleA(25, 180, 90, 0x0033ff);
>               public var myCircleD:CircleA= new CircleA(20, 50, 20, 0x0000cc);
>               
>               private function init():void {
>                   myCircles.addChild(myCircleA);
>                   myCircles.addChild(myCircleB);
>                   myCircles.addChild(myCircleC);
>                   myCircles.addChild(myCircleD);
>               }
>               
>               //myCircleA.cirColour = 0x00ff33;
>     
>           ]]>
>       </fx:Script>
>       
>       <s:SpriteVisualElement id = "myCircles"/>
>                              
>       
>     </s:Application>

Now all of this actually works fine, however I now want to create a couple of functions that cause a random circle to change colour every couple of seconds and change the colour palette on click etc, but to do all of this I need to be able to change the variable values, cirColour specifically.

How do I do this?

My attempts typically end in an 1120 error claiming I'm trying to access an undefined property.

I feel stupid.

Thanks for your time.

Josh

A: 

dear Joshua, if you are using flashbuilder and flex 4 why not to use power of Spark components??

http://pastebin.com/Vs7ZuDdB

you could ask you questions here)

Eugene
Whilst I have been looking into this since, I still feel like this is a fairly basic concept in Action Script and should probably know how to do it...Anyone know how i'd do this?Thanks.
Joshua
`myCircles.getChildAt(numberOfElementAdded)`;
Eugene
what, myCircles.getChildAt(numberOfElementAdded).circolour = *some number*; ?(would go and try it but not at my proper computer atm)thanks though
Joshua
did you check the source from link above?
Eugene