Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-24-2012, 07:55 AM   #1
crapageddon
White Belt
 
Join Date: Oct 2011
Posts: 80
Default Flex 4 & Flash Pro linkage issue?

Just started using Flash Pro in conjunction with Flash Builder 4.6. so I hope this is a noob-fix.

*Clarified question, see above.

Last edited by crapageddon; 07-29-2012 at 09:53 PM.
crapageddon is offline   Reply With Quote
Old 07-28-2012, 08:10 PM   #2
crapageddon
White Belt
 
Join Date: Oct 2011
Posts: 80
Default

Flash Professional Project, using FLEX 4 to edit code:
I can add the game and player to the stage, but they have no functionality. I don't believe my AS3 code is being used or seen? Is there a conflict between the linkage name in Flash Pro, and the class in the package?

I created the classes via 'edit class' and chose 'flash builder' but they don't seem to be connected. Anyone know what I'm doing wrong. I'm new to FB so it may be a basic setup issue.

FLASH PRO LIBRARY


FLEX DIR


TestGameA.as
Code:
package
{
	import gamepack.*;
	
	import flash.display.Sprite;
	
	public class TestGameA extends Sprite
	{
		public var game:Game;
		public var p1:Player;
		
		public function TestGameA()
		{
			trace("I am TestGameA constructor");
			addChild(game = new Game());
			game.x = 300;
			game.y = 300;
			addChild(p1 = new Player());
		}
	}
}
Game.as
Code:
package gamepack
{
	import flash.display.MovieClip;
	
	public class Game extends MovieClip
	{
		public function Game()
		{
			trace ("I am Game Constructor");
		}
	}
}
Player.as
Code:
package gamepack
{
	import flash.events.*;
	import flash.display.*;
	import flash.ui.*;
	
	public class Player extends MovieClip
	{	
		public var pSpeed:Number = 5;
		
		//CONSTRUCTOR
		public function Player()
		{
			trace ("I am Player Constructor");
			addEventListener(Event.ADDED_TO_STAGE, pLoaded);
		}
		
		//ADDED TO STAGE
		public function pLoaded(e:Event):void
		{
			trace("player wants to move");
			gotoAndStop(1);
			addEventListener(KeyboardEvent.KEY_DOWN, pInput);
		}
		
		//KEYBOARD MOVEMENT
		function pInput(key:KeyboardEvent):void
		{
			switch (key.keyCode)
			{
				case 37 ://Left
					scaleX = -1; //flip horiz.
					x -=  pSpeed;
					break;
				
				case 39 ://Right
					scaleX = 1; //flip horiz.
					x +=  pSpeed;
					break;
				
				case 38 ://Up 
					y -=  pSpeed;
					break;
				
				case 40 ://Down
					y +=  pSpeed;
					break;
			}
			
	}
}

Last edited by crapageddon; 07-29-2012 at 10:29 PM.
crapageddon is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:12 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.