PDA

View Full Version : Flex Virgin


dub_beat
03-02-2009, 04:20 PM
Hi,

I'm new to flex as of today.

I have an existing as3 project that i want to "sit" in an mxml application.

How can I do this
My original main.as file looks like this

package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
import framework.Controller;
import framework.IController;
import framework.Model;
import framework.IModel;
import framework.View;
import flash.display.MovieClip;
import flash.events.MouseEvent

/**
* ...
* @author DefaultUser (Tools -> Custom Arguments...)
*/




public class Main extends MovieClip
{
/*
* GUI Variables
* */
public var _loadButton:MovieClip = new MovieClip();
public var _playButton:MovieClip = new MovieClip();
public var _stopButton:MovieClip = new MovieClip();
public var _infotext:TextField = new TextField();
/**
* FRAMEWORK VARIABLES
*/
public var model:IModel = new Model( );
public var controller:IController = new Controller(model);
public var view:View;


public var maintxtx:TextField = new TextField();


public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}

private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
stage.align = "TL";
stage.scaleMode = "noScale";
stage.frameRate = 30;

view = new View(model, controller, this);



initGUI();
}
/**
* LOADING TRACK GUI
*/
private function initGUI():void
{
view.initGUI();
view.addLoadingUIListeners();

}


}

}

Now I want to do something like this


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init">

<mx:Script>
<![CDATA[

public var _loadButton:MovieClip = new MovieClip();
public var _playButton:MovieClip = new MovieClip();
public var _stopButton:MovieClip = new MovieClip();
public var _infotext:TextField = new TextField();

public var model:IModel = new Model( );
public var controller:IController = new Controller(model);
public var view:View;
view = new View(model, controller, this);



public function init():void

{
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
import framework.Controller;
import framework.IController;
import framework.Model;
import framework.IModel;
import framework.View;
import flash.display.MovieClip;
import flash.events.MouseEvent

view = new View(model, controller, this);
_tracklist = new TrackList();
_cliplist = new ClipList();
_info = new Info();
_waveEditor = new WaveFormEditor();
_playhead = new Playhead()
addChild(_tracklist)
addChild(_cliplist)
_main.addChild(_info)


/*PLAYBACK GUI*/
_loadButton.graphics.beginFill(0xf5f5f5);
_loadButton.graphics.drawRoundRect(50, 50, 50, 50, 3, 3);
_loadButton.graphics.endFill();
_loadButton.buttonMode = true;
addChild(_loadButton)
_playButton.graphics.beginFill(0x00ff00);
_playButton.graphics.drawRoundRect(100, 50, 50, 50, 3, 3);
_playButton.graphics.endFill();
_playButton.buttonMode = true;
addChild(_playButton);





}
]]>
</mx:Script>




</mx:Application>



Im likely way off here . for example i get errors saying that loadbutton doesnt exsist. Also I get errors saying addChild isnt a recognised function name

Can somebody help me get off the ground?