gioorgionatili | 23 December, 2007 16:37
When you start to develop a Flash Lite 1.1 arcade game is often required to have a background that “loops” under your sprite according to the direction sprite.
This is not a very complicated stuff and now we’ll look very quickly how to implement this with the old Flash Lite 1.1 ActionScript.
Import in the library of your .fla a PNG file with the same height of the screen of your target device and with the width equal to the double of the screen width.
Create a movie clip that contain this file and then create a new symbol in which you have to place an instance of the background and to define the script that handle the scroll.
Organize your timeline in order to have a “move” and an “init” label, a layer for the code and another one for the graphic
In the “init” frame you define the direction of the scroll, duplicate the bg_mc movie clip and complete the stuffs needed in order to handle your scrolling background.
direction = 1;
duplicateMovieClip("bg_mc", "bg_mc_new", 1000);
bg_mc_new._x = bg_mc._x + bg_mc._width;
bgStartX = _x;
speed = 4;
columnWidth = 320;
Now you are ready to implement the script contained in the move label (remember that the script associated with a frame label in Flash Lite 1.1 are used like functions and can be invoked with the call instruction) that handle the _x of this movie clip
_x -= (speed*direction);
if (_x <= (bgStartX - _width + columnWidth)){
_x = bgStartX - columnWidth - speed;
}
if(_x >= 0){
_x = - _width/2 + speed;
}
This script always increment the _x property and then check if the background is going outside the boundaries of the stage.
In order to make the background moving you handle the left and the right arrow pressure moving the background timeline to the frame 2 in order to create a loop
tellTarget("../mainBg_mc"){
set("direction", -1);
gotoAndPlay(2);
}
For reference and in order to be clear this is the file described in this post.
gioorgionatili | 02/02/2008, 18:04
Hi Steve,
Thank for your welcome message, I hope that this posts help the developer community to complete simple task in the Flash Lite development.
fishermann | 22/03/2008, 20:15
Very interesting info, thanks.
Giorgio Natili is Adobe community expert, a W3C member and a Forum Nokia Champion. He is head of his own company GNStudio, which has been operating in the web development filed for the past 6 years. His field of expertise focus on Adobe Flash, Fireworks, Dreamweaver, Coldfusion Flash Media Server, Flex and their integration, as well as accessibility both in html and Flash. More recently his interests have broadened to include developing mobile applications and e-learning tools. He also works on various education initiatives to spread awareness on accessibility issues, especially to flash developers.
He strongly believes in the need to spread new web-technologies by ‘evangelizing’ in the Italian development communities. As a result he has been an active member of the Igenium community (Macromedia Users Group), taking part as an invited speaker, in the 2003, 2004 and 2005 webb.it events where he held numerous seminars on Flash and related technologies. In 2005 and 2006 he participated in SMAU in Milan, again holding seminaries and training sessions. He also spoke at the Adobe Max in Chicago and Barcelona in 2007.
In 2003 he received the award “Sito Protagonista” from Macromedia Italy for the website www.alessandracellini.com.
Among his many successful projects the on-line version of the TV game show “Quiz show” for Einstein Multimedia, subsequently published in the portal www.libero.it, along with the implementation of a Rich Internet Application for visualizing in real time Italian soccer championship games results, for the principal Italian media group, Gruppo Espresso.
In 2005 he founded the Flash community Actionscript.it that he is still leading and animating.
Throughout 2005 he has been Mobile and Technological innovation consultant for Saatchi & Saatchi Italia where he developed the J2me version on the mobile application D&G for Interpreting.it.
Throughout 2006 his Studio has established close partnerships with the mobile content provider Jamba, developing mobile applications for the Jamba development team, and MTV Italia, for whom he developed a chat environment driven by flash media server.
In the first half of 2007 he develops Intelligere SCS, a powerful web based synchronous collaboration system, entirely developed in Flex, and releases it under an open source license. The passion for community work continues with the founding of Flexdevelopers.org.
Welcome
Steve | 01/01/2008, 12:03
Good to see another Flash Lite blog on Forum. This is a useful article - and hope to see many more. Keep up the good work - and weclome Giorgio!