المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : جولة حول أكشن سكريبت 3 التعامل مع النصوص جزء3


azizsoft
22-09-2013, 09:21 PM
بسم الله الرحمن الرحيم
الحمدلله والصلاة والسلام على رسول الله وعلى آله وصحبه أجمعين
السلام عليكم ورحمة الله وبركاته





تغيير محتوى الحقل النصي


لاادخال تغييرات على الحقول النصية يمكن اعتماد الخاصيتين
text
htmlText
والوظيفيتين
appendText وهي تشبه المعامل += يعني الاثنين نفس الوظيفة
replaceText تعويض جزء من النص ولاتنطبق على نصوص نوع HTML


appendTex أو المعامل +=
يمكن الاضافة على الحقل النصي باعتماد المعامل المذكور على خاصية النص تاكست وليس HTML

في هذا المثال سنضيف مثلا رقم 3 الى كلمة ActionScript
ولاحظ استعملنا المعامل +=


var monTexte:TextField = new TextField();
addChild ( monTexte );
monTexte.autoSize = TextFieldAutoSize.LEFT;
monTexte.text = "ActionScript";
monTexte.text += " 3"
// affiche : ActionScript 3
trace( monTexte.text );



replaceText


يمكن اعتماد الوظيفية المذكورة التابعة لكلاس
TextField لتعويض حقل نصي وتستقبل 3 قيم

beginIndex بداية الحرف او الرقم المراد تعويضه وهو افتراضيا سالب 1
endIndex نهاية الحرف او الرقم المراد تعويضه وهو افتراضيا سالب 1
newText نص التعويض

نريد مثلا أن نقوم بتعويض رقم 2 الى 3 من كلمة اكشن سكريبت2



var monTexte:TextField = new TextField();
addChild ( monTexte );
monTexte.autoSize = TextFieldAutoSize.LEFT;
monTexte.text = "ActionScript 2";
monTexte.replaceText( 13, 14, "3" );
addChild ( monTexte );




تحمبل ملفات خارجية الى حقل نصي



يمكن تحميل ملفات خارجية كصورة او ملف swf الى الحقل النصي بواسطة الاكشن سكريبت
الكود أسفله يوضح كيفية استدعاء ملف خارجي عن طريق رابط ولاحظ أخي الكريم هنا قمنا باستدعاء صورة موقع محرك البحث قوقل
وطبعا يمكن تغيير رابط الصورة حسب رغبتك .


var monTexte:TextField = new TextField();
addChild ( monTexte );
monTexte.autoSize = TextFieldAutoSize.LEFT;
monTexte.htmlText = "<p>هذه صورة موقع قوقل في حقل نصي هش ت م ل</p><p><img src= 'http://www.google.com/intl/en_ALL/images/logo.gif' >";



عند تحميل الصور بهاته الطريقة يمكن ايضا ادخال تأثيرات عليها من خلال الوظيفة
getImageReference
من كلاس TextFied وهذا أمر ستناوله في موضوع لاحق ان شاء الله


أما بخصوص تحميل ملف swf يكون تحميله أيضا عن طريق نفس الوظيفة
getImageReference وكلاسLoader

ويتم تخزين ملف swf في متغير بهذا الشكل .


var swfLogo:Loader = Loader ( monTexte.getImageReference("monAnim") );




تجدر الملاحظة أن كلاس TextField

يحتوي على عديد الخصائص والوضائف التي تتطلب جهد كبيرجدا لشرحها وعموما يمكن أن القول أن أهم الخصائص كثيرة الاستعمال
تم التطرق اليها وفيها يلي تذكير لما سبق ذكره واهم خصائص ادراج النصوص بالاكشن سكريبت 3


المثال الأول
اضافة نص عادي مع اطار ملون وبعض خصائص التنسيقات


// Initialize a "TextField" instance
var txt:TextField = new TextField();

// set properties to define the text field
txt.x = 50; // Distance from the left edge
txt.y = 80; // Distance from the top edge
txt.width = 200; // Lenght of the text field
txt.textColor = 0x0000da; // Text color
txt.backgroundColor = 0xededfe; // Sets the background color
txt.background = true; // Enables to display the background colors
txt.borderColor = 0x007800; // Sets the border color
txt.border = true; // Enables to display the border
txt.text = "Welcome to abc4web.net"; // Add text

// Align the text in the created field
txt.autoSize = "center";

// Apply "addChild()" to add the text in the Flash presentation
addChild(txt);




المثال الثاني
اضافة نص مع استغلال خصائص css و html


// Initialize a "TextField" instance
var txt:TextField = new TextField();

// Defining properties for the text field
txt.width = 180;
txt.height = 100;
txt.wordWrap = true;
txt.multiline = true;

// store CSS styles in a String variable
var css_st:String = ".bv{color:#0808fe; font-family:Arial; font-size:16px; font-weight:bold;} .adf{color:#ed0708; font-family:Verdana; font-size:13px; font-style:italic}";

// Defines the instance for the "StyleSheet" object
var styles:StyleSheet = new StyleSheet();

// Applies the "parseCSS" method to the variable with the CSS styles
styles.parseCSS(css_st);

// uses the "styleSheet" property to attach the CSS styles to the "txt" instance
txt.styleSheet = styles;

// Adds HTML formated text
txt.htmlText = '<span class="bv">Welcome</span><br><font size="12" color="#00a800">to <u><a href="http://www.abc4web.net/vb/">abc4web.net</a></u></font><br><span class="adf">ActionScript course</span>.';

// add the text in the Flash presentation
addChild(txt);


المثال الثالث
تنسيق النص باستغلال كلاس TextFormat



// Create a TextFormat instance
var textF:TextFormat = new TextFormat();

// sets properties to format the text
textF.leftMargin = 55; // the left margin of the paragraph, in pixels
textF.font = "Arial"; // Defines the font used
textF.color = 0x5678fe; // Color
textF.size = 24; // Text size (in pixels)

// Initialize a "TextField" instance in a "txt" variable
var txt:TextField = new TextField();

// Defining properties for the text field
txt.width = 240;
txt.wordWrap = true;
txt.multiline = true;

txt.text = "Text with TextFormat \nActionScript 3 Course"; // Adds the Text

// Apply "setTextFormat()" to the text field , with the "textFormat" instance as argument
txt.setTextFormat(textF);

// add the text in the Flash presentation
addChild(txt);



حاول أخي الكريم مراجعة الأكواد ومحاولة القيام ببعض التطبيقات وتغغير النصوص وموقع
عرض النص بالفلاش لمزيد استيعاب الموضوع .


لاتنسونا من صالح الدعـــــــــــــــــــــ ـــــــــاء


استودعكم الله


[/COLOR]

خادم المسلمين
22-09-2013, 10:09 PM
بخصوص تعديل اللون اخى

لاحظ استفسارى من خلال هذه الصورة
http://im42.gulfup.com/GFYO9.png (http://www.gulfup.com/?oS04UT)

azizsoft
22-09-2013, 11:04 PM
بسم الله الرحمن الرحيم

السلام عليكم ورحمة الله وبركاته

الأمر سهل اختراي لون تريده يدويا بالماوس من حافظة الألوان من البرنامج نفسه
حدد القيمة اللونية الجديدة وانسخها مكان القديمة .
هــــــــــــــام

يجب دائما اضافة رقم 0 وحرف x من اليسار قبل الكود ........0x
(لاحظ الكود قبل الحذف) واحذف علامة الهاش #



بالتوفيق

أبو يوسف
23-09-2013, 05:49 PM
جزاك الله خيرا أخانا عزيز على هذه الجولات

أتمنى لك التوفيق :abc_152:

abohmam
24-09-2013, 01:37 PM
:teslam_2:

جزاك الله خيرا أخى عزيز

بارك الله فيك على الشرح والمتابعة

:abc_152:

azizsoft
24-09-2013, 07:03 PM
بسم الله الرحمن الرحيم

جزاكم الله خيرا على حضوركم الطيب

خادم المسلمين
25-01-2018, 01:03 PM
شـكــ وبارك الله فيك ـــرا لك ... لك مني أجمل تحية .