Changing a document class to an imported class

Hello everybody!
My following document class is working fine. But, when I want to import it instead of using as a document class, it reports an error "1067: Implicit coercion of a value of type Class to an unrelated type flash.display:DisplayObject.". My class code is here:
package
import flash.display.Sprite;
import flash.display.Shape;
import flash.text.TextField;
import flash.events.MouseEvent;
public class Shapes extends Sprite
  var square: Sprite = new Sprite();
  var txt: TextField = new TextField();
  public function Shapes()
   square.graphics.lineStyle(4, 0xFF66CC);
   square.graphics.beginFill(0x990066);
   square.graphics.drawRect(250, 35, 175, 175);
   square.graphics.endFill();
   square.buttonMode = true;
   addChild(square);
   square.addEventListener(MouseEvent.CLICK, clickHandler);
   txt.text = "A Child of the Square";
   square.addChild(txt);
  function clickHandler(ev: MouseEvent): void
   if (square.numChildren > 0)
    square.removeChild(txt);
My FLA file script is as below:
import Shapes;
addChild(Shapes);
Seeking help, please!

You need to create an instance of the class Shapes and tha add this isntance
i.e. something like this
var shapes: Shapes = new Shapes();
addChild( shapes );

Similar Messages

  • Manually changing a document version number when importing an existing document

    Hello.
    Like a lot of people, we are starting to make use of Sharepoint Online as part of an Office 365 subscription.
    One of the things we want to do is move a bunch of version controlled documents from their current location on a traditional network file share into a Sharepoint Document library, and then use approval and version history to control and track changes.
    At the moment these are stored with the version number as part of the file name, so we have something like "Company car policy - version 6.docx". When there's a new version, the old one is moved to an archive folder and a new copy is saved as "Version
    7.docx" which is outdated and far from ideal.
    I've created my library, tested that approvals work, and have found instructions on how to use a workflow to notify people that changes have been made. That's all fine, but if I upload an existing document into the library it will start the version number
    at 0.1 or 1.0 depending on whether I add it as a draft or final.
    What I need to be able to do is to manually change the version number to match our existing system without having someone sit there checking a document in and out. Some of them have version numbers in the 20s so this would be a huge waste of time.
    I can't believe I'm the first person to have this problem - can anyone help me please?

    You are not the only one, that is for sure!
    The only way (that I'm aware of and is easy to accomplish) to achieve this is the following:
    * Upload your history v1, v2, v3, v4, v5, v6. And then it is really in sync with your current / old version numbers.
    * just upload the new / latest file and check out/check in the file x times so the version number will increase every check in.
    I know that this sounds weird/funny time consuming. Without 3th party tooling I don't see any other solution.
    With 3th party tooling then you can perform those actions (basicaly the same actions) more quick and easy, however you need to get yourself comfortable which such tooling. One of the tools (no I'm not a sales agent or whatsover) that I know can perform metadata
    changes is ShareGate. However in PowerShell you can perform also a lot of magic and without ad doubt there are a lot of migrating tools (AvePoint, Tzunami, etc) that can also "mimick" those manual steps.
    My best suggestion is: 
    * If you need to keep the old versions upload them all one by one (if it is not too time consuming)
    Otherwise
    * create a archive for old versions and start in SharePoint with version 1 which is exactly the same as the latest non-SharePoint version and store that archive in a separate document library/folder/site. (only keep old versions if there is a reall need
    /business case or legal case to do that.)
    Kind regards,
    Michiel hamers
    If you think this answer is good: please choose mark as answer.
    Michiel Hamers www.SharePointman.nl Don't hesitate to contact me for a SharePoint/O365 question.

  • Change default association with DOCUMENT class

    Hi
    Is it possible to change the default association of files in IFS with the DOCUMENT class to a subclass of DOCUMENT?
    I would like to make a subclass of DOCUMENT with additional attributes and, by default, associate ALL uploaded files with that subclass.
    If this is a setting in IFS manager, would someone be able to tell me what to change?
    Any help will be greatly appreciated.
    Thanks very much
    Hugo

    Hi,
    Yes, you have to associate the basic content type with the document library manually. You can refer to the following powershell:
    #Get site object and
    #specify name of the content type to look for in each library
    $site = Get-SPSite http://portal
    $lookForCT = "Sales Document"
    #Walk through each site in the site collection
    $site | Get-SPWeb -Limit all | ForEach-Object {
    write-host "Checking site:"$_.Title
    #Go through each document library in the site
    $_.Lists | where { $_.BaseTemplate -eq "DocumentLibrary" } | ForEach-Object {
    write-host "Checking list:"$_.Title
    $_.ContentTypesEnabled = $true
    #Check to see if the library contains the content type specified
    #at the start of the script
    if (($_.ContentTypes | where { $_.Name -eq $lookForCT }) -eq $null)
    write-host "No content type exists with the name" $lookForCT "on list" $_.Title
    else
    #Add site content types to the list
    $ctToAdd = $site.RootWeb.ContentTypes["HR Document"]
    $ct = $_.ContentTypes.Add($ctToAdd)
    write-host "Content type" $ct.Name "added to list" $_.Title
    $ctToAdd = $site.RootWeb.ContentTypes["IT Document"]
    $ct = $_.ContentTypes.Add($ctToAdd)
    write-host "Content type" $ct.Name "added to list" $_.Title
    $_.Update()
    #Dispose of the site object
    $site.Dispose()
    Reference:
    https://social.technet.microsoft.com/Forums/office/en-US/dc030cb6-5d99-47eb-9620-f3640f6d6b1b/powershell-script-enable-content-types-on-a-list-and-add-content-types?forum=sharepointadminprevious
    http://www.getinthesky.com/2014/11/add-contenttype-documents-sitecollection-using-powershell-sharepoint-2013/
    Best Regards,
    Eric
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Cannot import SWF with document class (AS3)

    When I try to import a SWF-file (published from a FLA-file with a as3 document class) via the mx:SWFLoader into Flash Builder, the imported SWF is not showing up (as3 build a cube from papervision3d). Which way do you have to import such a SWF-file?
    Regards, Sjoerd

    Shitf+Ctrl+Enter:
    Attempting to launch and connect to Player using URL preloader.swf
    [SWF] preloader.swf - 9591 bytes after decompression
    [SWF] big.swf - 1785015 bytes after decompression
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
        at DocumentlClass()
    Cannot display source code at this location.
    My document class (simplyfied):
    package {
        import flash.display.Sprite;
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import fl.transitions.Tween;
        import fl.transitions.TweenEvent;
        import fl.transitions.easing.*;
        import flash.events.ProgressEvent;
        public class CarouselClass extends MovieClip {
            private vars...
            public function CarouselClass() {
                trace("document class triggered");
                    this.addEventListener(Event.ADDED_TO_STAGE,init);
            private function init(evt:Event):void{
                 texts = new Texts();
                carouselSprite = new Sprite();
                addChild(carouselSprite);
                topContainer = new Sprite();
                carouselSprite.addChild(topContainer);
                hitBar = new HitBar();
                hitBar.x = stage.stageWidth / 2 - hitBar.width /2;
                hitBar.y = 245;
                addChild(hitBar);
                downContent = new DownContent();
                addChild(downContent);
                downContent.y = 325;
                downContent.title_txt.text = "Learning Carousel";
                downContent.description_txt.text = "Click on one of images above to view further details";
                createSections();
            } ... (more functions)

  • Document Class vs Timeline code differences...

    I'm trying to hunt down some kind of class conflict I seem to be having when using TweeLite easing and found out the same code that errors in a document class works fine if I place it in the timeline.
    Example - this works in frame one of the timeline:
    import com.greensock.TweenLite;
    import com.greensock.easing.*;
    TweenLite.to(obj, 1, { x:200, ease:Bounce.easeOut } );
    If however I make a very simple document class like so:
    package
          import com.greensock.TweenLite;
          import com.greensock.easing.*;
          import flash.display.MovieClip;
          public class Main extends MovieClip
               public function Main()
                    TweenLite.to(obj, 1, { x:200, ease:Bounce.easeOut } );
    I get an error when compiling:
    1119: Access of possibly undefined property easeOut through a reference with static type Class.
    So what's the differences between using a document class and timeline code?

    Odd... seems to have been a caching issue. I renamed the class, rebooted, and deleted ASO files and now it's working. Funny thing is that I never need to delete ASO files before... any thoughts on why this would stay cached?
    And, after rebooting I can make changes and don't need to delete ASO files either.
    Thanks!

  • Document Class Error

    I am working with Windows Vista Business if that makes a
    difference in this question.
    I am testing a class file for NoScale called NoScale.as
    I have created the class file attached.
    I have saved the class file in the same location as the fla
    file.
    I put in the document.class box: NoScale
    Whenever I publish, I receive the following error:
    5008: The name of definition 'Main' does not reflect the
    location of this file. Please change the definition's name inside
    this file, or rename the file.
    C:\Users\%UserName%\Desktop\Website\Reference Flas\NoScale.as
    (Note: I have replaced my username with %UserName%)
    I have attempted to put
    C:\Users\%UserName%\Desktop\Website\Reference Flas\NoScale.as into
    the document class box and I receive an error telling me that the
    \'s are incorrect and are not allowed.

    I know that the classes are code that is prewritten so you
    can use the functions within.
    The answer to your question is No, I don't know what the
    classes are doing because I am just beginning with AS3 and Flash 9.
    However, my question is Why does my code work with no
    problems without importing any of those classes into the code when
    I don't put anything into the Document class: [ box ].
    As soon as I wanted to give my flash header the ability to
    resize itself, I found out that I had to create a .as or class file
    with the above code in it to give it that capability. Once I did
    that I found out that I had to use the document class box in order
    to link that class file to the SWF. Once I created a proper .as
    file named NoScale and typed NoScale into the document class box,
    all of a sudden a ton of errors happen wanting me to include the
    flash.blah.blah files. If I remove the NoScale from the document
    class box and do nothing else, the project works just fine.
    That is what I don't understand.
    Wayne
    Adding the following did fix the errors. Thanks.
    import flash.display.LoaderInfo;
    import flash.display.InterpolationMethod;

  • How can a textInput variable access a document Class?

    I have a document class which creates a body of text on-the-fly at runtime.  I am trying to figure out (though I haven't taken any steps to do so yet) how to use a textinput field on the stage of a Flash document that calls the Document Class "MyClass" (just for example's sake").  The class file is MyClass.as and is located in the same directory as the FLA and resultant SWF.  I would like that textInput.text value to change the body text of the MyClass text.  The reason I am using MyClass is because I am performing special visualizations with the text that are encapsulated in MyClass.
    Thanks in advance for any feedback.
    -markerline

    I hadn't realized that this import was what was necessary.  Thank you.  However now with the imported property and my EnterFrameEvent, the rendered text is still not updating.
    Here is my complete Document Class:
    package
        import away3d.containers.ObjectContainer3D;
        import away3d.extrusions.TextExtrusion;
        import away3d.primitives.TextField3D;
        import flash.events.Event;
        import flash.display.MovieClip;
        import wumedia.vector.VectorText;
        import flash.text.TextField;
        import flash.text.TextFieldType;
        public dynamic class FontExtrusionDemo extends Away3DTemplate
            [Embed(source="Fonts.swf", mimeType="application/octet-stream")]
            protected var Fonts:Class;
            protected var container:ObjectContainer3D;
            protected var extrusion:TextExtrusion;
            protected var text:TextField3D;
            public var txtFld:TextField;
            public var myString:String;
            public function FontExtrusionDemo()
                super();
            protected override function initEngine():void{
                super.initEngine();
                this.camera.z=0;
                VectorText.extractFont(new Fonts());
            public function setString():void{
                this.myString=myString;
                txtFld= new TextField();
                txtFld.x=txtFld.y=20;
                txtFld.width =100;
                txtFld.height=20;
                txtFld.border=txtFld.background=true;
                txtFld.type=TextFieldType.INPUT;
                addChild(txtFld);
                stage.focus=txtFld;
            protected override function initScene():void{
                super.initScene();
                myString="1";
                setString();
                text = new TextField3D("Vera Sans",{
                    text:myString,
                    align: VectorText.CENTER}
                extrusion = new TextExtrusion(text, {
                    depth: 10,
                    bothsides:true}
                container = new ObjectContainer3D(text, extrusion, { z:300 });
                scene.addChild(container);
            protected override function onEnterFrameEvent(event:Event):void{
                super.onEnterFrameEvent(event);
                text = new TextField3D("Vera Sans",{
                    text:String(txtFld.text),
                    align: VectorText.CENTER}
                extrusion = new TextExtrusion(text, {
                    depth: 10,
                    bothsides:true}
                //container = new ObjectContainer3D(text, extrusion, { z:300 });
                //scene.addChild(container);  // IF I UNCOMMENT THIS THEN A NEW CHILD WILL BE ADDED AT EVERY FRAME, which is not desired.
                container.rotationY=(container.rotationY+1)%360;
                if (container.rotationY>90&&container.rotationY<270){
                    text.screenZOffset=10;
                } else {
                    text.screenZOffset=-10;

  • NEED TO KNOW HOW CONVERT GIF FILE TO SYMBOL FROM DOCUMENT CLASS

                                                ROBERT LEAHONG
                                      COMPUTER PROGRAMMER / ASP Web Devloper
    Hello,
            I need to convert a GIF file (PICTURE) to a symbol (Button) From within The Document Class using ActionScript 3.0 .
    Thanks in advance for your help.

    So you imported a .gif into the library and need to get to it from the document class? If that's the case you need to  right-click the image in the library, select properties, select the ActionScript tab and then set it to export for ActionScript. Give it a class name - I'll use myGif for example. You'll see it will have a base class of BitmapData...
    Then in your document class you can just instantiate it like:
    var myImageData:BitmapData = new myGif();
    You can turn it into a useable image that you can place on stage by putting it into a Bitmap object:
    var myImage:Bitmap = new Bitmap(myImageData);
    If you want to make a button out of it, ie make it clickable - stick it into a Sprite:
    var mySprite:Sprite = new Sprite():
    mySprite.addChild(myImage);
    addChild(mySprite);
    mySprite.addEventListener(MouseEvent.CLICK, clicked);
    function clicked(e:MouseEvent):void
         trace("clicked");
    HTH

  • Document Classes and other Questions

    Basically, i am working on an application that will eventually be deployed to the desktop as an AIR application.
    I am wanting to create an Analogue clock and Digital clock with a button that toggles the display between either one when pressed. As well as this, i will be wanting to display the Date below, i am having a number of issues however.
    I have the code sorted for three of the four components, i have not attempted to figure out the button thus far as i would be more than happy to have the digital clock, analogue clock and date all being displayed on a drag and drop desktop application first. When i say i have it sorted, i have a fully working analogue clock which i have managed to display on the desktop through air on its lonesome, however, i did not include the drag and drop function. For the digital clock and date components i am not sure how to configure them into document classes. The main issue i am having is i do not know if you can reference a dynamic text box within a movie clip to a document class.
    This is the code to show the date
    [code]{
    var currentTime:Date = new Date();
    var month:Array = new Array("January","February","March","April","May","June","July","August","September","Octo ber","November","December");
    var dayOfWeek:Array = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
    date_text.text = dayOfWeek[currentTime.getDay()] + " " + currentTime.getDate() + " " + month[currentTime.getMonth()] + " " + currentTime.getFullYear();
    [/code]
    I have put the actionscript frame inside the movie clip file, and i have given both the movie clip, and the dynamic text box within the movie clip the instance name "date_text".
    Basically, i am just struggling in how to put this code into a working document class, since the digital clock and date functions are both, some what similar, i feel the solution to one will more than likely lead to me discovering the solution for the other.
    The other problem i am having, i do not know how i will display all of the components on one air application. I am assuming, that you create one other document class file which links the other four together? i have tried to do this by just linking a new FLA file with the analogue clock, but it does not work. The code for that is below.
    [code]package
              import flash.events.Event;
              import flash.display.MovieClip;
              public class time1 extends MovieClip
                        public var now:Date;
                        public function time1()
                                  // Update screen every frame
                                  addEventListener(Event.ENTER_FRAME,enterFrameHandler);
                        // Event Handling:
                        function enterFrameHandler(event:Event):void
                                  now = new Date();
                                  // Rotate clock hands
                                  hourHand_mc.rotation = now.getHours()*30+(now.getMinutes()/2);
                                  minuteHand_mc.rotation = now.getMinutes()*6+(now.getSeconds()/10);
                                  secondHand_mc.rotation = now.getSeconds()*6;
    [/code]
    That is the original clock document class (3 Movie clips for the moving hands, and the clock face is a graphic, which i may have to reference somehow below)?
    [code]package
              import flash.display.MovieClip;
              public class main extends MovieClip
                        public var hourHand_mc:time1;
                        public var minuteHand_mc:time1;
                        public var secondHand_mc:time1;
                        public function main()
                                  hourHand_mc = new SecondHand();
                                  addChild(mySecondHand);
                                  hourHand_mc.x = 75;
                                  hourHand_mc.y = 75;
                                  minuteHand_mc = new SecondHand();
                                  addChild(mySecondHand);
                                  minuteHand_mc.x = 75;
                                  minuteHand_mc.y = 75;
                                  secondHand_mc = new SecondHand();
                                  addChild(mySecondHand);
                                  secondHand.x = 75;
                                  secondHand.y = 75;
    }[/code]
    This is my attempt at creating the main document class in a seperate FLA file to attempt to load the analogue clock, and later on the Digital Clock, Date Function and Toggle Display button in the same AIR application.
    Any help on this is much appreciated, i have been reading up a lot on it through tutorials and the like, but i can't seem to fully grasp it.

    why do you have code in a movieclip?
    if you want to follow best practice and use a document class you should remove almost all code from timelines.  the only timeline code that might be reasonably used would be a stop() on the first frame of multiframe movieclips.
    so, you should have a document class.  that could contain all your code but it would be better to just have your document class create your 2 clocks and date objects and possibly manage toggling between the two clocks.  you could have a separate class the tracks the time and date and that class is used by your two clock classes and your date class.

  • Document Class not work when I shift my MovieClip to 2nd Frame.

    Hello,
    All my content is at 1st frame of my FLA file...and I'm using Document Class... When I try to shift my content to 2nd frame, so I can use 1st frame for preloader.. but its not working...
    This is my document class... Basically at 1st frame I'm loading external jpg image to a MovieClip..
    Is it possible, I can **** my MovieClip and other content to 2nd frame of the timeline... ??? and Document Class work???
    Thanks...
    package com.ahmad.bg
         //import all classes
         import caurina.transitions.Tweener;
         import flash.display.Loader;
         import flash.display.MovieClip;
         import flash.display.Sprite;
         import flash.display.StageAlign;
         import flash.display.StageDisplayState;
         import flash.display.StageScaleMode;
         import flash.events.Event;
         import flash.events.MouseEvent;
         import flash.net.URLRequest;
         public class MainClass extends MovieClip
              //create variables
              private var loader:Loader;
              private static const IMAGE_PATH:String = "bgs/bg.jpg";         
              public function MainClass() {
                   stage.align = StageAlign.TOP_LEFT;
                   stage.scaleMode = StageScaleMode.NO_SCALE;              
                   stage.addEventListener(Event.RESIZE, stageResize);         
                   //load external image
                   loader = new Loader();
                   loader.load(new URLRequest(IMAGE_PATH));
                   loader.contentLoaderInfo.addEventListener(Event.COMPLETE, showImage);
                   pic.addChild(loader);    
              private function showImage(e:Event):void
                   try {                             
                        e.target.content.alpha = 1;
                        Tweener.addTween(e.target.content, { alpha:1, time:1, transition:"easeOutSine" } );                   
                        e.target.content.smoothing = true;                             
                   } catch (e:Error) { };
                   stageResize();
              private function stageResize(e:Event=null):void
                   pic.x = 0;
                   pic.y = 0;
                   pic.scaleX = pic.scaleY = 1;              
                   if ((stage.stageHeight / stage.stageWidth) < pic.height / pic.width) {
                        pic.width = stage.stageWidth;
                        pic.scaleY = pic.scaleX;
                   } else {
                        pic.height = stage.stageHeight;                   
                        pic.scaleX = pic.scaleY;
                   pic.x = stage.stageWidth / 2 - pic.width / 2;
                   pic.y = stage.stageHeight / 2 - pic.height / 2;         
                   bottomNav.x = Math.floor(stage.stageWidth / 2 - bottomNav.width / 2);
                   bottomNav.y = Math.floor(stage.stageHeight - bottomNav.height - 0);

    If you have code in your main class that references specific movieclips on the stage, they have to be on every frame you plan on using.
    If you have a movieclip named "pic" on frame 2, but you are referencing it right away in the main class, which starts on frame 1, then it is looking for a movieclip that does not exist until you move it to frame 2

  • Preloader in Document Class Help.

    Hello,
    I want to know that how can I add a Preloader to my existing document class. In my FLA all content is on 1st Frame. I'm loading an external image to a MovieClip which is on 1st frame and on stage. My document class is working fine but when i try to add any preloading script, its not working...
    Can any one please help me in this regard..
    A Garden of Thanks.
    My Document Class is here...  (This was also a tutorial which I'm using..)
    package com.ahmad.bg
         //import all classes
         import caurina.transitions.Tweener;
         import flash.display.Loader;
         import flash.display.MovieClip;
         import flash.display.Sprite;
         import flash.display.StageAlign;
         import flash.display.StageDisplayState;
         import flash.display.StageScaleMode;
         import flash.events.Event;
         import flash.events.MouseEvent;
         import flash.net.URLRequest;
         public class MainClass extends MovieClip
              //create variables
              private var loader:Loader;
              private static const IMAGE_PATH:String = "bgs/bg.jpg";          
              public function MainClass() {
                   stage.align = StageAlign.TOP_LEFT;
                   stage.scaleMode = StageScaleMode.NO_SCALE;               
                   stage.addEventListener(Event.RESIZE, stageResize);          
                   //load external image
                   loader = new Loader();
                   loader.load(new URLRequest(IMAGE_PATH));
                   loader.contentLoaderInfo.addEventListener(Event.COMPLETE, showImage);
                   pic.addChild(loader);     
              private function showImage(e:Event):void
                   try {                              
                        e.target.content.alpha = 0;
                        Tweener.addTween(e.target.content, { alpha:1, time:1, transition:"easeOutSine" } );                    
                        e.target.content.smoothing = true;                              
                   } catch (e:Error) { };
                   stageResize();
              private function stageResize(e:Event=null):void
                   pic.x = 0;
                   pic.y = 0;
                   pic.scaleX = pic.scaleY = 1;               
                   if ((stage.stageHeight / stage.stageWidth) < pic.height / pic.width) {
                        pic.width = stage.stageWidth;
                        pic.scaleY = pic.scaleX;
                   } else {
                        pic.height = stage.stageHeight;                    
                        pic.scaleX = pic.scaleY;
                   pic.x = stage.stageWidth / 2 - pic.width / 2;
                   pic.y = stage.stageHeight / 2 - pic.height / 2;          
                   //my bottom navigation
                            bottomNav.x = Math.floor(stage.stageWidth / 2 - bottomNav.width / 2);
                   bottomNav.y = Math.floor(stage.stageHeight - bottomNav.height - 0);

    package com.ahmad.bg
         //import all classes
         import caurina.transitions.Tweener;
         import flash.display.Loader;
         import flash.display.MovieClip;
         import flash.display.Sprite;
         import flash.display.StageAlign;
         import flash.display.StageDisplayState;
         import flash.display.StageScaleMode;
         import flash.events.Event;
         import flash.events.MouseEvent;
         import flash.net.URLRequest;
         import flash.events.ProgressEvent;
         public class MainClass extends MovieClip
              //create variables
              private var loader:Loader;
              private static const IMAGE_PATH:String = "bgs/bg.jpg";          
              public function MainClass() {
                   stage.align = StageAlign.TOP_LEFT;
                   stage.scaleMode = StageScaleMode.NO_SCALE;               
                   stage.addEventListener(Event.RESIZE, stageResize);          
                   //load external image
                   loader = new Loader();
                   loader.load(new URLRequest(IMAGE_PATH));
                   loader.contentLoaderInfo.addEventListener(Event.COMPLETE, showImage);
                   loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preload_image, false, 0, true);
                   private function preload_image(event:ProgressEvent):void
                          var per = int((event.bytesLoaded / event.bytesTotal) * 100);
                          pic.addChild(loader);
                          //make a textfield or preloader animation and assign this per to it.
              private function showImage(e:Event):void
                   try {                              
                        e.target.content.alpha = 0;
                        Tweener.addTween(e.target.content, { alpha:1, time:1, transition:"easeOutSine" } );                    
                        e.target.content.smoothing = true;                              
                   } catch (e:Error) { };
                   stageResize();
              private function stageResize(e:Event=null):void
                   pic.x = 0;
                   pic.y = 0;
                   pic.scaleX = pic.scaleY = 1;               
                   if ((stage.stageHeight / stage.stageWidth) < pic.height / pic.width) {
                        pic.width = stage.stageWidth;
                        pic.scaleY = pic.scaleX;
                   } else {
                        pic.height = stage.stageHeight;                    
                        pic.scaleX = pic.scaleY;
                   pic.x = stage.stageWidth / 2 - pic.width / 2;
                   pic.y = stage.stageHeight / 2 - pic.height / 2;          
                   //my bottom navigation
                   bottomNav.x = Math.floor(stage.stageWidth / 2 - bottomNav.width / 2);
                   bottomNav.y = Math.floor(stage.stageHeight - bottomNav.height - 0);
    Oh.. Thanks.. its working now... Thanks aloooooooooooooot.....
    Any other tip if you have a time to give me will be a greatful to you...
    Thanks again for your precious time.. I've seen your Awesome Portfolio at your website....

  • Accessing value in document class

    hello i am trying to acces a value in the document class. but i can't get it to work.
    what i have is:
    can someone tell me how i should access the myArray value?
    bomberman.as:
    package  {
              import flash.display.MovieClip;
              public class bomberman extends MovieClip {
            public var myArray:Array=[]; //trying to access this value
                        public function bomberman() {
                                  init();
                                  //trace(document.docClass);
                        private function init() {
                        var square:Array=[];
                                  for (var i:Number=0;i<11;i++) {
                                            for (var j:Number=0;j<11;j++) {
                                                      var temp:grassSquare;
                                                      if (i==0||i==10) {
                                                                temp=new grassSquare(i*50,j*40);
                                                                addChild(temp);
                                                                square.push(temp);
                                                      } else if (i%2!=0) {
                                                                if (j==0||j==10) {
                                                                          temp=new grassSquare(i*50,j*40);
                                                                          addChild(temp);
                                                                          square.push(temp);
                                                                          myArray.push(false);
                                                                } else {
                                                                          myArray.push(true);
                                                      } else {
                                                                if (j%2==0) {
                                                                          temp=new grassSquare(i*50,j*40);
                                                                          addChild(temp);
                                                                          square.push(temp);
                                                                          myArray.push(false);
                                                                } else {
                                                                          myArray.push(true);
    bomberman.fla:
    import flash.events.KeyboardEvent
              var User1:Player1=new Player1;
              stage.addEventListener(KeyboardEvent.KEY_DOWN, User1.fl_SetKeyPressed);
              User1.x=75;
              User1.y=60;
              addChild(User1);
    Player1.as:
    package  {
              import flash.display.MovieClip;
              import flash.events.Event;
              import flash.events.KeyboardEvent
              import flash.ui.Keyboard
              public class Player1 extends MovieClip {
              private var upPressed:Boolean = false;
              private var downPressed:Boolean = false;
              private var leftPressed:Boolean = false;
              private var rightPressed:Boolean = false;
              private var currentSquare:uint=12;
                        public function Player1() {
                                  this.addEventListener(Event.ENTER_FRAME, fl_MoveInDirectionOfKey);
                                  //stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed);
                        public function fl_MoveInDirectionOfKey(event:Event)
                                            if (upPressed && this.y>=100 /*&&document.myArray[currentSquare-1]*/)
                                                      this.y -= 40;
                                                      upPressed = false;
                                                      currentSquare-=1;
                                            if (downPressed && this.y<=340 /*&& this.myArray[currentSquare+1]*/)
                                                      this.y += 40;
                                                      downPressed = false;
                                                      currentSquare+=1;
                                            if (leftPressed && this.x>=125 /*&& /*this.myArray[currentSquare-11]*/)
                                                      this.x -= 50;
                                                      leftPressed = false;
                                                      currentSquare-=11;
                                            if (rightPressed && this.x<=425 /* && /*this.myArray[currentSquare+11]*/)
                                                      this.x += 50;
                                                      rightPressed = false;
                                                      currentSquare+=11;
                                            trace(currentSquare);
                                  public function fl_SetKeyPressed(event:KeyboardEvent):void
                                            switch (event.keyCode)
                                                      case Keyboard.UP:
                                                                upPressed = true;
                                                                break;
                                                      case Keyboard.DOWN:
                                                                downPressed = true;
                                                                break;
                                                      case Keyboard.LEFT:
                                                                leftPressed = true;
                                                                break;
                                                      case Keyboard.RIGHT:
                                                                rightPressed = true;
                                                                break;

    i have this code now and it gives me a bunch of errors. could someone tell me what's going wrong ?
    errors are in the red code.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 25
    1093: Syntax error.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 27
    1084: Syntax error: expecting identifier before this.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 27
    1084: Syntax error: expecting colon before minusassign.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 28
    1084: Syntax error: expecting rightbrace before semicolon.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 31
    1084: Syntax error: expecting rightparen before if.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 31
    1084: Syntax error: expecting identifier before dot.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 31
    1093: Syntax error.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 33
    1084: Syntax error: expecting identifier before this.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 33
    1084: Syntax error: expecting colon before plusassign.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 34
    1084: Syntax error: expecting rightbrace before semicolon.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 37
    1093: Syntax error.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 39
    1084: Syntax error: expecting identifier before this.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 39
    1084: Syntax error: expecting colon before minusassign.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 40
    1084: Syntax error: expecting rightbrace before semicolon.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 43
    1084: Syntax error: expecting rightparen before if.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 43
    1084: Syntax error: expecting identifier before dot.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 43
    1093: Syntax error.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 45
    1084: Syntax error: expecting identifier before this.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 45
    1084: Syntax error: expecting colon before plusassign.
    C:\Users\Jannes\Desktop\dev\Player1.as, Line 46
    1084: Syntax error: expecting rightbrace before semicolon.
    package  {
              import flash.display.MovieClip;
              import flash.events.Event;
              import flash.events.KeyboardEvent
              import flash.ui.Keyboard
              public class Player1 extends MovieClip {
              private var upPressed:Boolean = false;
              private var downPressed:Boolean = false;
              private var leftPressed:Boolean = false;
              private var rightPressed:Boolean = false;
              private var currentSquare:uint=12;
                        public function Player1() {
                                  this.addEventListener(Event.ENTER_FRAME, fl_MoveInDirectionOfKey);
                                  //stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed);
                        public function fl_MoveInDirectionOfKey(event:Event)
                                            if (upPressed && this.y>=100 && MovieClip(root).myArray[currentSquare-1]*/)
                                                      this.y -= 40;
                                                      upPressed = false;
                                                      currentSquare-=1;
                                            if (downPressed && this.y<=340 && MovieClip(root).myArray[currentSquare+1]*/)
                                                      this.y += 40;
                                                      downPressed = false;
                                                      currentSquare+=1;
                                            if (leftPressed && this.x>=125 && MovieClip(root).myArray[currentSquare-11]*/)
                                                      this.x -= 50;
                                                      leftPressed = false;
                                                      currentSquare-=11;
                                            if (rightPressed && this.x<=425 && MovieClip(root).myArray[currentSquare+11]*/)
                                                      this.x += 50;
                                                      rightPressed = false;
                                                      currentSquare+=11;
                                            trace(currentSquare);
                                  public function fl_SetKeyPressed(event:KeyboardEvent):void
                                            switch (event.keyCode)
                                                      case Keyboard.UP:
                                                                upPressed = true;
                                                                break;
                                                      case Keyboard.DOWN:
                                                                downPressed = true;
                                                                break;
                                                      case Keyboard.LEFT:
                                                                leftPressed = true;
                                                                break;
                                                      case Keyboard.RIGHT:
                                                                rightPressed = true;
                                                                break;

  • ADDED event in document class after removed from Stage

    Hi All,
    I am currently play with the document class (the class acts as main) constructor for a SWF file.
    package {
      import flash.display.*;
      import flash.events.*;
      public class TestSymbol extends MovieClip
        public function TestSymbol()
          this.addEventListener(Event.ADDED, function(event:Event) { trace(event.eventPhase, event.target, event.currentTarget, "added triggered"); });
          trace("parent", this.parent);
          this.stage.removeChild(this);
          trace("stage", this.stage);
    In frame script 1, i put
    trace("1");
    trace("parent", this.parent);
    After i run TestSymbol.swf and  i got
    parent [object Stage]
    stage null
    2 [object TestSymbol] [object TestSymbol] added triggered
    1
    parent null
    I wonder where is this ADDED event coming from? If the document class is added to some other objects, why its parent is null after the event?
    Thanks in advance
    Sam

    By wrapper do you mean they are the same object or the MainTimeLine is a separate object being added to DocumentClass, as it triggers the ADDED event? I know that framescript can be accessed as documentClass functions, so I thought they are the same object, maybe i was wrong.
    I did a new test within some more listeners
    package {
      import flash.display.*;
      import flash.events.*;
      public class TestSymbol extends MovieClip
        public function TestSymbol()
          this.addEventListener(Event.ADDED_TO_STAGE, addedToStageListener);
          this.addEventListener(Event.ADDED, addedListener)
          this.addEventListener(Event.REMOVED_FROM_STAGE, removedFromStageListener);
          this.addEventListener(Event.REMOVED, removedListener);
          trace("parent", this.parent);
          this.stage.removeChild(this);
          trace("stage", this.stage);
         private function addedListener(event:Event):void {
           trace(event.eventPhase, event.target, event.currentTarget, "added triggered");
         private function addedToStageListener(event:Event):void {
           trace(event.eventPhase, event.target, event.currentTarget, "addedToStage triggered");
         private function removedListener(event:Event):void {
           trace(event.eventPhase, event.target, event.currentTarget, "removed triggered");
         private function removedFromStageListener(event:Event):void {
           trace(event.eventPhase, event.target, event.currentTarget, "removedFromStage triggered");
    and this is the output
    parent [object Stage]
    2 [object TestSymbol] [object TestSymbol] removed triggered
    2 [object TestSymbol] [object TestSymbol] removedFromStage triggered
    stage null
    2 [object TestSymbol] [object TestSymbol] added triggered
    As the remove listeners are fired immediately, i don't think the queue is waiting until the end of the constructor.

  • Access a mc or textfeild from a non document class.

    Hey all.
    This use to be simple in as2, but seems to allude me from as3.  It used to be simple to access an object you put on the stage like a mc or dynamic text field by simply using _root.instanceName ect.  Now I see references to making references to the Stage and such like:
    private var stage:Stage;
    stage = stageRef;
    and I am still confused.
    What I have going on is, I have placed a movieclip on the stage in Flash and gave it an instance name of Cell_mc.
    I have a cusom class that extends MovieClip with the following imports
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.events.MouseEvent;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
    This Class is tied to a set of MovieClips in my Library.
    I have a listener: this.addEventListener(MouseEvent.MOUSE_DOWN,pickUp);
    And a function:
    private function pickUp(event:MouseEvent):void
                      this.startDrag();
                      _interval = new Timer(100);
                      _interval.addEventListener(TimerEvent.TIMER,onInterval);
                      _interval.start();
    And
    private function onInterval(event:TimerEvent):void
                      //Set up hit test
                      this.hitArea(Cell_mc)
                            trace("hit");
    I get the following error whenever I try to access an object I placed on the stage from anywhere other than the document class:
    1120: Access of undefined property Cell_mc.
    How do I access the cell_mc that is already on the stage from this non-document class?
    Thanks guys.

    try:
    private var stage:Stage;
    stage = stageRef;
    and I am still confused.
    What I have going on is, I have placed a movieclip on the stage in Flash and gave it an instance name of Cell_mc.
    I have a cusom class that extends MovieClip with the following imports
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.events.MouseEvent;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
    This Class is tied to a set of MovieClips in my Library.
    I have a listener: this.addEventListener(MouseEvent.MOUSE_DOWN,pickUp);
    And a function:
    private function pickUp(event:MouseEvent):void
                      this.startDrag();
                      _interval = new Timer(100);
                      _interval.addEventListener(TimerEvent.TIMER,onInterval);
                      _interval.start();
    And
    private function onInterval(event:TimerEvent):void
                      //Set up hit test
                      this.hitArea(MovieClip(root).Cell_mc)
                            trace("hit");
    I get the following error whenever I try to access an object I placed on the stage from anywhere other than the document class:
    1120: Access of undefined property Cell_mc.
    How do I access the cell_mc that is already on the stage from this non-document class?
    Thanks guys.

  • Preloader and Document Class BIG question (yeap please help)

    Hy,
    I know that this its a question posted many, many times, but
    after searching the net, reading a lot of books and searching this
    forum too, I cant get out with a solution. If I'd say for sure
    there is no possibility to create something like this, I just go
    back to old methods but is not the scope of Adobe with AS3 to
    encourage the use of OOP principle or not?
    The problem:
    I have a single fla file (AS3) with a single frame on
    timeline, frame that its there when you will create the file with
    flash. In the library I have different symbols, that for simplicity
    are only jpg image, (BitmapData) checked for export for
    ActionScript and exported on frame one. An external .as file called
    DocumentClass its off course my Document Class
    This its all that I want to do with the fla, the goal its to
    create, animate etc. only with AS3 in external classes, no timeline
    script. I don't want to load external files, XML, or else in this
    movie. I just want a single swf after compilation, no additional
    files.
    Ok, how do I create a preloader that will take care of
    starting the logic after the whole swf its loaded and in the same
    time shows the user a percentage or a load bar or something that
    its not the blank screen when the swf its downloading. I want to do
    this without another swf that load this swf, or timeline scripts,
    or place all the content on second frame and then gotoAndStop to
    the third frame. All this are not solution but cheap tricks, that
    are against all this OOP principle that I just continue to read in
    books and here from guru programmers.
    The big question is:
    It is possible to create a preloader, when use a document
    class with your fla? And if yes, how?
    I know that the Document Class its not instantiated if its
    not fully loaded, if that's true when the document class will be
    fully loaded? maybe after the whole movie its loaded? And, if its
    true, it will never show a percentage bar "while" the movie its
    loaded. And if that's true WHY use a document class anyway?
    Thank you for reading this and I really wait to get some
    answer.

    I am pretty sure you cannot do self preloader with one frame
    and all the objects in the library. I guess the key here is
    one-frame design. Screen refreshes (renders) only when all the
    scripts in the frame are executed - this is a very important thing
    to understand about how Flash works. Yes, you can force screen
    refresh with updateAfterEvent() method but it is attached to a
    handful of events only (MouseEvent and TimerEvent) but, again, all
    this functionality is available only after first frame scripts are
    executed. Thus, it seems like the only way to create preloader from
    within SWF is to use multiple frames and set library objects to
    load in later (not first) frame.
    quote:
    And if that's true WHY use a document class anyway?
    Well, preloader is the last thing that would be on my mind in
    terms of using AS3 ability to link DocumentClass to the top movie.
    This feature allows for very sophisticated architectural
    approaches. It has no connection to preloader as to any other
    features developer wants to implement. Neither it depends on or
    negates timeline. As a matter of fact, although I love one-frame
    applications, I find on numerous occasions that my application
    would be more efficient if I used several (at least two) frames.
    gotoAndStop is not deprecated. It is a valid MovieClip class'
    method. After all, having only one frame doesn't mean not having
    frames at all - there is one already. Frames are fundament of
    Flash. AS3 did introduce frameless entities like Sprite, etc. but
    it doesn't mean that frames are going anywhere.
    I would agree that timeline code is inferior to
    classed/packaged (read: better organized) code but, still, how is
    it not OOP? Frame is an Object, right? Why using timeline is cheap
    and not a solution?
    On a side note, I see too many times how some authors (and
    managers) are pushing their agenda (or close mindedness) onto their
    audience with no real substantiation. Claiming that timeline in
    Flash is not valid architectural decision from OOP standpoint is
    totally wrong. As wrong as strict adherence to design patterns. I
    don't think there is sharply defined "right" or "wrong" in
    programming. One finds the best optimal solution. The goal is to
    create something that works fine. Unless, of course, the process is
    the goal - but very few of us can afford focusing on the process.

Maybe you are looking for

  • How to  limit the access of a transaction

    please provide hw to create an authorization object... like hw to limit the access of a particular userdefined trasaction to a particular user

  • Hyperlink appearance in a pdf?

    I've just found out about how to put hyperlinks into a pdf exported from InDesign using the InDesign help. But it looks like the only way they can be styled is either with or without a rectangle around them, which is quite an unconventional way to di

  • Nokia Lumia 1520 suppports only 3G?

    I have a Nokia Lumia 1520 purchased in India but to my surprise I find only 2G and 3G as the options under Settings--> Mobile Network --> Highest Connection Speed. I have a 4G SIM inserted and my service provider supports 4G.

  • How to create personnel number as FI Customer in system?

    Dear Community,    I am new in HR, and have requirements to create from HR personnel an FI customers fro internal billing. Can you guide me how to do it in HR? Best regards, Artem

  • Why can't i tap the wifi button on my ipod touch 4g?

    When i go to "Settings" the wifi button is greyed out and i can't tap it. Help me please!!