Вопрос знающим

Обсуждение и помощь по вопросам взаимодействия с ВКонтакте API в Flash-приложениях (ActionScript)
Ответить
moto
Сообщения: 122
Зарегистрирован: 05 апр 2010, 23:08

Вопрос знающим

Сообщение moto »

вот есть у меня fla - файл,
к нему присоединен as файл со следующим кодом:

Код: Выделить всё

package {  import flash.display.Sprite;  import flash.display.Stage;  import flash.events.Event;  import flash.events.MouseEvent;  import flash.system.Security;  import flash.text.TextField;  import vk.*;     import flash.net.URLLoader;    import flash.net.URLRequest;    import flash.display.*;    import flash.events.*;    import flash.text.*;   public class rico extends Sprite   {    private var wrapper:* = null;    private var menu_item1:* = null;    private var menu_item2:* = null;    private var menu_item3:* = null;    private var menu_item4:* = null;    private var menu_item5:* = null;    private var menu_item6:* = null;        private var last_y_1:uint = 290;    private var last_y_2:uint = 330;    private var last_y_4:uint = 300;    private var last_y_5:uint = 330;    private var box1:* = null;    private var box2:* = null;            private var api_id:Number=743131; // id вашего приложения        private var api_secret:String="sE4VLBDdSQ"; // секретный ключ        private var externalXML:XML;        private var loader:URLLoader = new URLLoader();        private var photoLoader:Loader = new Loader();        private var viewer_id:Number;        private var sig:String;        private var uid:String;        private var bdate_txt:TextField = new TextField();        private var name_txt:TextField = new TextField();        private var univer_txt:TextField = new TextField();              public function rico():void     {      if (stage) init();      else addEventListener(Event.ADDED_TO_STAGE, init);//======================            var params:Object=LoaderInfo(root.loaderInfo).parameters;            viewer_id = (params['viewer_id']) ? parseInt(params['viewer_id']) : 1;            getProfile(viewer_id);    }        private function getProfile(uid):void {            sig=MD5.encrypt(viewer_id+'api_id='+api_id+'fields=bdate,photo_bigmethod=getProfilesuids='+uid+'v=2.0'+api_secret);            var request:URLRequest=new URLRequest("http://api.vkontakte.ru/api.php?api_id="+api_id+"&method=getProfiles&uids="+uid+"&fields=bdate,photo_big&v=2.0&sig="+sig);            loader.load(request);            loader.addEventListener(Event.COMPLETE, onComplete);        }private function onComplete(event:Event):void {            bdate_txt.text='';            if (loader!=null) {                externalXML=new XML(loader.data);                var bdate = externalXML..bdate;                bdate_txt.text=bdate;                bdate_txt.x=430;                bdate_txt.y=10;                //addChild(bdate_txt);                                var uname = externalXML..first_name + ' ' + externalXML..last_name;                name_txt.text=uname;                name_txt.x=300;                name_txt.y=10;                //addChild(name_txt);                                var univerx = externalXML..university_name;                univer_txt.text=univerx;                univer_txt.x=430;                univer_txt.y=210;                                var photo = externalXML..photo_big;                var request2:URLRequest=new URLRequest(photo);                photoLoader.load(request2);                photoLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);             } else {                trace("Error!");            }        }         private function onLoaded(e:Event):void {            photoLoader.x = 10;            photoLoader.y = 10;            //addChild(photoLoader);        }        private function init(e:Event = null):void     {      removeEventListener(Event.ADDED_TO_STAGE, init);       Security.allowDomain( "*" );      VK.init( this, "http://api.vkontakte.ru/swf/vk_gui-0.5.swf" );      //VK.init( this, "../../../bin/vk_gui-0.5.swf" );    }         public function onVKLoaded():void    {      var i:uint;            wrapper = Object(parent.parent);      if ( wrapper.external == null )        wrapper = stage; // Local                  // A background for entire application   //   var bg:Sprite = new Sprite();   //   VK.Utils.fillRect( bg, 0, 132, 627, 4050, VK.Utils.BK_COL );   //   addChild( bg );            // Main menu with three items (and three associated pages)      // Associated pages are accessible as:  main_menu.page( idx )      var main_menu:* = VK.createMainMenu( wrapper );      menu_item1 = main_menu.addItem( "вкладка номер один", "loc1" );      menu_item2 = main_menu.addItem( "вкладка номер два", "loc2" );      menu_item3 = main_menu.addItem( "вкладка номер три", "loc3" );      menu_item4 = main_menu.addItem( "вкладка номер четыре", "loc4" );      menu_item5 = main_menu.addItem( "вкладка номер пять", "loc5" );      menu_item6 = main_menu.addItem( "вкладка номер шесть", "loc6" );      main_menu.y +=70;      addChild( main_menu );         //   main_menu.addEventListener( Event.CHANGE, onMenuNavigate );      //----------------------выбор активной вкладки-------------      main_menu.selectedItem = menu_item1;      //menu_item2.label = "новое имя вкладки";                  // -----------------------------------------------------------------------------------      // --- Первая вкладочка ---  menu_item1.panel.addChild( bdate_txt);      menu_item1.panel.addChild( name_txt);  menu_item1.panel.addChild( photoLoader);  menu_item1.panel.addChild( univer_txt);                      }       }  }
в папке с файлом есть папка vk в которой VK.as со следующим содержимым:

Код: Выделить всё

package vk{  import flash.display.Loader;  import flash.net.URLRequest;  import flash.events.Event;  import flash.events.IOErrorEvent;  import flash.system.LoaderContext;  import flash.system.ApplicationDomain;     public class VK  {    public static var MainMenu:Class = null;    public static var RoundButton:* = null;    public static var SquareButton:* = null;    public static var LinkButton:* = null;    public static var LightButton:* = null;    public static var ComboBox:* = null;    public static var ListBox:* = null;    public static var Box:* = null;    public static var CheckBox:* = null;    public static var RadioButtonsGroup:* = null;    public static var Pagination:* = null;    public static var InputField:* = null;    public static var ScrollBar:* = null;    public static var Utils:* = null;     public static const LINK_BUTTON:uint = 0;    public static const BLUE_BUTTON:uint = 1;    public static const GRAY_BUTTON:uint = 2;     // ------------------------------------------------------------------------------ Call this before use of VK library.    public static function init( obj:*, url:String ):void    {      var loader:Loader = new Loader();      loader.contentLoaderInfo.addEventListener( Event.COMPLETE, function(e:Event):void      {        Utils        = loader.contentLoaderInfo.applicationDomain.getDefinition( "vk.gui.Utils" ) as Class;        RoundButton  = loader.contentLoaderInfo.applicationDomain.getDefinition( "vk.gui.RoundButton" ) as Class;        SquareButton = loader.contentLoaderInfo.applicationDomain.getDefinition( "vk.gui.SquareButton" ) as Class;        LinkButton   = loader.contentLoaderInfo.applicationDomain.getDefinition( "vk.gui.LinkButton" ) as Class;        LightButton  = loader.contentLoaderInfo.applicationDomain.getDefinition( "vk.gui.LightButton" ) as Class;        ComboBox     = loader.contentLoaderInfo.applicationDomain.getDefinition( "vk.gui.ComboBox" ) as Class;        ListBox      = loader.contentLoaderInfo.applicationDomain.getDefinition( "vk.gui.ListBox" ) as Class;        Box          = loader.contentLoaderInfo.applicationDomain.getDefinition( "vk.gui.Box" ) as Class;        CheckBox     = loader.contentLoaderInfo.applicationDomain.getDefinition( "vk.gui.CheckBox" ) as Class;        RadioButtonsGroup = loader.contentLoaderInfo.applicationDomain.getDefinition( "vk.gui.RadioButtonsGroup" ) as Class;        MainMenu     = loader.contentLoaderInfo.applicationDomain.getDefinition( "vk.gui.MainMenu" ) as Class;        Pagination   = loader.contentLoaderInfo.applicationDomain.getDefinition( "vk.gui.Pagination" ) as Class;        InputField   = loader.contentLoaderInfo.applicationDomain.getDefinition( "vk.gui.InputField" ) as Class;        ScrollBar    = loader.contentLoaderInfo.applicationDomain.getDefinition( "vk.gui.ScrollBar" ) as Class;                obj.onVKLoaded();      } );            loader.contentLoaderInfo.addEventListener( IOErrorEvent.IO_ERROR, function(e:IOErrorEvent):void      {        //trace( e.toString() );      }, false, 0, true );            loader.load( new URLRequest( url ), new LoaderContext( false, ApplicationDomain.currentDomain ) );    }        // ------------------------------------------------------------------------------ Creation wrappers.     public static function createMainMenu( wrapper:*, lazyMode:Boolean = false ):*    {MainMenu.STAGE_WIDTH = 807;       return new MainMenu( wrapper, lazyMode );    }        public static function createRoundButton( label:String, x:int, y:int, type:uint = 1 ):*    {      return new RoundButton( label, x, y, type );    }        public static function createSquareButton( label:String, x:int, y:int, type:uint = 1 ):*    {      return new SquareButton( label, x, y, type );    }        public static function createLinkButton( label:String, x:int, y:int, font_size:uint = 11, width:uint = 0, height:uint = 0 ):*    {      return new LinkButton( label, x, y, font_size, width, height );    }        public static function createLightButton( label:String, x:int, y:int, width:uint,            color:int, active_color:int, text_color:uint, active_text_color:uint,             align:uint = 0, font_size:uint = 11, margins:uint = 4 ):*    {      return new LightButton( label, x, y, width, color, active_color, text_color, active_text_color, align, font_size, margins );    }        public static function createComboBox( wrapper:*, x:int, y:int, width:uint ):*    {      return new ComboBox( wrapper, x, y, width );    }      public static function createListBox( x:int, y:int, width:uint ):*    {      return new ListBox( x, y, width );    }      public static function createBox( title:String, content:*, y:int, width:uint, buttons:Array ):*    {      return new Box( title, content, y, width, buttons );    }      public static function createCheckBox( title:String, x:int, y:int ):*    {      return new CheckBox( title, x, y );    }        public static function createRadioButtonsGroup( x:int, y:int ):*    {      return new RadioButtonsGroup( x, y );    }        public static function createPagination( totalCount:uint, x:uint, y:uint, height:uint = 0, type:uint = 0, pagesVisible:uint = 2, elemsOnPage:uint = 10 ):*    {      return new Pagination( totalCount, x, y, height, type, pagesVisible, elemsOnPage );    }        public static function createInputField( x:uint, y:uint, width:uint, linesCount:uint = 1, editable:Boolean = true, border:Boolean = true ):*    {      return new InputField( x, y, width, linesCount, editable, border );    }     public static function createScrollBar( x:int, y:int, height:int ):*    {      return new ScrollBar( x, y, height );    }     public static function addText( s:String, x:int, y:int, text_color:uint = 0, text_format:uint = 0x0010, width:uint = 0, height:uint = 0, font_size:uint = 11 ):*    {      return Utils.addText( x, y, width, font_size, s, text_color, text_format, height );    }  }} 
как сделать так чтобы этот код создавал все поля не по всей флэшке, а только на воторой сцене?
заранее огромное спасибо!
Ответить