Rotate Dynamically added to stage object using AS3 in CS4

Trying to rotate an object that is dynamically added to the stage usin

Page 1 of 1

1 Replies - 4680 Views - Last Post: 02 January 2010 - 12:03 AM

#1 yogidishman   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 28-December 09

Rotate Dynamically added to stage object using AS3 in CS4

Post icon  Posted 28 December 2009 - 07:51 PM

/*Note that I am trying to make the object called Wheel1 (wh1) spin when it is dynamically placed on the stage. So far I have not been able to find any code that will allow me to dynamically retrieve an object from the library, place it on the stage and rotate it continuously.*/

var spinSpeed:Number =40;
var bg1:MovieClip = new Background2();
var bg2:MovieClip = new Background2();

var tk:MovieClip = new tractor();
var sp:MovieClip = new Spaceship();
var rd1:MovieClip = new road();
var rd2:MovieClip = new road();
var wh1:MovieClip = new Wheel1();
var xLowerLimit:int = 570 //the pixel width of the stage

'bg2.y = - bg1.height;'
bg2.x =0;
bg2.y=65
tk.y=150
tk.x=300
sp.x=400
sp.y=135
rd1.x=300
rd1.y=225
rd2.x=0
rd2.y=225
wh1.x=268
wh1.y=204
addChild(bg1);
addChild(rd1)
addChild(rd2)
addChild(bg2);
addChild(tk);
addChild(sp);
addChild(wh1);

addEventListener(Event.ENTER_FRAME, scroll);
function scroll(e:Event):void {
bg1.x += 1;
bg2.x += 1;
if (bg1.x > xLowerLimit) bg1.x = bg2.x - bg1.width;
if (bg2.x > xLowerLimit) bg2.x = bg1.x - bg2.width;

rd1.x += 1;
rd2.x += 1;
if (rd1.x > xLowerLimit) rd1.x = rd2.x - rd1.width;
if (rd2.x > xLowerLimit) rd2.x = rd1.x - rd2.width;
}

/

Is This A Good Question/Topic? 0
  • +

Replies To: Rotate Dynamically added to stage object using AS3 in CS4

#2 ponthedashboard   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 9
  • Joined: 24-December 09

Re: Rotate Dynamically added to stage object using AS3 in CS4

Posted 02 January 2010 - 12:03 AM

put this one in enter frame function
 
bg2.rotationX += 3; 



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1