Moving part of the code to separate package

Hello guys,
I'm looking for some help with the following script:
Main Class:
package {
// Flash Classes
import flash.display.MovieClip;
import flash.events.Event;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
public class Main extends MovieClip {
private var projectSetupStageBgFill:String = "Solid";
private var projectSetupStageBgColor:uint = 0x333333;
  private var mainBg:MovieClip = new MovieClip();
  public function Main() {
   InitStage();
// ----------------------- Start ------------------------ // 
private function InitStage():void {
   if (projectSetupStageFullscreen) {
    stage.scaleMode = StageScaleMode.NO_SCALE;
    stage.align = StageAlign.TOP_LEFT;
   switch (projectSetupStageBgFill) {
    case "Solid":
    default:
     mainBg.graphics.beginFill(projectSetupStageBgColor);
     mainBg.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
     mainBg.graphics.endFill();
     addChild(mainBg);
     break;
// ----------------------- End ------------------------ //
Now, I'd like to move the script between --- Start --- and --- End --- comments, to the separate package. When I do that, I've got many reference errors.
Would anybody be able to show me, how the code should look like, when it's in separate package, with all the references to variables that work? And how to call this function from Main class?
Thx a lot!

Oh, if this is an exercise too, here is one of approaches
So, conceptually in the original code init method does two things:
1. Configures stage
2. Draws rectangle.
If we want to move these two functions outside the Main class, we will need to create at least two classes.
But, first, we need to organize our objects into packages. We need to create a directory tree.
1. create directory with the name com
2. inside com create directory named mydomain
3. inside domain we start branching:
Stage configurator is more like a utility class - let's make util subfolder of domain
Background belongs to graphics - let's create subfolder graphics in domain.
So, our final tree is:
com/domain/graphics
                  /utils
In utils folder we create StageConfig.as - we will move functionality related to stage configuration here
In graphics folder we create Rectangle.as - we will move functionality related to drawing rectangle here
These classes can be something like this:
package com.mydomain.utils
     import flash.display.Sprite;
     import flash.display.StageAlign;
     import flash.display.StageScaleMode;
     import flash.events.Event;
      * Extends Sprite so that we just place it
      * on display list and it gets access to stage
     public class StageConfig extends Sprite
          private var _scaleMode:String;
          private var _align:String = StageAlign.TOP_LEFT;
          public function StageConfig(scaleMode:String = StageScaleMode.NO_SCALE, align:String = StageAlign.TOP_LEFT)
               _scaleMode = scaleMode;
               _align = align;
               if (stage) init();
               else addEventListener(Event.ADDED_TO_STAGE, init);
          public function init(e:Event = null):void
               removeEventListener(Event.ADDED_TO_STAGE, init);
               stage.scaleMode = scaleMode;
               stage.align = align;
          public function get scaleMode():String { return _scaleMode; }
          public function set scaleMode(value:String):void
               _scaleMode = value;
               if(stage) stage.scaleMode = _scaleMode;
          public function get align():String { return _align; }
          public function set align(value:String):void
               _align = value;
               if(stage) stage.align = _align;
And Rectangle:
package com.mydomain.graphics
     import flash.display.Graphics;
     import flash.display.Sprite;
     import flash.events.Event;
     public class Rectangle extends Sprite
          public var fillColor:uint = 0xff0000;
          // set width
          public var w:Number = 100;
          public var h:Number = 100;
          public function Rectangle(w:Number, h:Number, fillColor:uint = 0xffffff)
               this.fillColor = fillColor;
               this.w = w;
               this.h = h;
               if (stage) init();
               else addEventListener(Event.ADDED_TO_STAGE, init);
          public function init(e:Event = null):void
               removeEventListener(Event.ADDED_TO_STAGE, init);
               var g:Graphics = this.graphics;
               g.beginFill(fillColor);
               g.drawRect(0, 0, w, h);
               g.endFill();
To accomodate these classes in Main.as:
package
     import com.mydomain.graphics.Rectangle;
     import com.mydomain.utils.StageConfig;
     import flash.display.MovieClip;
     import flash.events.Event;
     public class Main extends MovieClip
          // stage configurator
          private var stageConfig:StageConfig;
          // background object
          private var background:Rectangle;
          // background fill color
          private var projectSetupStageBgColor:uint = 0x333333;
          public function Main()
               if (stage) init();
               else addEventListener(Event.ADDED_TO_STAGE, init);
          private function init(e:Event = null):void
               removeEventListener(Event.ADDED_TO_STAGE, init);
               stageConfig = new StageConfig();
               addChild(stageConfig);
               background = new Rectangle(stage.stageWidth, stage.stageHeight, projectSetupStageBgColor);
               addChild(background);

Similar Messages

  • TS1292 I have recently received an iTunes card and after scraping away the panel to get my code the first part of the code is unreadable how do I go about getting a code for the card

    Hi there I have recently been given an iTunes card as a present.i went to use it today to put credit on my account and after scraping away the panel found that I couldn't read part of the code that was on the card how do I go about getting the card activated?

    If the page that you postted from doesn't help then you will need to try contacting iTunes support (you will need to give them as much of the serial number and activation code from the card as you can read) : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then iTunes Cards And Codes

  • Is there a way to redeem iTunes gift cards if part of the code has been scratched off?

    Is there a way to redeem iTunes gift cards if part of the code has been scratched off?

    With any luck, the following document may be of some assistance with that:
    iTunes Store: Invalid, inactive, or illegible codes

  • How do I copy different parts of the page into separate pdf files?

    I have Adobe Acrobat 9 Pro and an assortment of very large pdfs that I want to make into about a thousand individual pdfs.  The pages contain text and I want to be able to copy parts of the page into separate different pdfs.  It would be really nice if I could split up the page into the required sections by highlighting all the different sections on the page and then save each section to individual pdfs all at once.  Acrobat has so many features that I am hoping that it can do something like this.  Thanks  Anewbie282

    With the number of pages you are talking about, there is no real easy solution. However, try extracting the page(s) you want in a new file. After the extracted file exists, try using the object select tool to remove the parts you do not want. You might find using the redaction tool to zero out the parts you don't want might work better. Unfortunately, a PDF is not a word processor type data file and the editing is likely not going to be easy.

  • How to isolate the wait function to one part of the code

    I'm buildling an ecg montoring system along with programming an external stimulator using TTL pulses to work along side the information obtained from the ECG.The most important of  these features is the heart rate. However, whenever I activate my pulse trains in the code, the DAQmx Wait Until Done.vi function pauses everything in the code, including the part of my code that monitors the heart rate, which uses time to measure it. What I would like, is the wait function to only affect the pulse train generators without pausing anything else in the code. Is this possible? And if so how can I make it happen?
    I will attach my vi
    Solved!
    Go to Solution.
    Attachments:
    simulatejed.vi ‏130 KB

    Your problem is that everything is in the same loop.  So the longest operation is going to determine the loop rate (and therefore processing rate).  What you really need to do is separate your tasks into separate loops.  Use queues and/or notifiers to communicate your data and commands between loops.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • I bought $15 card for daughter and she scratched off part of the code.

    I BOUGHT A $15 CARD FOR MY DAUGHTER AND SHE SCRATCHED OFF THE CODE.

    Typing in all caps indicates shouting, is considered rude, and is difficult to read.
    Many do not read such posts.
    iTunes Store: Invalid, inactive, or illegible codes

  • How to read the time and then run different parts of the codes?

    I am new to LabView. I want to read the program running time and then decide what to do.
    For exaple, if time is less than 1s, output sin signal;if time is more than 1s, output sawteeth signal. It is easy to be implemented in C or Simulink, but seems difficult for me in LabView.
    Thanks.

    Hi, Bill,
    Thank you very much for your help.
    I changed your sample codes a little bit to get moving graph. I have three more questons:
    (1) If there are more cases, such as one for t=1s, the second for t=3.2s,and a third for t=6.9s, do I have to use multi-layer case structure, since it only checks the result if it is true or false?
    (2)Does labview provide us something to have the function such as 'switch...case' or 'if..else' in C/C++?
    (3)Is there anything for a time-based multi-segment function?
    Best wishes,
    Attachments:
    example2.vi ‏55 KB

  • Putting the part of the code on the block diagram in "comments" like we do in C

    Hi
    Like in C, if I dont want the compiler to see few lines of code I just // or /* them. Is there a way to do same thing for a loop on a block diagram in Labview.
    Kind Regards
    Austin

    Also note that the CONDITIONAL DISABLE structure will let you include/exclude things - I use it for debugging code.  It's like:
    #ifdef Debugging
        printf("Pressure is %0.1f, temp is %0.1f", P, T);
    #end if
    You define the symbols on the PROPERTIES page of the target, in the CONDITIONAL DISABLE SYMBOLS section.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

  • Is iPhoto part of the new Tiger OS package?

    Does iPhoto or iLife come with Tiger 10.4?

    That's what I thought. I just got a new G5 at work with Tiger on it and it has iLife installled on it. ****, that means I'll have to buy both Tiger and iLife. Thanks,

  • Is there a way to view the code screen and the design screen in separate windows

    Is there a way to view the code screen and the design screen in separate windows instead of connected. I would like to have the code on one monitor and the design on another

    You can open the Code Inspector Window to have the code completely separate from the Design/Document window. You can also then move the CI window to a separate monitor if you like.
    Window > Code Inspector or F10

  • Why dreamweaver add space in the code when i do this:...?

    Hi,
    look at those pictures below.. Those are the steps to show how dreamweaver reacts after a series of actions with part of the code in CODE VIEW...

    Hi Masa,
    Well the answer lies in how you are adding the indentation for better reading.
    I assume you added space of tab to add indentation. So you are doing that in reduced window width and your text wraps as per the width. But when you again resize the window to full lenght your text takes  full space and the spaces and tabs you added for indentation are moved into text itself which is normal (since you have added that space to text).
    So DW is now adding any space it is the space you added for indentation which is showing up when you go to full width view.
    Don't use such indentation for reading in code and anyways HTML will leave out such whitespaces when page renders.
    Hope that helped
    -Vinay

  • How to restructure this code into separate classes?

    I have C# code that initializes a force feedback joystick and plays an effect file(vibrates the joystick). I have turn the console application into library
    code to make a dll so that I can use it in LabVIEW. 
    Right now all the code is written under one class, so went I put the dll in LabVIEW I can only select that one class. labVIEW guy told me that I need to
    restructure my C# code into separate classes. Each class that I want to access from LabVIEW needs to marked as public. Then I can instantiate that class in LabVIEW using a constructor, and call methods and set properties of that class using invoke nodes and
    property nodes.
    How can I do this correctly? I tried changing some of them into classes but doesn't work. Can you guys take a look at the code to see if it is even possible
    to break the code into separate classes? Also, if it is possible can you guide me, suggest some reading/video, etc.
    Thank you
    using System;
    using System.Drawing;
    using System.Collections;
    using System.Windows.Forms;
    using Microsoft.DirectX.DirectInput;
    namespace JoystickProject
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    private System.Windows.Forms.Label label1;
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null;
    private Device device = null;
    private bool running = true;
    private ArrayList effectList = new ArrayList();
    private string joyState = "";
    public bool InitializeInput()
    // Create our joystick device
    foreach(DeviceInstance di in Manager.GetDevices(DeviceClass.GameControl,
    EnumDevicesFlags.AttachedOnly | EnumDevicesFlags.ForceFeeback))
    // Pick the first attached joystick we see
    device = new Device(di.InstanceGuid);
    break;
    if (device == null) // We couldn't find a joystick
    return false;
    device.SetDataFormat(DeviceDataFormat.Joystick);
    device.SetCooperativeLevel(this, CooperativeLevelFlags.Exclusive | CooperativeLevelFlags.Background);
    device.Properties.AxisModeAbsolute = true;
    device.Properties.AutoCenter = false;
    device.Acquire();
    // Enumerate any axes
    foreach(DeviceObjectInstance doi in device.Objects)
    if ((doi.ObjectId & (int)DeviceObjectTypeFlags.Axis) != 0)
    // We found an axis, set the range to a max of 10,000
    device.Properties.SetRange(ParameterHow.ById,
    doi.ObjectId, new InputRange(-5000, 5000));
    // Load our feedback file
    EffectList effects = null;
    effects = device.GetEffects(@"C:\MyEffectFile.ffe",
    FileEffectsFlags.ModifyIfNeeded);
    foreach(FileEffect fe in effects)
    EffectObject myEffect = new EffectObject(fe.EffectGuid, fe.EffectStruct,
    device);
    myEffect.Download();
    effectList.Add(myEffect);
    while(running)
    UpdateInputState();
    Application.DoEvents();
    return true;
    public void PlayEffects()
    // See if our effects are playing.
    foreach(EffectObject myEffect in effectList)
    //if (button0pressed == true)
    //MessageBox.Show("Button Pressed.");
    // myEffect.Start(1, EffectStartFlags.NoDownload);
    if (!myEffect.EffectStatus.Playing)
    // If not, play them
    myEffect.Start(1, EffectStartFlags.NoDownload);
    //button0pressed = true;
    protected override void OnClosed(EventArgs e)
    running = false;
    private void UpdateInputState()
    PlayEffects();
    // Check the joystick state
    JoystickState state = device.CurrentJoystickState;
    device.Poll();
    joyState = "Using JoystickState: \r\n";
    joyState += device.Properties.ProductName;
    joyState += "\n";
    joyState += device.ForceFeedbackState;
    joyState += "\n";
    joyState += state.ToString();
    byte[] buttons = state.GetButtons();
    for(int i = 0; i < buttons.Length; i++)
    joyState += string.Format("Button {0} {1}\r\n", i, buttons[i] != 0 ? "Pressed" : "Not Pressed");
    label1.Text = joyState;
    //if(buttons[0] != 0)
    //button0pressed = true;
    public Form1()
    // Required for Windows Form Designer support
    InitializeComponent();
    // TODO: Add any constructor code after InitializeComponent call
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    if( disposing )
    if (components != null)
    components.Dispose();
    base.Dispose( disposing );
    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    public void InitializeComponent()
    this.label1 = new System.Windows.Forms.Label();
    this.SuspendLayout();
    // label1
    this.label1.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
    this.label1.Location = new System.Drawing.Point(8, 8);
    this.label1.Name = "label1";
    this.label1.Size = new System.Drawing.Size(272, 488);
    this.label1.TabIndex = 0;
    // Form1
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.BackColor = System.Drawing.SystemColors.ControlText;
    this.ClientSize = new System.Drawing.Size(288, 502);
    this.Controls.AddRange(new System.Windows.Forms.Control[] {
    this.label1});
    this.Name = "Form1";
    this.Text = "Joystick Stuff";
    this.ResumeLayout(false);
    #endregion
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    using (Form1 frm = new Form1())
    frm.Show();
    if (!frm.InitializeInput())
    MessageBox.Show("Couldn't find a joystick.");

    Imho he means the following.
    Your class has performs two tasks:
    Controlling the joystick.
    Managing the joystick with a form.
    So I would recommend, that you separate the WinForm from the joystick code. E.g.
    namespace JoystickCtlLib
    public class JoystickControl
    private Device device = null;
    private bool running = true;
    private ArrayList effectList = new ArrayList();
    private string joyState = "";
    public string State { get { return this.joyState; } }
    public bool InitializeInput() { return true; }
    public void PlayEffects() { }
    private void UpdateInputState() { }
    So that your joystick class does not reference or uses any winform or button.
    btw, there is a thing which is more important than that: Your polling the device in the main thread of your application. This will block your main application. Imho this should be a job for a thread like background worker.

  • Unable to view code for procedures/packages in SQL workshop

    Hi
    1 The code window is blank when i try to view the code of any package/procedure in HTML DB sql workshop..
    2 Also when i try to describe HTMLDB_COLLECTIONS view it hangs..
    Am i missing any settings here..
    Thanks in advance
    Laks

    I understand the HTML DB collections view is populated by the HTML DB runtime but why does it hang the firefox browser when i just give a describe on it from sql window
    Also unable to view code for Stored program units ?...
    Anything i am missing or not aware of ?
    Thanks in advance
    Regards
    Laks

  • Viewing code of a package

    Oracle 9.2.0.5 on HP-UX 11.23.
    I tray to see the code of a package and I only see a encrypted code (of the package). I am doing this connected as the owner of this package.
    Any idea?

    Is the WRAP done by the developer as a free decision? This is, I can view the code of another packages. Does this means that the developer of this other packages decided not to WRAP the code?

  • Need Explaination for the Code

    I would like to understand the declaration part of the code and also the flow below
       DATA: L_S_RANGE Type RSR_S_RANGESID,
       DATA: LOC_VAR_RANGE like RRRANGEEXIT
    what is L_S_RANGE     and   RSR_S_RANGESID  ?
    what is LOC_VAR_RANGE     and    RRRANGEXIT ?
    l_s_range-low
    l_s_range -high
    l_s_range -sign = 'I'.
    l_s_range - opt = 'BT'.   or  'EQ'
    APPEND l_s_range to E_T_RANGE.

    Hi,
    what is L_S_RANGE and RSR_S_RANGESID ?
    See the Structure in SE11:  RRRANGESID
    TYPES: RSR_S_RANGESID TYPE rrrangesid,
           RSR_T_RANGESID TYPE Rsdd_T_RANGE,
           RSR_S_RANGEK   TYPE RRrange,
           RSR_T_RANGEK   TYPE RRKG_T_RANGEK,
           RSR_S_RANGES   TYPE RRKG_S_RANGES,
           RSR_T_RANGES   TYPE RRKG_T_RANGES.
    what is LOC_VAR_RANGE and RRRANGEXIT ?
    See the Structure in SE11: RRRANGEEXIT
    Thanks
    Reddy

Maybe you are looking for

  • Video to vector flash

    I will be getting a series of 10 second video's for a website. They would like me to recreate the video as animated silhouettes of the people in the video. To show basic fight moves. Is it possible to take the supplied video into Flash, remove the ba

  • Is there any way to scroll pie chart labels

    is there a way to have a scroll bar for the pie chart key Many thanks

  • Errors when installing Quicktime 7

    I purchased and installed Quicktime Pro. When I upgraded to Quicktime 7, I get error messages on my desktop. The movie file P1020888.MOV cannot be found. Without this file, the movie cannot play properly. (Cancel or search) I can't cancel this messag

  • Moving "My Digital Editions" folder

    I am trying to move the "My Digital Editions" folder from the default location under "My Documents". When I do so, I have to add my ebooks back to the library (which is OK), but Digital Editions also then adds a "My Digital Editions" folder with a ma

  • Number of Masters

    Hi, I was just wondering if the forum had any thoughts on the acceptible(optimal), number of master sites that could be used on a large global system with a slow network and very few data changes. TIA Marc